Morning all, below is the code I use in a little temp measure project and have a question.
The data sheet on the internet talks about bit D2 from the MAX6675 is used to detect if the thermocouple has gone Open as at the moment all my code does is return its max temp of 1024. I could do with monitoring this bit as well as the temp as I already have but can't work out how to go about it. Any help appreciated.
Code:
; Picaxe 08M2 to Max6675 thermocouple
Symbol CS = C.2 ' connect pin6 to pin 6 MAX6675
Symbol SCK = C.1 ' connect pin4 to pin 5 MAX6675
Symbol MISO = PinC.3 ' connect pin5 to pin 7 MAX6675
Symbol CONF = C.4 ' output pin for flame confirmed
Symbol Val = W1
Symbol I = B1
' Directives
#COM 31 'specify serial port
#picaxe 08M2 'specify procesor
#no_data 'reduces download time
#terminal 4800 'specify terminal baud rate
init:
pause 2000
High CONF
Main:
GoSub MeasTemp
GoSub DisplayTemp
GoSub ControlOut
Pause 500 ' allow Max6675 to finish
Goto Main
MeasTemp:
High CS ' deselect the 6675
Low SCK
Low CS ' start conversion
Val = 0 ' initialize temperature variable
For I = 1 to 16 ' serial clock in 16 bits
High SCK
Val = Val * 2 + MISO 'clock in the bits into a word
Low SCK
Next I
High CS ' deselect the 6675
Val = Val / 32 ' use only the 11 most sig bits (val = deg Celsius)
Return
DisplayTemp:
sertxd("Temp=",#val," ",13,10) 'display text
Return
ControlOut:
if val <= 120 then LockOut 'flame not confirmed
if val >= 130 then Confirmed 'flame confirmed
Return
LockOut:
sertxd("Lock_Out"," ",13,10) 'display text
Pause 100 'wait for period
High CONF 'turn on output
Pause 100 'wait for period
Return
Confirmed:
sertxd("Flame_Confirmed", " ",13,10) 'display text
Pause 100 'wait for period
Low CONF 'turn off output
Pause 100 'wait for period
Return
The data sheet on the internet talks about bit D2 from the MAX6675 is used to detect if the thermocouple has gone Open as at the moment all my code does is return its max temp of 1024. I could do with monitoring this bit as well as the temp as I already have but can't work out how to go about it. Any help appreciated.