Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MAX6675 temperature sampling routine. Routine stores sampled values in an array and returns the average.
'-------------------------------------------------------------------------------
' Read temperature
'-------------------------------------------------------------------------------
READ_TEMPERATURE:
'Get a sampling of temperature values and write to temperature array
FOR index = 0 TO BUFFERSIZE - 1
LOW CS
SHIFTIN DAT, CLK, 0,[curTemp\16]
HIGH CS
ARRAY_TEMPS[index] = curTemp>>5
PAUSE 179
NEXT index
curTemp = 0
'Add up all the values in the array
FOR index = 0 TO BUFFERSIZE - 1
curTemp = curTemp + ARRAY_TEMPS[index]
NEXT index
'Take an average of the temperature values
curTemp = curTemp/BUFFERSIZE
RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment