Menu

DS18B20 data on 7-segment LED display.

Help
JANIS
2017-06-13
2017-06-15
1 2 > >> (Page 1 of 2)
  • JANIS

    JANIS - 2017-06-13

    Hello to all! I fail to temperature data from DS18B20 displayed on the 7-segment LED display. The code is simple. But it does not work. 7-segment display is dark. if deactivates row - DSdata = readtemp, the display starts. Where is the problem?

        #chip 16F876A, 4
                            '' #config osc = int - cannot use, because for this chip only ext osc
    
    'support for Common Cathode
        #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
    
    #include <DS18B20.h>
    
    ' DS18B20 port settings
       #define DQ PortC.4
    
    
     do forever
    
    DSdata = readtemp '' <=============
    
    DisplayValue 1,  DSdata/100
    wait 1 ms
    DisplayValue 2,  DSdata/10 , 1
    wait 1 ms
    DisplayValue 3, DSdata%10
    wait 1 ms
    loop
    
     
  • Anobium

    Anobium - 2017-06-13

    Which release please? Version of the Great Cow BASIC installation please.

     
  • JANIS

    JANIS - 2017-06-13

    SynWrite 6.22.2290

     
    • Anobium

      Anobium - 2017-06-13

      Sorry, what is the date of the Great Cow BASIC compiler? This is will tell you the version and the build date. In the IDE/SynWrite select IDETools/GCB Tools/GCB Compiler Version

       
  • JANIS

    JANIS - 2017-06-13

    Anobium, the answer is correct?

     
    • Anobium

      Anobium - 2017-06-13

      I think not.

      It should be something like 0.96.01a 2017-02-20

       
  • JANIS

    JANIS - 2017-06-13

    0.97.01 2017-02-20

     
  • Anobium

    Anobium - 2017-06-13

    Have a look a the code in the Help, section DisplayValue.

    I have just tried the first code example and that works for your chip.

    As you are multiplexing you may need to add the code

         Repeat 500
                    DisplayValue 1, Num1
                    Wait 1 ms
                    DisplayValue 2, Num2
                    Wait 1 ms
                End Repeat
    
     
  • JANIS

    JANIS - 2017-06-13

    Anobium, I tried the following:

     #chip 16F876A, 4
                            '' #config osc = int - cannot use, because for this chip only ext osc
    
    'support for Common Cathode
        #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
    
    #include <DS18B20.h>
    
    ' DS18B20 port settings
       #define DQ PortC.4
    
    
     do forever
    
    DSdata = readtemp '' <=============
    repeat 500
    
    DisplayValue 1,  DSdata/100
    wait 1 ms
    DisplayValue 2,  DSdata/10 , 1
    wait 1 ms
    DisplayValue 3, DSdata%10
    wait 1 ms
    
    end repeat
    loop
    

    The result is the same :(

     
  • JANIS

    JANIS - 2017-06-13

    I do not know what to do :(, maybe with the GCB is not possible to indicate the temperature on the LED 7-segment display?

     
  • Anobium

    Anobium - 2017-06-13

    Does this work? Let us just confirm the LED displays work. The sensor will work. Let us isolate the LEDs first. Have tried the Help code? I just adapted to your config - please inspect the sample code for pins out etc.

      'This program will count from 0 to 99 on two LED displays
        #chip 16F876A, 4
    
    
      'See 7 Segment Display Overview for alternate ways of defining Ports
        #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 ' Optional DP
    
        #define DISP_SEL_1 PORTA.1
        #define DISP_SEL_2 PORTA.2    
        #define DISP_SEL_3 PORTA.3
    
        Do
            For Counter = 0 To 99
    
                'Get the 2 digits
                Number = Counter
                Num1 = 0
                If Number >= 10 Then
                    Num1 = Number / 10
                    'SysCalcTempX stores remainder after division
                    Number = SysCalcTempX
                End If
                Num2 = Number
    
                'Show the digits
                'Each DisplayValue will erase the other (multiplexing)
                'So they must be called often enough that the flickering
                'cannot be seen.
                Repeat 500
                    DisplayValue 1, Num1
                    Wait 1 ms
                    DisplayValue 2, Num2
                    Wait 1 ms
                End Repeat
            Next
        Loop
    
     
  • JANIS

    JANIS - 2017-06-13

    I checked earlier. I now have checked with your code. LED Display Works!

     
  • Anobium

    Anobium - 2017-06-13

    Now add the sensor - I would do it slower. One piece at a time, the includes, the port etc etc. Slowly, slowly is better than big attempt.

    Good luck.

     
  • JANIS

    JANIS - 2017-06-13

    First I add #include <ds18b20.h>, Its OK, then I add #define DQ PortC.4, Its OK, but when I add
    DSdata = readtemp, then programm stop , and Led display is dark</ds18b20.h>

     
    • Anobium

      Anobium - 2017-06-13

      ohhhh. Change = readtemp to a constant number, like DSdata = 50. This should proove the LEDs are working OK.

      Let us know all is good with this test.

      If this is good. Check the sensor configuration.

       
  • JANIS

    JANIS - 2017-06-13

    This test is good.

     
  • JANIS

    JANIS - 2017-06-13

    How to I can check The sensor config?

     
  • Anobium

    Anobium - 2017-06-13

    Check your config.

     
  • JANIS

    JANIS - 2017-06-13

    Thank Anobium. I forgot I was on a resistor :( Sorry
    But later I still have a lot of questions about this project.

     
  • JANIS

    JANIS - 2017-06-14

    Hallo!! Apologies once again Anobium for my forgetfulness. But my project now have another problem. I use 3 pieces. 7_segmentu displays. Normally, without flashing, shines only the last display. Display 1 and 2 blink with a frequency Which Depend on the repeat cycle time. The display does not blink When the disables ReadDigitalTemp function. :(

        #chip 16F876A, 4
                            '' #config osc = int - cannot use, because for this chip only ext osc
    'support for Common Cathode
        #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
    
     main:
    ReadDigitalTemp
    
    repeat 50
    wait 1 ms
    DisplayValue 1,  DSInt/10
    wait 1 ms
    DisplayValue 2, DSInt%10 , 1
    wait 1 ms
    DisplayChar 3, "C"
    end repeat
    goto main
    
     
  • mmotte

    mmotte - 2017-06-14

    Greetings JANIS,

    If you read the documentation at the head of DS18B20.h file, it says the reading of the value can take up to 750 ms. This long time is why you see a blink.

    I don't have an immediate solution. Try increasing the "repeat 50" to "repeat 500" which will make the display time longer.

    Second I see a "250 ms" wait at the beginning of the include file DS18B20.h read that could be trimmed. You still would see a blink.

    Otherwise we would be talking on creating an interrupt to scan the displays.

    I will think on it. I have to go for now.

    BR
    M

     
  • JANIS

    JANIS - 2017-06-14

    Anobium already said that need "repeat 500"
    . But the display also flashes.

     
  • JANIS

    JANIS - 2017-06-14

    I want this LED display also use for other information indicating. Where data will be received from another microcontroller via USART interface, in 1 byte form. I do not know IF it will be Possible IF now the cycle is Interrupted for reading DC18b20 ..

     
  • JANIS

    JANIS - 2017-06-14

    Display 1 and 2 blinking at intervals for about 3 seconds, the display 3 - OK.

     
  • William Roth

    William Roth - 2017-06-14

    ReadDigitalTemp appears to be a "blocking command". This means that the PIC cannot refresh the display from the time that ReadDigitalTemp is called until the time that it completes. This time could be up to 750ms. You have several options.

    1. Use an analog temperature sensor that provides instant readings
    2. Use a separate microcontroller for the DS18B20 and poll that controller via USART for saved temperature data.
    3. Use a display that does not need constant refreshing
     
1 2 > >> (Page 1 of 2)

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.