The Free Site   |  vBuddy - make friends, share photos, blogs, have fun   |  Cheap Web Hosting - starting at $5

Temperature Display

This picaxe circuit senses the temperature and sends the data to the postbox picaxe. It also displays the temperature on a dual 7 segment display. The numbers flash one segment then the other every second eg 1 - 7 for 17. This demonstrates use of the HC595 serial to parallel chip. The intention when this was first built was for a fast multiplexed display but the picaxe couldn't multiplex fast enough.

' 7 seg display
' 2nd bit = segment A
' 8th bit = segment G
' 1st bit = discarded
' pin0 high = enable 1st display via 914 reverse diode
' pin1 high = enable 2nd display via 914 reverse diode
' pin2 = latch clock HC595 pin 12 - low to high transition latches the data
' pin3 = serial data out = HC595 pin 14
' pin4 = shift clock = HC595 pin 11 - low to high tranition stores the serial data out
' pin 5 = serial data out
' **** important - low = leds on
' multiplexing is slow - flickers a lot
' Segments are xGFEDCBA in b1

main: GoSub temperature
GoSub SplitDecimal
GoSub SendData
GoTo main

SplitDecimal: ' pass w6
For w4 = 1 To 40 ' send every 2 mins
Let w5 = w6 / 10
Let b0 = w5
GoSub SendToLatch
high 0
pause 1000
let w5=w6//10
Let b0 = w5
GoSub SendToLatch
low 0
high 1
pause 1000
low 1
pause 1000
Next w4

Return

SendToLatch: ' sends data in b0
lookup b0,(%01000000,%01111001,%00100100,%00110000,%00011001,%00010010,%00000010,%01111000,%00000000,%00010000),b1
let pins = %00000000
For b2 = 1 To 8
b3=b1 and %00000001
let b4=b3*%00001000 ' pin 3 of 0-7 = serial data
Let pins = b4 ' output
high 4 ' store the data and shift
low 4
b1 = b1 / 2 ' shift right
Next b2
high 2 ' latch
low 2
Return

temperature: ' 10mv per degree x5 = 50mv per degree. 10 degrees = 1/2 a volt. 255=5V=25 steps per 20 degrees
' 42 = 13.6 degrees
' 90 = 35 degrees roughly
' 12 = 0 degrees
' 2.2 steps per degree
readadc 0, w0
w6 = w0 - 12
w6 = w6 * 10
w6 = w6 / 22 ' divide by 2.2
Return


SendData: Let b3 = w6 ' output byte
Let b2 = 0 ' device no 0
'let b3=15 ' 4 data bytes
Let b4 = 1
Let b5 = 2
Let b6 = 3
Let w6 = b3 ' add up checksum note if reprogram this can do in one line eg let w6=b3+b4+b5+b6
Let w6 = w6 + b4
Let w6 = w6 + b5
Let w6 = w6 + b6
serout 5,N1200,("DataI",b2,b3,b4,b5,b6,b12,b13)
Return


Home