Menu

digital thermometer using 3x7segment displays

Help
JANIS
2017-08-24
2017-08-25
  • JANIS

    JANIS - 2017-08-24

    Hello to all!
    I want to make a thermometer using the DS18B20 digitalo temperature sensor. My code works only in positive values. When the temperature falls below 0, no numerical values appear on the 7 segment display. The second question -
    How can a minus sign be displayed on a 7-segment display, then, when the variable value sign=1 ?

      #chip 16F886,4''876A, 4
    
        #define 7Seg_CommonAnode
    
        #define DISP_SEG_A PORTB.0
        #define DISP_SEG_B PORTB.1
        #define DISP_SEG_C PORTB.2
        #define DISP_SEG_D PORTB.3
        #define DISP_SEG_E PORTB.4
        #define DISP_SEG_F PORTB.5
        #define DISP_SEG_G PORTB.6
        #define DISP_SEG_DOT PORTB.7
    
        #define Disp_Sel_1 PortA.1
        #define Disp_Sel_2 PortA.2
        #define Disp_Sel_3 PortA.3
        dir portb out
        dir porta.1 out
        dir porta.2 out
        dir porta.3 out
    
    #include <DS18B20.h>
    ' DS18B20 port settings
    #define DQ PortC.4
    
    dig =1
    InitTimer0 Osc, PS0_16
    On Interrupt Timer0Overflow Call showdigit
    
     main:
    ReadDigitalTemp
    
    Num3 = DSInt/10
    Num2 = DSInt%10
    
        If RxData.7 = 1 Then
        sign=0
        Else
        sign=1
        end if
    goto main
    
    sub  showdigit
    
        Select Case dig
        Case 1
            DisplayValue 1, sign
        Case 2
            DisplayValue 2, Num3
        Case 3
                 displayvalue 3, Num2      
        Case Else
            dig = 1
        End Select
    
        dig++
        If dig > 3 then dig =1
    
    end sub
    
     
  • Anobium

    Anobium - 2017-08-24

    Do you get negative values on a serial terminal? Use the demos in this folder to show how to send to a serial terminal - \GCB@Syn\GreatCowBasic\Demos\Temperature Sensor Solutions\DS18B20 Sensor Solutions\Sensor to Hardware Serial Terminal

     
  • JANIS

    JANIS - 2017-08-24

    Not. Negative temperature values must be indicated on the same 7-segment display.Now you can not see temperature values below 0 degrees on the 7-segment display. Just when indicate negative values , then in 1 segment indicate ' - ' sign.

     
  • Anobium

    Anobium - 2017-08-24

    You are not getting negative numbers on a Serial terminal? Can you attached your source code?

     
  • JANIS

    JANIS - 2017-08-24

    I have published a code. Do you not see the code , Anobium?

     
  • Anobium

    Anobium - 2017-08-24

    I mean the code that shows the results on a serial terminal. I want to check the results are negative - you may already know the sensor and the results are negative - so, I wanted to check the results on a serial terminal. This is the program I wanted to see.

     
  • JANIS

    JANIS - 2017-08-24

    I do not understand why serial code is needed? I do not have that. :(

     
  • Chris Roper

    Chris Roper - 2017-08-24

    I do not understand why serial code is needed? I do not have that. :(

    I would guess that the Serial code is needed to determine where the error might be.

    If the result displays as Negative on the Serial Terminal, it confirms that the temperature reading is correct and the display output needs debugging.

    Conversely if the terminal is not showing a negative then the fault lays in the sensor reading not the display.

    It is structured debugging, break the system into logical blocks and test each until you narrow down the course of the problem.

    Hope that helps.

    Cheers
    Chris

     
  • Joseph Realmuto

    Joseph Realmuto - 2017-08-24

    For the sign just do this instead:

        Select Case dig
        Case 1
            IF sign = 1 THEN
              Set DISP_SEG_A on
              Set DISP_SEG_B on
              Set DISP_SEG_C on
              Set DISP_SEG_D on
              Set DISP_SEG_E on
              Set DISP_SEG_F on
              Set DISP_SEG_G off
              Set DISP_SEG_DOT on
             END IF
        Case 2
            DisplayValue 2, Num3
        Case 3
            Displayvalue 3, Num2      
        Case Else
            dig = 1
        End Select  
    

    It looks like DSint returns a negative number if the temperature is below zero. That's why nothing displays. You need to convert it back to a positive number:

    DSint = DSint * -1  
    
     

    Last edit: Joseph Realmuto 2017-08-24
  • JANIS

    JANIS - 2017-08-24

    Joseph, Not working your suggestion :(. I tried another day to connect the LCD display and read the values.Then I give a message. I do not know how to do this differently.

     
  • Joseph Realmuto

    Joseph Realmuto - 2017-08-24

    Try this instead:

    DSint = 0 - DSint  
    

    Negative numbers are represented in two's complement plus one format. For example, -1 is really 65535, -2 is 65534, and so forth. When you subtract from zero, you should end up with the correct positive number.

     
  • stan cartwright

    stan cartwright - 2017-08-25

    Try dim var as integer...works for +- 32767.

     
  • JANIS

    JANIS - 2017-08-26

    Hey , Thank you all!
    ! Joseph Realmuto, Yessss DSint = 0 - DSint works!
    But the idea of minus '-' sign is not working. :(

     
  • mmotte

    mmotte - 2017-08-26

    JANIS,
    You are looking for how to display a '-' on a 7 segment display?

    Use:

    'DisplayChar (display, character, dot)
    IF sign = 1 THEN
          DisplayChar (1, 45)   ' 45 is ascii for a minus sign
             END IF
    

    There are two undocumented ascii characters for the 7 segment display, space and minus ( 32 and 450. Otherwise the DisplayChar function must be a letter or number.
    GL
    Mike

     
  • JANIS

    JANIS - 2017-08-26

    Thanks, mmotte! Super working now.
    Then, when the code will fully ready, I'll post. I think that someone might be interested.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.