Reading a MAX 31855
eagletalontim
Posts: 1,399
in Propeller 1
Going to need a bit of help on this one. I am working with the M31855K and am trying to write a SPIN function to read the temperature of the type K sensor. I have found the Github example, but it appears to only work with Prop 2? New to that area... The Github example seems to be missing several things and I can't seem to get it to run. So... I am wanting to just write my own function in the Prop Tool.
After looking at the Data Sheet, I am a bit confused. It looks like I need to pull CS low, then begin pulsing SCK to receiving in data on SO. There are 32 bits that would need to be read, filled into an array, and then the first 14 bits would be the temperature? Not sure I understand how to convert those 14 bits to a human readable temperature. Any help is greatly appreciated!
After looking at the Data Sheet, I am a bit confused. It looks like I need to pull CS low, then begin pulsing SCK to receiving in data on SO. There are 32 bits that would need to be read, filled into an array, and then the first 14 bits would be the temperature? Not sure I understand how to convert those 14 bits to a human readable temperature. Any help is greatly appreciated!
Comments
The first being the Cold Junction and the TC junction are way apart (+/- 10ºF). Is there a way to programmatically tune to the correct temperature? It seems the code returns a temperature reading in Celsius where I would need Fahrenheit for this application.
Second, since the code conversion from C to F is starting from a whole number, it skips degrees when converting to F which can be an issue since this will be used in a tempering oven and the temperature needs to hold very steady for well over an hour. A swing of +/- 10 degrees F can result in a failure.
I tried to get these to work, but it kept returning 0ºC which made me think either I have the pins set wrong or the PU resistor is not right?
Remember that your values are 100x the actual temperature: 23.5 degrees C will be 2350 using fixed-point math.
Are you twisting the cables?
Massimo
I'd say check the pin assignment. I just tested it again and it works fine with a pull-up on SCK of up to 1.3M, only fails at 1.5M. The SparkFun board doesn't look like it should be causing any oddities, just has a 10K pullup on CS and filtering on the thermocouple inputs.
I agree entirely with Jon; I've dabbled a little with floating points and decided it didn't offer enough benefit over integer math.
Try this for a comparison: Do you need those thousandths of degrees?
When I'm using the sparkfun board I don't use CS pullup's.
That worked perfectly Since I plan on making several of these for some of our local blacksmiths and one for myself, using Fahrenheit is the easiest to read for us.
So... the other issue I am running into is the calibration. For testing purposes, I am using a thermocouple that came with my Southwire meter which is a K type. I am using ambient room temperature for a general temperature. The room temperature is at 74, but the average readings are ranging from 59 to 63 on the TC reading. If I apply any heat at the IC itself, the reading skyrockets which I don't think that is supposed to happen since I am reading the TC instead of CJ, but I could be wrong.
I will be ordering the K Type thermocouple wire from a quality source and TIG welding the wire together for the final builds.
That is a difficult situation for thermocouple instrumentation. Avoid all gradients of temperature across the circuit board from the MA31855 to the point where the thermocouples attach. Avoid thermal gradients across the chip itself. It is gradients that matter, not so much the increase in temperature per se, so do all you can to isolate the board from the source of heat, so that its temperature will be uniform. Attach the thermocouple itself or the connector K extensions as close as possible to the MAX; even to the point of soldering the thermocouple wires directly to MAX pins.
Like Heater used to say: If you think you need floating point, chances are you don't understand the problem.
I don't want to put words in eagletalontim's mouth but I've observed the same thing when converting from whole number C degrees to whole number F degrees. The process loses resolution because a Celsius degree is only 5/9ths of a Fahrenheit degree. So you see the Fahrenheit temperature skipping certain numbers even though the rise or fall of temperature is monotonic.
To cure that, I round off by adding half a degree on the last conversion step (... + 32_50) and then truncating (/100).
As for why I'm using Fahrenheit (seems like it needs justification these days), it's because I've been firing and baking for 60 years and have a sense for F that I will never have for C. Conversely, C is all I've ever used for chemistry and physics, so F in a scientific context is awkward and objectional. ¯_(ツ)_/¯