Hi folks,
I am reading 3 temperatures, one differential temperature and an analog signal, using subs bb, cc, dd, ee and ff. Temps. The 5 readings are displayed in sequence on a single 7 seg display. This part of the system works fine although the code is not very elegant.
I then added an interrupt so that by pressing a switch at input 1 from one to five times I could hold the display at bb or cc or dd etc. This is done by counting b8.
The interrupt addition works fine on the simulator but I cannot get past b8 = 1 with the actual device. Any help would be appreciated.
Thanks
pilko
I am reading 3 temperatures, one differential temperature and an analog signal, using subs bb, cc, dd, ee and ff. Temps. The 5 readings are displayed in sequence on a single 7 seg display. This part of the system works fine although the code is not very elegant.
I then added an interrupt so that by pressing a switch at input 1 from one to five times I could hold the display at bb or cc or dd etc. This is done by counting b8.
The interrupt addition works fine on the simulator but I cannot get past b8 = 1 with the actual device. Any help would be appreciated.
Thanks
pilko
Code:
temp28X:
setint %00000010,%00000010
'Differential Temperature = Feed Temperature minus Return Temperature
bb:
setint %00000010,%00000010 'Feed Temperature
readtemp 4,b0 'Return Temperature
readtemp 5,b4
pins=%10111100:pause 200:pins=%00000000:pause 200 ' flash a "d"
if b0>=b4 then let b5=b0-b4 endif
if b0>128 then aa 'Sub zero temps value correction
if b0>128 then let b5=b0-127+b4 endif
if b4>b0 then aa
if b4>b0 then let b6=b0-b4 let b5=256-b6 endif
b1= b5/10 'divide orig temp to get tens value
b2= b5//10 'divide orig temp so remainder yields units value
pause 200
on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine 'tens
pause 300:pins=%00000000 'blanks all 7 segs
pause 300
on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine 'units
pause 300:pins=%00000000 'blanks all 7 segs
if b8=1 then bb
if b8=2 then cc
'Temperature 1
cc:
setint %00000010,%00000010
readtemp 4,b0 'Feed Temperature
pins=%11100010:pause 200:pins=%00000000:pause 200 ' flash a "F"
if b0>128 then 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
pause 200
on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine 'tens
pause 300:pins=%00000000 'blanks all 7 segs
pause 300
on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine 'units
pause 300:pins=%00000000 'blanks all 7 segs
if b8=2 then cc
if b8=3 then dd
'Temperature 2
dd:
setint %00000010,%00000010
readtemp 5,b0 'Return Temperature
pins=%01100110:pause 200:pins=%00000000:pause 200 'flash a "r"
if b0>128 then 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
pause 200
on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine 'tens
pause 300:pins=%00000000 'blanks all 7 segs
pause 300
on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine 'units
pause 300:pins=%00000000
if b8=3 then dd
if b8=4 then ee
'Temperature 3
ee:
setint %00000010,%00000010
readtemp 6,b0 'Outdoor Temperature
pins=%10111000:pause 200:pins=%00000000:pause 200 'flash a "o"
if b0>128 then 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
pause 200
on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine 'tens
pause 300:pins=%00000000 'blanks all 7 segs
pause 300
on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine 'units
pause 300:pins=%00000000
if b8=4 then ee
if b8=5 then ff
'Frost level
ff:
setint %00000010,%00000010
pause 500
readadc 1,b0 'Voltage representing Frost Level
pins=%01110000:pause 200:pins=%00000000:pause 200 'flash a "L"
b1= b0/10 'divide orig reading to get tens value
b2= b0//10 'divide orig reading so remainder yields units value
pause 200
on b1 gosub zero,one,two,three,four,five,six,seven,eight,nine 'tens
pause 300:pins=%00000000 'blanks all 7 segs
pause 300
on b2 gosub zero,one,two,three,four,five,six,seven,eight,nine 'units
pause 300:pins=%00000000
if b8=5 then ff
if b8>5 then let b8=0 endif
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
aa:for b3 = 1 to 2:pins=%10000000:pause 200:pins=%00000000:pause 200:next b3 return
interrupt:
gg: if pin1 = 1 then hh 'Decision command
goto gg
hh: if pin1 = 0 then ii 'Decision command
goto hh
ii: let b8 = b8 + 1 'Inc command
if b8=1 then bb
if b8=2 then cc
if b8=3 then dd
if b8=4 then ee
if b8=5 then ff
if b8>5 then temp28X
setint %00000010,%00000010
return