Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brooksware2000
Created August 7, 2012 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brooksware2000/3280697 to your computer and use it in GitHub Desktop.
Save brooksware2000/3280697 to your computer and use it in GitHub Desktop.
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