Menu

DS18B20 data on 7-segment LED display.

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

    JANIS - 2017-06-14

    Thanks William! I did also think that the need to use a small microcontroller for DS18B20 read and transmit data through USART. But I have one controller available to carry bytes for other information indicating the same microcontroller and 7segm. display via USART. Or one microcontroller could receive data from another microcontroller and read DS18B20, and transmit data to third microcontroller via USART? Controller will be able both to read and to transmit via USART?

     
    • Chris Roper

      Chris Roper - 2017-06-14

      How far apart will they be?
      If they are all on the same board you could put them on an I2C or SPI BUS.

      On 14 June 2017 at 16:49, JANIS kalvitis@users.sf.net wrote:

      Thanks William! I did also think that the need to use a small
      microcontroller for DS18B20 read and transmit data through USART. But I
      have one controller available to carry bytes for other information
      indicating the same microcontroller and 7segm. display via USART. Or one
      microcontroller could receive data from another microcontroller and read
      DS18B20, and transmit data to third microcontroller via USART? Controller
      will be able both to read and to transmit via USART?


      DS18B20 data on 7-segment LED display.
      https://sourceforge.net/p/gcbasic/discussion/579126/thread/fe5ee037/?limit=25&page=1#3f54


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/gcbasic/discussion/579126/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • Anobium

        Anobium - 2017-06-14

        I vote for SPI. Robust and no extra components.

         
  • kent_twt4

    kent_twt4 - 2017-06-14

    I vote for timer interrupt to handle the ds18b20 and display updates, and have the 16f876a handle everything, it is more than capable. Have code (mostly) will travel.

     
  • Anobium

    Anobium - 2017-06-14

    I vote with Kent. He wrote the sensor library!!!!

     
  • mmotte

    mmotte - 2017-06-14

    JANIS,
    Here is multiplexing the 7 seg display with an interrupt.The interrupt executesoften enough to prevent flicker.
    in this case : 4mhz/4/16/256/3
    4 mhz is clockosc
    4 is clock cycle is 1/4 clock osc
    16 is the pre counter 0 divider
    256 is ,it is an 8 bit counter
    3 was the number of digits
    so each digit is lit up for ~ 1/80 of a second

    Each interrupt the next digit is displayed.

    I don't have an 18S20 to test with so I tested on a protoboard and faked the DS with a "wait time" of 750 ms. It was working there. I am not sure if the interrupt will mess up the DS18S20.h sub readings?
    This program is yours adapted with the interrupt parts. I have not tested this program but it should work.

     #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
    
    dig =1
    InitTimer0 Osc, PS0_16
    On Interrupt Timer0Overflow Call showdigit
    
     main:
    ReadDigitalTemp
    
    Num3 = DSInt/10
    Num2 = DSInt%10
    Char1= "C"
    
    '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
    
    sub  showdigit
    
        Select Case dig
    
        Case 1
            DisplayValue 1, Num3
    
        Case 2
            DisplayValue 2, Num2
    
        Case 3
            DisplayChar 3, Char1
    
    
        Case Else
            dig = 1
    
        End Select
        dig++
        If dig > 3 then dig =1
    
    end sub
    

    GL
    M

     
  • kent_twt4

    kent_twt4 - 2017-06-14

    Not running for office, and besides we know that Evan has improved the original library. I have found that tossing out the first reading before main can be a good idea when reading the ds18b20 type devices. So I agree with mmotte that the 250ms delay can be deleted.

    As far as the interrupt ds18b20 driven code, say you have a counter counting to 10 for every 100ms timer interrupt, you can use code like this to toggle between starting a conversion, and reading the scratch pad value a second later.

    LED_ON = 0
    ...
    ...
    Main:
    ...
    ...
    If TenthSec = 10 Then     'tenthsec multiplier or 1 sec intervals
    
      LED_ON = NOT LED_ON  'toggle led flag
         IF LED_ON = True Then
         Set LED1 ON
         'start DS18S20 temp conversion
         MasterRST
         OWout SkipRom
         OWout ConvertT
      Else
         Set LED1 OFF
        'read DS18S20 temp conversion
         MasterRST
         OWout SkipRom
         OWout ReadScratch
         Owin
         LedTemp = HighLow/2
      End If
    
    End If
    
     
  • JANIS

    JANIS - 2017-06-15

    Thank you for all. I am back, and I will test MMottes code :)

     
  • JANIS

    JANIS - 2017-06-15

    Hey! MMOTTE! Your code works!​ Thank you all!
    I will continue the project and I will be probably a lot of confusions ...

     
<< < 1 2 (Page 2 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.