Welcome! Log In Create A New Profile

Advanced

Marlin 1.1.9 thermocouple(AD8495) Weird calculation?

Posted by guana19 
Marlin 1.1.9 thermocouple(AD8495) Weird calculation?
June 12, 2019 11:37AM
I recently bought a k-type thermocouple for my printer and was trying to use it.
but when i put in on my printer with ad8495 breakout board, it would only measure something like 180C at room temp!
so i searched about it, and came up with this

oringinal marlin code:
((RAW) * 6.6 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET)

modified code:
((((RAW) * 5.0 / 1024.0 / (OVERSAMPLENR) - 1.25) / 0.005 / (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET)

the equation to measure temps with ad8495 is [Temperature = (Vout - 1.25) / 0.005 V ]

and i can't understand where did [(RAW) * 6.6 * 100.0 / 1024.0] came from!

as far as i know, oversamplenr means marlin will measure the temperature 16times and use the average of it.
so RAW input would be something like X16 of analog reading, which would be why we use RAW/OVERSAMPLENR.

since analog input is read as (analog read voltage/5)*1024,

i did this [(RAW) * 5.0 / 1024.0 / (OVERSAMPLENR)] to regain original voltage reading from the breakout board and applied it to ad8495 equation.

And now, i'm getting accurate temperatures.
But am i right about this?
since there are now subtract in the code, will it be ok to use it like that?
why the oringinal code was like that? where did that *6.6 came from?
Sorry, only registered users may post in this forum.

Click here to login