[SOLVED !] 7segment Decimal Point Value


Closed Thread
Results 1 to 12 of 12

Thread: 7segment Decimal Point Value4727 days old

  1. #1
    willim
    Guest

    0 Not allowed!

    Default 7segment Decimal Point Value

    Hi,

    I started to play with DS1820 and got a good success using Seven Segment Led's. First I used 3 digits display and the result is fantastic.

    Now want to use 4 digits with dec point...i.e.... 2 digits for the actual temperature and the last 2 digits are for decimal (00.00). The problem is I don't know how to convert the print command to display in my 7 segment led.

    Example:
    Print $FE, 1, Dec (RawTemp / 100), ".", DEC2 RawTemp, " C"

    While in 7SEGMENT LED

    DecOnes = Read Dig RawTemp.BYTE0,0
    DecTens = Read Dig RawTemp.BYTE0,1

    The above READ DIG will show unacceptable values. Any help from the guru's?

    [HTML] Device 16F628 ' We are using a PIC16F628
    Declare XTAL = 4 ' And a 4MHz crystal

    ' Config INTRC_OSC_NOCLKOUT, CP_OFF, WDT_OFF, PWRTE_ON, LVP_OFF
    @CONFIG_REQ
    @__config INTRC_OSC_NOCLKOUT & WDT_OFF & PWRTE_ON & LVP_OFF & CP_OFF & MCLRE_OFF
    ALL_DIGITAL = TRUE 'All I/O digital required for 16f628, comment out for 16f84

    ON_INTERRUPT GoTo MULT_INT ' Point to the interrupt handler and ENABLE global interrupts

    ' ** DEFINE VARIABLES **
    Dim DecOnes As Byte ' Led Decimal digit 1
    Dim DecTens As Byte ' Led Decimal digit 2
    Dim Ones As Byte ' Led Temp Actual Value digit 1
    Dim Tens As Byte ' Led Temp Actual Value digit 2
    Dim ActualTemp As Word ' The number to display on the LEDS in temperature
    Dim TempDecVal As Word ' The number to display the decimal temperature
    Dim RawTemp As Word ' Gathered data from Ds18s20
    Dim TimeShare As Byte ' Used by the interrupt for time sharing
    Dim VarX As Byte ' General Variable
    Dim VarY As Word ' General Variable
    Dim CountRemain As Byte ' Count remaining
    Dim Count_per_c As Byte ' Count per degree C

    ' ** ALIAS 7 SEGMENT DISPLAY CONTROL PINS **
    Symbol SEGMENTS = PORTB ' Use Port B for LED segment pins
    Symbol DIGIT1 = PORTA.6 ' Common Driver for display 1
    Symbol DIGIT2 = PORTA.7 ' Common Driver for display 2
    Symbol DIGIT3 = PORTA.0 ' Common Driver for display 3
    Symbol DIGIT4 = PORTA.1 ' Common Driver for display 4
    Symbol RUNLED = PORTA.3 ' Promgam monitor Led

    ' ** ALIAS DS1820 I/O PIN **
    Symbol DQ = PORTA.2

    ' ** Declare the flags of the INTCON register **
    Symbol T0IF = INTCON.2 ' Timer0 Overflow Interrupt Flag
    Symbol GIE = INTCON.7 ' Global Interrupt Enable
    Clear
    DelayMS 1000 ' Wait Micro to stabilized
    '************************************************* **********************************

    ' SEVEN SEGMENT DATA
    ' For Common Cathode
    Data 192,249,164,176,153,146,131,248,128,152,255

    GoTo Over_Subs ' Jump over the subroutine

    '************************************************* **********************************
    '************************************************* **********************************

    ' INTERRUPT HANDLER
    ' Multiplexes the 4-digits

    MULT_INT:-
    btfss TimeShare.0 ; If it's our turn then...
    jump TRY_DIGIT2
    bcf DIGIT4 ; Turn OFF the fourth LED
    movfw DecOnes ; Set up the pattern for PORTB
    bsf DIGIT1 ; Turn ON the first LED
    jump EXIT_INTERRUPT ; Exit the interrupt via TimeShare test
    TRY_DIGIT2:-
    ; Process the second display
    btfss TimeShare.1 ; If it's our turn then...
    jump TRY_DIGIT3
    bcf DIGIT1 ; Turn OFF the first LED
    movfw DecTens ; Set up the pattern for PORTB
    bsf DIGIT2 ; Turn ON the second LED
    jump EXIT_INTERRUPT ; Exit the interrupt via TimeShare test
    TRY_DIGIT3:-
    ; Process the third display
    btfss TimeShare.2 ; If it's our turn then...
    jump TRY_DIGIT4
    bcf DIGIT2 ; Turn OFF the second LED
    bcf Ones.7 ; Turn ON the decimal Point
    movfw Ones ; Set up the pattern for PORTB
    bsf DIGIT3 ; Turn ON the third LED
    jump EXIT_INTERRUPT ; Exit the interrupt via TimeShare test
    TRY_DIGIT4:-
    ; Process the fourth display
    btfss TimeShare.3 ; If it's our turn then...
    jump EXIT_INTERRUPT
    bcf DIGIT3 ; Turn OFF the third LED
    movfw Tens ; Set up the pattern for PORTB
    bsf DIGIT4 ; Turn ON the fourth LED
    EXIT_INTERRUPT:-
    movwf SEGMENTS ; Place the digit pattern on PORTB
    movlw 1
    clrc ; Clear the CARRY ready for the ROTATE
    rlf TimeShare,F ; Shift TimeShare Left
    btfsc TimeShare.4 ; Is bit 4 set ?
    movwf TimeShare ; Yes. So set TimeShare to 1
    bcf T0IF ; Reset TMR0 interrupt flag
    Context Restore ; Exit the interrupt

    '************************************************* ***********************************
    FLASH_LED:
    For VarX = 1 To 5
    Low RUNLED
    DelayMS 100
    High RUNLED
    DelayMS 100
    Next
    Return

    '************************************************* ***********************************

    ' Build up the seperate digits of variable TempDecVal
    Build_Digits:
    ; BUILD THE DECIMAL VALUE
    DecOnes = Read Dig TempDecVal.BYTE0,0
    DecTens = Read Dig TempDecVal.BYTE0,1

    ; BUILD THE TEMPERATURE VALUE
    Ones = Read Dig ActualTemp,0
    If ActualTemp < 10 Then
    Tens = 255 ' Blank the Tens DIGIT
    Else
    Tens = Read Dig ActualTemp.BYTE0,1
    EndIf
    Return

    '************************************************* ***********************************

    READ_TEMP:
    OWrite DQ, 1, [$CC, $44] ' Send Skip ROM command and Calculate Temp command
    While ORead DQ, 4 = 0 : Wend ' Wait until conversion is complete
    OWrite DQ, 1, [$CC, $BE] ' Send Skip ROM command and Read ScratchPad command
    ORead DQ, 0, [RawTemp.LowByte, RawTemp.HighByte,CountRemain,CountRemain,_
    CountRemain,CountRemain,CountRemain, Count_per_c]
    ' Calculate temperature in degrees C to 2 decimal places
    ' NOTE: The equation used will not work correctly with negative temperatures.
    RawTemp = (((RawTemp >> 1) * 100) - 25) + (((Count_per_c - CountRemain) * 100) / Count_per_c)
    ' Print $FE, 1, Dec (RAWTEMP / 100), ".", DEC2 RAWTEMP, " C"
    ' Calculate temperature in degrees F to 2 decimal places (not valid for negative temperature)
    ' RAWTEMP = (RAWTEMP */ 461) + 3200
    ' Print $FE, $C0, Dec (RAWTEMP / 100), ".", DEC2 RAWTEMP, " F"
    ActualTemp = RawTemp / 100
    TempDecVal = RawTemp
    Return
    '************************************************* ***********************************
    '************************************************* ***********************************

    Over_Subs:
    High RUNLED ; TURN OFF LED
    ' Set TMR0 to interrupt on rollover
    OPTION_REG = %00000011 ' Flash led
    INTCON = %00100000 ' Enable TMR0 overflow interrupt. ' Assign TMR0 clock to internal source
    While GIE = 1 : GIE = 0 : Wend ' Make sure global interrupts are off

    Output SEGMENTS
    High DIGIT1 : High DIGIT2 : High DIGIT3 : High DIGIT4
    TimeShare = 1 ' Reset the time share variable
    GIE = 1 ' Enable Global Interrupts

    '''*********************************************** *************************************
    MAINLOOP:

    For VarY = 0 To 1500
    DelayMS 1
    Next

    Low RUNLED
    DelayMS 100
    High RUNLED

    GoSub READ_TEMP
    GoSub Build_Digits

    GoTo MAINLOOP ' Do it forever
    End ' END OF PROGRAM [/HTML]

    Actually my problem is after the decimal point. If somebody can guide me in the right way, please help.

    willim

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,703
    Thumbs Up
    Received: 48
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    For starters I take it that the word var "RawTemp" holds the temperature in full

    something like 278 to be = to 27.8

    If so then

    DecOnes = dig RawTemp,0 ; read the value below the point
    DecUnits = dig RawTemp,1 ; Read the units
    DecTens = dig RawTemp,2 ; Read the Tens

    the result will be
    DecOnes = 8
    DecUnits = 7
    DecTens = 2

    If you want to get the value of the the number above the . in one go then

    DecTens = RawTemp / 10
    Tim

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    willim
    Guest

    0 Not allowed!

    Default

    Hi Tim,

    Many thanks! I have a working Temperature control now.

    Willim

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,530
    Thumbs Up
    Received: 75
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default

    Willim,

    How do you get to print the (.)? I couldn't understand it. I did some 7 ssegment but only numbers. If you have 27.8 how do you get the (.) after reading the 8 on a 7 segment?

    Thank you

    Joseph

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,703
    Thumbs Up
    Received: 48
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    The dot is available on some 7 LED's some times its on every segment others where its a 4 pack its in the middle. Nearly all are activated by Bit 8 of the data line.
    Tim

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    willim
    Guest

    0 Not allowed!

    Default

    Hi joseph,

    Tim is right, In my case it is a commom anode 7segment led. So, you have to clear bit 8 of the target 7segment led. DP (decimal point) are common in 7Segment Led's.

    willim

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    willim
    Guest

    0 Not allowed!

    Default

    Here is a brief Explanation of 7SEGMENT Led



    The 7 segment display is used as a numerical indicator on many types of test equipment.
    It is an assembly of light emitting diodes which can be powered individually.
    They most commonly emit red light.
    They are arranged and labelled as shown in the diagram.

    Powering all the segments will display the number 8.
    Powering a,b,c d and g will display the number 3.
    Numbers 0 to 9 can be displayed.
    The d.p represents a decimal point.

    The one shown is a common anode display since all anodes are joined together and go to the positive supply.
    The cathodes are connected individually to zero volts.
    Resistors must be placed in series with each diode to limit the current through each diode to a safe value.


    Common cathode displays where all the cathodes are joined are also available.


    willim

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    willim
    Guest

    0 Not allowed!

    Default

    Here is the picture

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,530
    Thumbs Up
    Received: 75
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default

    Thank you for your replies,

    I think that I wasn't clear in my question.

    Let say as per Tim example that I have a number 27.8. I know how to DIG out the numbers to display on a 7 segment. I also know how the dot is connected.

    I cannot understand how to make the software to select the dot.

    i.e.: -

    If the number is 2.78 and is being incrementing and at a certain count this number increases to 27.8, how can I DIG out the dot to place it after first digit and then after the second digit and then after the third digit and so on?

    Regards

    Joseph

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    willim
    Guest

    0 Not allowed!

    Default

    ok let as do it like this...

    [HTML]Dim AfterDot as byte ' value after decimal (.) point (00.0)
    Dim Ones as byte ' One's or Units value (00.0
    Dim Tens as byte ' Ten's value (00.0
    [/HTML]

    Usually we are declaring the above variables as an alias for each 7 segment LED.

    if you want the to place the dot as shown (00.0) then set the bit7 of ONES before you send the data to the display. That is if you are using a common cathode leds. Clear it for common anode leds.

    [HTML]Dim AfterDot as byte ' value after decimal (.) point (00.0)
    Dim Ones as byte ' One's or Units value (00.0
    Dim Tens as byte ' Ten's value (00.0
    [/HTML]

    if you want it like this (0.00) then set bit7 of variable TENS. or clear it if you are using common anode.

    [HTML]Set TENS.7[/HTML]

    Hope this help,
    willim

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    willim
    Guest

    0 Not allowed!

    Default

    Sory for the wrong answer...

    here it is

    [HTML]Dim AfterDot as byte ' value after decimal (.) point (00.x)
    Dim Ones as byte ' One's or Units value (0x.0)
    Dim Tens as byte ' Ten's value (x0.0)[/HTML]

    Usually we are declaring the above variables as an alias for each 7 segment LED.

    if you want the to place the dot as shown (00.0) then set the bit7 of ONES before you send the data to the display. That is if you are using a common cathode leds. Clear it for common anode leds.

    [HTML]Set Ones.7[/HTML]

    if you want it like this (0.00) then set bit7 of variable TENS. or clear it if you are using common anode.

    [HTML]Set Tens.7[/HTML]


    willim

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,530
    Thumbs Up
    Received: 75
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default

    Thank you for your answer,

    I will try what you suggested.

    Regards

    Joseph

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Display no decimal point on a float.
    By geoff_c in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 8th February 2017, 20:42
  2. More than three digits after the decimal point
    By pe1pme in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 23rd December 2015, 21:35
  3. [SOLVED !] LCD decimal point
    By Peter D in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 22nd February 2008, 13:01
  4. [SOLVED !] How to use 74Hc164 for drive 7segment ?
    By maxiboost in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 13th June 2007, 06:05
  5. [SOLVED !] bcd to decimal
    By ADLIN SYSTEMS in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 31st March 2007, 14:24

Tags for this Thread

Posting Permissions

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