3 DSB18B20 to 7 Seg

pilko

Senior Member
Hi All
I am working on a project which reads 3 DSB18B20 temp sensors to a single 7 Seg display, an idea I took from a post by manuka. The code and a timing diagram are attached.
The 7 seg flashes 3-1,s followed by the temp from sensor #1 then the 7 seg flashes 3-2,s followed by the temp from sensor #2 then the 7 seg flashes 3-3,s followed by the temp from sensor #3
The system works fine except I cannot reduce the delay between the 3 flashes and the temp readout as indicated by the “?” on the timing diagram. Not only cannot I reduce the delay, I don’t know why it is there in the first place.
Any explanations would be appreciated.
Thanks pilko
Code:
temp28X:
readtemp 0,b0                                  'DS18B20 # 1 temp reading at 28X input 0
if b0>128 then gosub negtemps                  'Sub zero temps value correction
b1= b0/10		                       'divide orig temp to get tens value
b2= b0//10                                     'divide orig temp so remainder yields units value

for b3 = 1 to 3:pins=%01100000:pause 200:pins=%00000000:pause 200:next b3 ' flash a "1" 3 times		                       'divide orig temp so remainder yields units value

on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine  'tens 
pause 400:pins=%00000000                       'blanks all 7 segs  
pause 400                

on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine   'units
pause 400:pins=%00000000                       'blanks all 7 segs         
pause 600                 

for b3 = 1 to 3:pins=%10110110:pause 200:pins=%00000000:pause 200:next b3 'flash a "2" 3 times

readtemp 1,b0                                  'DS18B20 # 2 temp reading at 28X input 1
if b0>128 then gosub negtemps                  'Sub zero temps value correction
b1= b0/10		                       'divide orig temp to get tens value
b2= b0//10		                       'divide orig temp so remainder yields units value

on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine  'tens
pause 400:pins=%00000000 	           'blanks all 7 segs  
pause 400                

on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine  'units
pause 400:pins=%00000000                   
pause 600     

for b3 = 1 to 3:pins=%10011110:pause 200:pins=%00000000:pause 200:next b3 'flash a "3" 3 times

readtemp 2,b0                                   'DS18B20 # 3 temp reading at 28X input 2
if b0>128 then gosub negtemps                   'Sub zero temps value correction
b1= b0/10		                        'divide orig temp to get tens value
b2= b0//10		                        'divide orig temp so remainder yields units value

on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine  'tens
pause 400:pins=%00000000 	           'blanks all 7 segs  
pause 400                

on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine  'units
pause 400:pins=%00000000                   
pause 600
     
goto temp28X            


 zero: pins=%01111110:return '0 shows
 one:  pins=%01100000:return '1 shows
 two:  pins=%10110110:return '2 shows
 three:pins=%10011110:return '3 shows
 four: pins=%11001100:return '4 shows
 five: pins=%11011010:return '5 shows
 six:  pins=%11111010:return '6 shows
 seven:pins=%00001110:return '7 shows
 eight:pins=%11111110:return '8 shows
 nine: pins=%11001110:return '9 shows

negtemps:'DS18B20 subzero negative temps routine + flashing -ve alert
for b3 = 1 to 2:pins=%10000000:pause 200:pins=%00000000:pause 200:next b3
b0 = b0 - 127:return 'b0 now correctly able to show subzero temps
 

Attachments

westaust55

Moderator
Can you explain your problem a little further.

The line
for b3 = 1 to 3 : pins=%01100000 : pause 200 : pins=%00000000 : pause 200 : next b3 ' flash a "1" 3 times

will give a 200ms delay from the 3rd flashing of the "1"

What duration are you seeing?

The ON b1 GOSUB will have some small timing overhead before the pins are set up with the new value to display.
 

westaust55

Moderator
For your second and third sensors you are displaying the sensor number then reading the DS18B20.

The readtemp command can take up to 750ms (3/4 second)

try this mod:
Code:
temp28X:
readtemp 0,b0                                  'DS18B20 # 1 temp reading at 28X input 0
if b0>128 then gosub negtemps                  'Sub zero temps value correction
b1= b0/10		                       'divide orig temp to get tens value
b2= b0//10                                     'divide orig temp so remainder yields units value

for b3 = 1 to 3:pins=%01100000:pause 200:pins=%00000000:pause 200:next b3 ' flash a "1" 3 times		                       'divide orig temp so remainder yields units value

on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine  'tens 
pause 400:pins=%00000000                       'blanks all 7 segs  
pause 400                

on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine   'units
pause 400:pins=%00000000                       'blanks all 7 segs         
pause 600                 


readtemp 1,b0                                  'DS18B20 # 2 temp reading at 28X input 1
if b0>128 then gosub negtemps                  'Sub zero temps value correction
b1= b0/10		                       'divide orig temp to get tens value
b2= b0//10		                       'divide orig temp so remainder yields units value

for b3 = 1 to 3:pins=%10110110:pause 200:pins=%00000000:pause 200:next b3 'flash a "2" 3 times

on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine  'tens
pause 400:pins=%00000000 	           'blanks all 7 segs  
pause 400                

on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine  'units
pause 400:pins=%00000000                   
pause 600     


readtemp 2,b0                                   'DS18B20 # 3 temp reading at 28X input 2
if b0>128 then gosub negtemps                   'Sub zero temps value correction
b1= b0/10		                        'divide orig temp to get tens value
b2= b0//10		                        'divide orig temp so remainder yields units value

for b3 = 1 to 3:pins=%10011110:pause 200:pins=%00000000:pause 200:next b3 'flash a "3" 3 times

on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine  'tens
pause 400:pins=%00000000 	           'blanks all 7 segs  
pause 400                

on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine  'units
pause 400:pins=%00000000                   
pause 600
     
goto temp28X            


 zero: pins=%01111110:return '0 shows
 one:  pins=%01100000:return '1 shows
 two:  pins=%10110110:return '2 shows
 three:pins=%10011110:return '3 shows
 four: pins=%11001100:return '4 shows
 five: pins=%11011010:return '5 shows
 six:  pins=%11111010:return '6 shows
 seven:pins=%00001110:return '7 shows
 eight:pins=%11111110:return '8 shows
 nine: pins=%11001110:return '9 shows

negtemps:'DS18B20 subzero negative temps routine + flashing -ve alert
for b3 = 1 to 2:pins=%10000000:pause 200:pins=%00000000:pause 200:next b3
b0 = b0 - 127:return 'b0 now correctly able to show subzero temps
 

pilko

Senior Member
Thanks eclectic and westaust for yor help. Have to go out now. Will try your suggestions later.
 

manuka

Senior Member
Glad you've tamed it-I'd not initially considered reading 3 different sensors in this style. Just one DS18B20 to a single 7 segment was considered a tad too minimalist by some! Stan ("Manuka")
 

westaust55

Moderator
Glad you've tamed it-I'd not initially considered reading 3 different sensors in this style. Just one DS18B20 to a single 7 segment was considered a tad too minimalist by some! Stan ("Manuka")
Stan,

It is all a case of what one needs or wants and what expense one is prepared to go to. There are time when minimalistic is sufficient.

Presentation wise, the Rolls Royce will get you to the shops (and make a statenment) to make a purchase, but then so will an ancient mini moke (but maybe a different statement)!
 

tater1337

Member
Glad you've tamed it-I'd not initially considered reading 3 different sensors in this style. Just one DS18B20 to a single 7 segment was considered a tad too minimalist by some! Stan ("Manuka")
heh. I've been toying with just using one LED for display output. I think one 7 segment is smart.

(remembers when 12x2 LCDs were $200 plus)
 
Top