How to display dot on 7-seg , 4 digit


Closed Thread
Results 1 to 28 of 28
  1. #1
    Join Date
    May 2005
    Posts
    70

    Angry How to display dot on 7-seg , 4 digit

    we try to used 7-seg 4 digit.
    but we don't know how to display dot (Ex. 45.46)

  2. #2
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Think of the display as a 8 segment display, where the eighth 'segment' is the decimal. Keep this 'segment' off in all the digits, except for the one where you want the decimal to show.

    Regards,

    Anand

  3. #3
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Need more informatiom
    here is may code :for display 7-seg

    For i = 0 To 3 ' Loop through 4 digits
    n = Value Dig i ' Get digit to display
    Gosub display1 ' Display the value
    NEXT I
    goto mainloop

    display1:
    Digits = $ff ' All digits off to prevent ghosting

    ' Convert binary number in n to segments for LED
    ' COM ANODE 1234567890

    Lookup n, [$3F,$06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F], Segments

    ' Set digit pin i to 0 (on) and the rest of the pins to 1 (off)

    Digits = ~Dcd i

    Return

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Question

    Your code is not complete! You have a nice lookup table but you do not use the outcome from the table? Where do you use the variable Segments? Is Digits the name of your port? (which you imply when you set it = $FF at one point)

    Also, the way you have it (Digits =~DCD i)
    Digits can only be

    11111110
    11111101
    11111011
    11110111

    Although it is late here, your code makes no sense to me

    However, if Digits does control the port, it looks like you can turn your DP on by issuing this
    Digits.7 = 0
    (provided the wire or trace from the DP goes to pin 7 of your port).

    Post complete code for better shot at guessing what you are trying to do.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    ok it's not 4am (it's 8:15am)

    i see what the dcd command is doing (common anode as you noted).

    For the digit you want to have the dp on try

    Sements.7 = 0 (provided your PORT.7 pin is tied to the DP via wire or trace


    Good Luck
    Last edited by paul borgmeier; - 23rd December 2006 at 15:19.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    One more time - after a proper days rest, I have no clue what your code does; it looks to me to be partly written for common anode displays ($3F=1) and partly written for common cathode displays (Digits = ~DCD i). The Segments.7=0 should work (right after your lookup table) for the digit you want the DP to be on. Please post full code or schematic for more definite help.
    Again, Good Luck
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  7. #7
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi paul borgmeier
    Now I try to show temp with DS1820 on 7 seg 4 digit
    Below is code , I can read data temp from ds1820 and send to RS232 -->OK but canot to diplay to 7 Seg. Ex 29.05C

    Code :
    Define LOADER_USED 1
    DEFINE OSC 4
    @ Device pic16F877, xt_OSC, BOD_OFF, PWRT_ON, WDT_OFF, PROTECT_OFF,WRT_ON

    Segments Var PORTC
    Digits Var PORTD

    i Var Byte
    n Var Byte
    Value Var Word


    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output


    ' Allocate variables
    command var byte ' Storage for command
    J var byte ' Storage for loop counter
    temp var word ' Storage for temperature
    DQ var PORTd.4 ' Alias DS1820 data pin
    DQ_DIR var TRISd.4 ' Alias DS1820 data direction pin

    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output
    TrisB = $00
    Portb = $00
    OPTION_REG = $55 ' Set TMR0 configuration 1:64
    INTCON = $A0 ' Enable TMR0 interrupts
    On Interrupt Goto display

    ADCON1 = 7 ' Set PORTA and PORTE to digital

    ' Lcdout $fe, 1, "Temp in degrees C" ' Display sign-on message
    'debug ====
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds ,4 m
    'debug ====

    ' Mainloop to read the temperature and display on LCD
    mainloop:
    Gosub init1820 ' Init the DS1820

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $44 ' Start temperature conversion
    Gosub write1820

    Pause 2000 ' Wait 2 seconds for conversion to complete

    Gosub init1820 ' Do another init

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $be ' Read the temperature
    Gosub write1820
    Gosub read1820

    'Display the decimal temperature
    'Lcdout $fe, 1, dec (temp >> 1), ".", dec (temp.0 * 5), " degrees C"
    'HSEROUT ["Temp = ",dec (temp>>1),".", dec (temp.0*5)," C",13,10]
    Goto mainloop ' Do it forever


    ' Initialize DS1820 and check for presence
    init1820:
    Low DQ ' Set the data pin low to init
    Pauseus 500 ' Wait > 480us
    DQ_DIR = 1 ' Release data pin (set to input for high)

    Pauseus 100 ' Wait > 60us
    If DQ = 1 Then
    'Lcdout $fe, 1, "DS1820 not present"
    Pause 500
    Goto mainloop ' Try again
    Endif
    Pauseus 400 ' Wait for end of presence pulse
    Return


    ' Write "command" byte to the DS1820
    write1820:
    For j = 1 to 8 ' 8 bits to a byte
    If command.0 = 0 Then
    Gosub write0 ' Write a 0 bit
    Else
    Gosub write1 ' Write a 1 bit
    Endif
    command = command >> 1 ' Shift to next bit
    Next j
    Return

    ' Write a 0 bit to the DS1820
    write0:
    Low DQ
    Pauseus 60 ' Low for > 60us for 0
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Return

    ' Write a 1 bit to the DS1820
    write1:
    Low DQ ' Low for < 15us for 1
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Pauseus 60 ' Use up rest of time slot
    Return


    ' Read temperature from the DS1820
    read1820:
    For J = 1 to 16 ' 16 bits to a word
    temp = temp >> 1 ' Shift down bits
    Gosub readbit ' Get the bit to the top of temp
    Next J
    Return

    ' Read a bit from the DS1820
    readbit:
    temp.15 = 1 ' Preset read bit to 1
    Low DQ ' Start the time slot
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    If DQ = 0 Then
    temp.15 = 0 ' Set bit to 0
    Endif
    Pauseus 60 ' Wait out rest of time slot
    Return

    '================== 7 seg ment display ==============================
    disable
    display:
    INTCON.2 = 0 'clear the interrupt flag

    VALUE = (temp >>1)+(temp.0 * 5)

    For i = 0 To 3 ' Loop through 4 digits
    n = Value Dig i ' Get digit to display
    Gosub display1 ' Display the value
    NEXT I

    goto mainloop

    display1:
    Digits = $ff ' All digits off to prevent ghosting

    ' Convert binary number in n to segments for LED
    ' COM ANODE 1234567890
    Lookup n, [$3F,$06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F, $77, $7C, $39, $5E, $79, $71], Segments
    ' Set digit pin i to 0 (on) and the rest of the pins to 1 (off)

    Digits = ~Dcd i

    Return
    enable
    End
    Attached Images Attached Images  

  8. #8
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=chai98a;30011]Hi paul borgmeier
    Now I try to show temp with DS1820 on 7 seg 4 digit
    Below is code , I can read data temp from ds1820 and send to RS232 -->OK but canot to diplay to 7 Seg. Ex 29.5C

    How to show number , dot and character on display ??

    Code :
    Define LOADER_USED 1
    DEFINE OSC 4
    @ Device pic16F877, xt_OSC, BOD_OFF, PWRT_ON, WDT_OFF, PROTECT_OFF,WRT_ON

    Segments Var PORTC
    Digits Var PORTD

    i Var Byte
    n Var Byte
    Value Var Word


    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output


    ' Allocate variables
    command var byte ' Storage for command
    J var byte ' Storage for loop counter
    temp var word ' Storage for temperature
    DQ var PORTd.4 ' Alias DS1820 data pin
    DQ_DIR var TRISd.4 ' Alias DS1820 data direction pin

    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output
    TrisB = $00
    Portb = $00
    OPTION_REG = $55 ' Set TMR0 configuration 1:64
    INTCON = $A0 ' Enable TMR0 interrupts
    On Interrupt Goto display

    ADCON1 = 7 ' Set PORTA and PORTE to digital

    ' Lcdout $fe, 1, "Temp in degrees C" ' Display sign-on message
    'debug ====
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds ,4 m
    'debug ====

    ' Mainloop to read the temperature and display on LCD
    mainloop:
    Gosub init1820 ' Init the DS1820

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $44 ' Start temperature conversion
    Gosub write1820

    Pause 2000 ' Wait 2 seconds for conversion to complete

    Gosub init1820 ' Do another init

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $be ' Read the temperature
    Gosub write1820
    Gosub read1820

    'Display the decimal temperature
    'Lcdout $fe, 1, dec (temp >> 1), ".", dec (temp.0 * 5), " degrees C"
    'HSEROUT ["Temp = ",dec (temp>>1),".", dec (temp.0*5)," C",13,10]
    Goto mainloop ' Do it forever


    ' Initialize DS1820 and check for presence
    init1820:
    Low DQ ' Set the data pin low to init
    Pauseus 500 ' Wait > 480us
    DQ_DIR = 1 ' Release data pin (set to input for high)

    Pauseus 100 ' Wait > 60us
    If DQ = 1 Then
    'Lcdout $fe, 1, "DS1820 not present"
    Pause 500
    Goto mainloop ' Try again
    Endif
    Pauseus 400 ' Wait for end of presence pulse
    Return


    ' Write "command" byte to the DS1820
    write1820:
    For j = 1 to 8 ' 8 bits to a byte
    If command.0 = 0 Then
    Gosub write0 ' Write a 0 bit
    Else
    Gosub write1 ' Write a 1 bit
    Endif
    command = command >> 1 ' Shift to next bit
    Next j
    Return

    ' Write a 0 bit to the DS1820
    write0:
    Low DQ
    Pauseus 60 ' Low for > 60us for 0
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Return

    ' Write a 1 bit to the DS1820
    write1:
    Low DQ ' Low for < 15us for 1
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Pauseus 60 ' Use up rest of time slot
    Return


    ' Read temperature from the DS1820
    read1820:
    For J = 1 to 16 ' 16 bits to a word
    temp = temp >> 1 ' Shift down bits
    Gosub readbit ' Get the bit to the top of temp
    Next J
    Return

    ' Read a bit from the DS1820
    readbit:
    temp.15 = 1 ' Preset read bit to 1
    Low DQ ' Start the time slot
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    If DQ = 0 Then
    temp.15 = 0 ' Set bit to 0
    Endif
    Pauseus 60 ' Wait out rest of time slot
    Return

    '================== 7 seg ment display ==============================
    disable
    display:
    INTCON.2 = 0 'clear the interrupt flag

    VALUE = (temp >>1)+(temp.0 * 5)

    For i = 0 To 3 ' Loop through 4 digits
    n = Value Dig i ' Get digit to display
    Gosub display1 ' Display the value
    NEXT I

    goto mainloop

    display1:
    Digits = $ff ' All digits off to prevent ghosting

    ' Convert binary number in n to segments for LED
    ' COM ANODE 1234567890
    Lookup n, [$3F,$06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F, $77, $7C, $39, $5E, $79, $71], Segments
    ' Set digit pin i to 0 (on) and the rest of the pins to 1 (off)

    Digits = ~Dcd i

    Return
    enable
    End

  9. #9
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    I see - the PNPs (which I did not know about) threw me off. It appears proper for Common Anode.

    Try this:
    1) On your buffer, tie 1 and 19 low so they do not float.
    2) The 3rd from last line of your code - change "Return" to "Resume" (See manual section on On Interrupt for details).

    Please report back progress so that others following this can get closure.

    EDIT:
    3) Your lookup values need to be inverted - as written they are for common cathode displays. Change to ($C0, $F9, $A4, etc) where the segments you want off are high and the segments you want on are low.
    4) To turn on the decimal point on the second digit, insert right after the lookup table
    if i = 1 then Segments.7 = 0 (or if the DP is always to be on you could do this in hardware by disconnecting RC7 from D7 on U2 and connecting RD1 to D7 on U2 (in addition to RD1 going to the Base of Q2))
    Last edited by paul borgmeier; - 26th December 2006 at 07:15. Reason: add more info
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  10. #10
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Here is the full list of Common Cathode:

    Starting from 0 to 9.

    $c0, $F9, $A4, $B0, $99, $92, $82, $F8, $80, $90



    ------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  11. #11
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Sayzer,
    You bolded Common Cathode as if it is for sure - you must mean Common Anode. Common Cathode requires the segment to be high to be on while Common Anode requires Segments to be low to be on. His buffer is non-inverting. (Your set looks correct though - I left a little for the OP to work out as a learning exercise but now he is close to set).

    EDIT:
    Oh, for thoroughness, have you considered testing DT's suggested gif animator at 1/4 scale?
    Last edited by paul borgmeier; - 26th December 2006 at 19:35.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  12. #12
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi Paul,

    My set is for Common Cathode.
    I now see what you meant.

    Let me check for Common Anode...Should be somewhere in my HDDs.

    BTW; I am just testing the animator and will remove it now. I think is is slowing down the CPU when there is more then one running.

    -----------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  13. #13
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Sayzer,

    You have it correct for Common Anode in post #10 (at least the first three are correct - I didn't check your others). The OP should be grateful for your help because you probably saved him hours of work and frustration)

    Best Wishes
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  14. #14
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Paul,

    Ok, here is the clarification.
    (from 0 to 9)

    Common Anode : $c0, $F9, $A4, $B0, $99, $92, $82, $F8, $80, $90

    Common Cathode : $3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F


    Using Dot or not changes from set to set.
    These are what I use.




    ----------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  15. #15
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi paul borgmeier
    I'm not understand for item 1
    1) On your buffer, tie 1 and 19 low so they do not float.

    For item 4 , as you advise with modify some hard were right, Do you have other way with out modify hard or not.

  16. #16
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    1) On U2, pins 1 and 19 both must be connected to GND (or held low) in order for the input to be placed on the output of the buffer. If either pin is high, then the entire output of U2 will be tri-stated (high impedance). Floating means leaving pins NOT or unconnected, which is not good because they can "do what they want" - stay low, drift high, or worse go somewhere in-between. Just connect both 1 and 19 to GND and you will be set.

    4) The DP can be set entirely in software using the added line of code OR it can be set in hardware. If you cannot change your circuit, then use the software version. Just add the IF-THEN statement shown in 4) and you should have a DP turned on.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  17. #17
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Post

    Hi paul borgmeier
    Thank for you reply..
    Soory! for circuit not clear for you.. , we used 7 seg COM Cathode..
    This circuit i have test with time counter alredly done no problem.
    But after we apply Display sub to 1820 reading ,so got problem display cannot show reading on 7 seg display..

    Pls any xepert advise >> very confiuse for me

    code: time conter
    DEFINE LOADER_USED 1
    DEFINE OSC 4

    @ Device pic16F877, xt_OSC, BOD_OFF, PWRT_ON, WDT_OFF, PROTECT_OFF,WRT_ON

    Segments Var PORTC
    Digits Var PORTD

    i Var Byte
    n Var Byte
    J var byte
    Value Var WORD
    Hr var byte
    Minute var BYTE ' Define minute variable
    Second var BYTE ' Define second variable
    Ticks var byte ' Define pieces of seconds variable
    D_up var byte

    clear ' clear all RAM (sets all VAR declarations to zero)
    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output
    TrisB = $00
    Portb = $00
    OPTION_REG = $55 ' Set TMR0 configuration 1:64
    INTCON = $A0 ' Enable TMR0 interrupts
    On Interrupt Goto int0

    mainloop:
    goto display

    goTo mainloop ' Do it forever


    disable
    int0:
    Ticks = Ticks + 1 ' Count pieces of seconds
    If Ticks < 61 Then goto ExitInterrupt ' 61 ticks per second

    ' One second elasped - update time
    Ticks = 0
    Second = Second + 1
    If Second >= 60 Then
    Second = 0
    Minute = Minute + 1
    If Minute >= 60 Then
    D_up =1
    Minute = 0
    Hr =hr + 1
    If Hr >= 60 Then
    Hr = 0

    endif
    endif
    Endif

    goto mainloop

    display:

    If D_up = 1 then
    VALUE = ((Hr*100)+Minute)
    goto dup
    else
    VALUE = ((minute*100)+second)
    endif

    dup:
    For i = 0 To 3 ' Loop through 4 digits
    n = Value Dig i ' Get digit to display

    ' Gosub display1 ' Display the value
    Digits = $ff

    Lookup n, [$3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F,_
    $77, $7C, $39, $5E, $79, $71, $0FF], Segments
    Digits = ~Dcd i

    NEXT I
    goto mainloop

    ExitInterrupt:
    INTCON.2 = 0 'clear the interrupt flag
    Resume
    enable


    code : 1820 reading
    Define LOADER_USED 1
    DEFINE OSC 4
    @ Device pic16F877, xt_OSC, BOD_OFF, PWRT_ON, WDT_OFF, PROTECT_OFF,WRT_ON

    Segments Var PORTC
    Digits Var PORTD

    i Var Byte
    n Var Byte
    Value Var Word

    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output

    ' Allocate variables
    command var byte ' Storage for command
    J var byte ' Storage for loop counter
    temp var word ' Storage for temperature
    DQ var PORTd.4 ' Alias DS1820 data pin
    DQ_DIR var TRISd.4 ' Alias DS1820 data direction pin

    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output
    TrisB = $00
    Portb = $00
    OPTION_REG = $55 ' Set TMR0 configuration 1:64
    INTCON = $A0 ' Enable TMR0 interrupts
    On Interrupt Goto display

    ADCON1 = 7 ' Set PORTA and PORTE to digital
    'debug ====
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds ,4 m
    'debug ====
    ' Mainloop to read the temperature and display on LCD
    mainloop:
    Gosub init1820 ' Init the DS1820

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $44 ' Start temperature conversion
    Gosub write1820

    Pause 2000 ' Wait 2 seconds for conversion to complete

    Gosub init1820 ' Do another init

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $be ' Read the temperature
    Gosub write1820
    Gosub read1820

    'Display the decimal temperature
    HSEROUT ["Temp = ",dec (temp>>1),".", dec (temp.0*5)," C",13,10]
    Goto mainloop ' Do it forever
    ' Initialize DS1820 and check for presence
    init1820:
    Low DQ ' Set the data pin low to init
    Pauseus 500 ' Wait > 480us
    DQ_DIR = 1 ' Release data pin (set to input for high)

    Pauseus 100 ' Wait > 60us
    If DQ = 1 Then
    'Lcdout $fe, 1, "DS1820 not present"
    Pause 500
    Goto mainloop ' Try again
    Endif
    Pauseus 400 ' Wait for end of presence pulse
    Return
    ' Write "command" byte to the DS1820
    write1820:
    For j = 1 to 8 ' 8 bits to a byte
    If command.0 = 0 Then
    Gosub write0 ' Write a 0 bit
    Else
    Gosub write1 ' Write a 1 bit
    Endif
    command = command >> 1 ' Shift to next bit
    Next j
    Return

    ' Write a 0 bit to the DS1820
    write0:
    Low DQ
    Pauseus 60 ' Low for > 60us for 0
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Return

    ' Write a 1 bit to the DS1820
    write1:
    Low DQ ' Low for < 15us for 1
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Pauseus 60 ' Use up rest of time slot
    Return


    ' Read temperature from the DS1820
    read1820:
    For J = 1 to 16 ' 16 bits to a word
    temp = temp >> 1 ' Shift down bits
    Gosub readbit ' Get the bit to the top of temp
    Next J
    Return

    ' Read a bit from the DS1820
    readbit:
    temp.15 = 1 ' Preset read bit to 1
    Low DQ ' Start the time slot
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    If DQ = 0 Then
    temp.15 = 0 ' Set bit to 0
    Endif
    Pauseus 60 ' Wait out rest of time slot
    Return

    '================== 7 seg ment display ==============================
    disable
    display:

    VALUE = (temp >>1)

    For i = 0 To 3 ' Loop through 4 digits
    n = Value Dig i ' Get digit to display

    ' Gosub display1 ' Display the value
    Digits = $ff
    Lookup n, [$3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F,_
    $77, $7C, $39, $5E, $79, $71, $0FF], Segments
    Digits = ~Dcd i

    NEXT I
    INTCON.2 = 0 'clear the interrupt flag
    goto mainloop
    Resume
    enable
    End

  18. #18
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Question

    Chai98a,
    Soory! for circuit not clear for you.. , we used 7 seg COM Cathode..
    It is clear to me as presented. Is it wrong? I did not assume Common Anode – you told me it was Common Anode (see your third post). The transistors shown in your schematic and the code line Digits=~DCD i also imply Common Anode.

    Your code is largely not commented
    Your schematic is not complete

    I spent considerable time sorting all this out and now I will not offer more until you give more detail.

    1) Is the the schematic fragment correct?
    2)What is the P/N of Q1-Q4 are they really PNP?
    3)What troubles are you having (i.e., does the display light up (at all)? wrong temp? junk? just missing DP?)
    4) Are pins 1 and 19 tied low on U2?
    5) With the code you posted in #17, how does temp get set? (I don't believe it ever does)

    From post #7
    I can read data temp from ds1820 and send to RS232 -->OK but canot to diplay to 7 Seg. Ex 29.5C
    and from post #17
    This circuit i have test with time counter alredly done no problem
    it appears to me you have everything you need – your circuit works and you must have code to drive it; your temperature sensor reads temperature correctly.

    I am not sure how to help you until you provide more information
    Last edited by paul borgmeier; - 28th December 2006 at 16:33.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  19. #19
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default ...then sayzer gets into the scene.

    Paul, let me help you here a little.

    I see you are trying to help; all of us went through the same process that Chai98a is now going through.
    I am sure when Chai98a gets more experienced, he will also help others on this forum as much as he can.


    Chai98a, are you using standard 4x7 segments LED display? or it is one of those LARGE ones?

    Also, why are you using 74HC ?

    Based on your answer, I will post a schematic for you.

    ---------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  20. #20
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    With this talk of CC and CA displays, I'd like to share a technique I've used and found very useful.

    I like to design PCBs that would work with CA as well as CC displays; the only hardware difference between the two is whether to tie the emitters of the driver transistors to +5 or ground, depending on the display.

    So, provide for a jumper that lets you select between the two.

    AND, use this signal as an input to the PIC to tell it what kind of display is being used. Keep 2 lookup tables in the code, one for CA and the other for CC; depending on the state of the jumpered signal, the code uses the corresponding lookup.

    During production time, then, it becomes easier as one could use either CA or CC, without having to change the code; just connect the common line to +5 or Gnd, and it will work.

    Regards,

    Anand

  21. #21
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Paul, let me help you here a little.
    I do not need help ... the OP does Anyone is welcome to contribute and chime in.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  22. #22
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi sayzer and paul borgmeier
    # Is the the schematic fragment correct?
    -see attached
    # What is the P/N of Q1-Q4 are they really PNP?
    -TR # BC557
    # What troubles are you having (i.e., does the display light up (at all)? wrong temp? junk? just missing DP?)
    -found Junk display,flash ,missing dp
    # Are pins 1 and 19 tied low on U2?
    - yes
    # are you using standard 4x7 segments LED display?
    - we used standard 7 seg.
    # why are you using 74HC ?
    - I did follow some sample on web

  23. #23
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Red face

    Quote Originally Posted by paul borgmeier View Post
    I do not need help ... the OP does Anyone is welcome to contribute and chime in.
    Maybe I do need help - I need to sharpen/review my PNP circuit abilites a bit and will comment soon.

    Others welcome to comment.

    EDIT:
    based on an offlist conversation with another member
    Last edited by paul borgmeier; - 28th December 2006 at 19:10.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  24. #24
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Sayzer - where did you go ... I thought you were helping me here? .

    Chai98a,
    As Sayzer was hinting at in his "Large" post, if you are using a "standard" common-sized common anode display, you might want to simplify your circuit and follow something like figure 6 of the below link. Your schematic as draw is not correct and makes little sense (to me).

    http://picbasic.com/resources/articles/ledart.htm

    Is this an option or are you locked into your hardware as shown in your earlier post?
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  25. #25
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    We had a long holiday here in Turkey.

    Sorry Paul. I was busy with my .... (fill in the blank).


    I will post some concept schematics, using PNP, NPN and ULN type of drivers.

    -----------------

  26. #26
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Now we finish 7 seg display temp form ds1820 about 90%
    But we stil have porblem with display fashing and i have try at 20 Mhz cannot resolve it



    Code:

    Define LOADER_USED 1
    DEFINE OSC 4
    @ Device pic16F877A, xt_OSC, BOD_OFF, PWRT_ON, WDT_OFF, PROTECT_OFF 'WRT_On

    Segments Var PORTC
    Digits Var PORTD

    i Var Byte
    n Var Byte
    Value Var Word

    ' Allocate variables
    command var byte ' Storage for command
    J var byte ' Storage for loop counter
    temp var word ' Storage for temperature
    T VAR WORD
    DQ var PORTd.4 ' Alias DS1820 data pin
    DQ_DIR var TRISd.4 ' Alias DS1820 data direction pin
    read_done var byte
    Lastdata var word


    TRISc = $00 ' Set segment pins to output
    TRISd = $f0 ' Set digit pins to output
    TrisB = $00
    Portb = $00
    portd = $ff

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 12 ' 19200 Bauds ,4 m
    'debug ====

    ' Mainloop to read the temperature and display on LCD


    mainloop:
    'goto display
    'Goto mainloop

    Gosub init1820 ' Init the DS1820

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $44 ' Start temperature conversion
    Gosub write1820

    Pause 2000 ' Wait 2 seconds for conversion to complete

    Gosub init1820 ' Do another init

    command = $cc ' Issue Skip ROM command
    Gosub write1820

    command = $be ' Read the temperature
    Gosub write1820
    Gosub read1820


    'Display the decimal temperature
    'HSEROUT ["Temp = ",dec (temp>>1),".", dec (temp.0*5)," C",13,10]
    'T = ((temp>> 1)*100)+((TEMP.0*5)*10)
    'HSEROUT ["Temp = ",dec T ,13,10]
    value = ((temp>> 1)*100)+((TEMP.0*5)*10)
    GOTO DISPLAY
    Goto mainloop ' Do it forever


    ' Initialize DS1820 and check for presence
    init1820:
    Low DQ ' Set the data pin low to init
    Pauseus 500 ' Wait > 480us
    DQ_DIR = 1 ' Release data pin (set to input for high)

    Pauseus 100 ' Wait > 60us
    If DQ = 1 Then
    'Lcdout $fe, 1, "DS1820 not present"
    Pause 500
    Goto mainloop ' Try again
    Endif
    Pauseus 400 ' Wait for end of presence pulse
    Return


    ' Write "command" byte to the DS1820
    write1820:
    For i = 1 to 8 ' 8 bits to a byte
    If command.0 = 0 Then
    Gosub write0 ' Write a 0 bit
    Else
    Gosub write1 ' Write a 1 bit
    Endif
    command = command >> 1 ' Shift to next bit
    Next i
    Return

    ' Write a 0 bit to the DS1820
    write0:
    Low DQ
    Pauseus 60 ' Low for > 60us for 0
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Return

    ' Write a 1 bit to the DS1820
    write1:
    Low DQ ' Low for < 15us for 1
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    Pauseus 60 ' Use up rest of time slot
    Return


    ' Read temperature from the DS1820
    read1820:
    For i = 1 to 16 ' 16 bits to a word
    temp = temp >> 1 ' Shift down bits
    Gosub readbit ' Get the bit to the top of temp
    Next i
    Return

    ' Read a bit from the DS1820
    readbit:
    temp.15 = 1 ' Preset read bit to 1
    Low DQ ' Start the time slot
    @ nop ' Delay 1us at 4MHz
    DQ_DIR = 1 ' Release data pin (set to input for high)
    If DQ = 0 Then
    temp.15 = 0 ' Set bit to 0
    Endif
    Pauseus 60 ' Wait out rest of time slot
    Return
    '================== 7 seg ment display ==============================
    display:
    'value = ((temp>> 1)*100)+((TEMP.0*5)*10)

    PORTC = $39
    LOW DIGITS.0
    PAUSEUS 1500
    PORTC = $0

    'value = 125
    For i = 1 To 4 ' Loop through 4 digits

    n = Value Dig i ' Get digit to display

    ' Gosub display1 ' Display the value
    Digits = $ff

    Lookup n, [$3F, $06, $5B, $4F, $66, $6D, $7D, $07, $7F, $6F,_
    $77, $7C, $39, $5E, $79, $71, $0FF], Segments

    If i = 2 then segments = segments + 128 'Digit 2 show dot

    Digits = ~Dcd i

    NEXT I
    goto mainloop
    End

  27. #27
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    If you have more then 2ms pause in total during the whole process, you will see blinking.

    Have your calculator and start adding your pauses.
    See what the total is.

    Also, remove any repeat routines if any.

    I have no time to check your code.

    Why don't you use an easier DS1820 code by the way?


    ----------------------

  28. #28
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi sayzer thank you we done after try remove 2 ms out.


    Buy the way we will post this code in exampls code for share with other peple

Similar Threads

  1. Hdsp 21xx display
    By Original in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th June 2012, 20:07
  2. LED Machine Tach For Tired Eyes
    By Archangel in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 27th January 2010, 14:55
  3. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  4. DS1820 display with 7-seg 4 digits
    By chai98a in forum Code Examples
    Replies: 12
    Last Post: - 10th April 2008, 13:12
  5. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts