Understanding temperature code
I am modifying my firmware with an extra temperature reading to be used for a temperature compensation later.
Currently I have managed to modify configuration.h so extruder 2 has a thermistor input defined (and a fudge fix in repetier.h so it would actually add it in the array, despite numextruders being unchanged). I have further modified the M105 command so "M105 P2" will report the raw value of that thermistor as stored in osAnalogInputValues. So far so good. The rest of the code still works. (I also ended up fixing some errors in pins.h for my megatroincs v3 board)
I am currently stuck trying to get the thermistor raw->degreeC conversion extracted from extruder.cpp so I can do the same for my M105 P2 output. I am hoping for a hint here, ;;) please ?
(I think a feature request is some other internal structure to define "arbitrary" temperature inputs - which could be used for thermal shutdown, expansion compensation or whatever. The current temperature inputs are tightly tied to regulating heaters. Another day and post)
Currently I have managed to modify configuration.h so extruder 2 has a thermistor input defined (and a fudge fix in repetier.h so it would actually add it in the array, despite numextruders being unchanged). I have further modified the M105 command so "M105 P2" will report the raw value of that thermistor as stored in osAnalogInputValues. So far so good. The rest of the code still works. (I also ended up fixing some errors in pins.h for my megatroincs v3 board)
I am currently stuck trying to get the thermistor raw->degreeC conversion extracted from extruder.cpp so I can do the same for my M105 P2 output. I am hoping for a hint here, ;;) please ?
(I think a feature request is some other internal structure to define "arbitrary" temperature inputs - which could be used for thermal shutdown, expansion compensation or whatever. The current temperature inputs are tightly tied to regulating heaters. Another day and post)
Comments
More help, please ;;)
Yes, I understood the function of the ISR,
Module extruder.cpp, class TemperatureController, method updateCurrentTemperature() seems where the temperature gets converted. Lets assume I have a "sensortype"=1. There are two switch statements (with lots of old leftover types?). The first one at "case 99" I have copied the code to do the same for my thermistor value (remember, I have only defined the sensor, it is not part of an extruder, and thus will not be touched by any extruder-code) and it gives me a printable raw value.
the 2nd switch at case 12 does what I see as a linear interpolation(?) of values in what "temptables_num" points to, where the sensortype has selected the table followed by another bit compensation.
Somehow these structure is used for the bedthermistor, too. At the Extruder::getHeatedBedTemperature it is output, but how/when could I add my thermistor to this? I can see the clue around line 1300 i extruder.cpp with the #define NUM_TEMPERATURE_LOOPS .... but feel most uncertain on the consequences of adding 1 to it, and where code would transfer osAnalogInputValues[my index] to the structure. ...
we can take this discussion offline/pm/mail if you want to.