Traumflug / Teacup_Firmware

Firmware for RepRap and other 3D printers
http://forums.reprap.org/read.php?147
GNU General Public License v2.0
312 stars 199 forks source link

Support fot PT100 sensor #334

Closed ahmetonat closed 1 year ago

ahmetonat commented 1 year ago

In my quest to install Teacup firmware into an Atmega 328 so that I can resurrect an old Tiertime UP-Mini, I stumbled into another important problem. The Up Mini uses a thermocouple of type PT100. Sure, no problem; Teacup does have a PT100 in the temperature sensors section. But wait; why does Repetier host show 1835degC when I select it?

Diving into the code searching for the term PT100: temp.c: #ifdef TEMP_PT100 temp.c: case TT_PT100: temp.c: #warning TODO: PT100 code

Oh well...

So my question is, I am willing to vounteer for the PT100 code support. Can anyone give me any hint on :

Ahmet Onat

Traumflug commented 1 year ago

Well, I can't really help you, as it's too far back since I looked into this code. My little machine simply works and works, no need to touch anything.

Regarding PT100 I vaguely remember that a first step would be to try to use the existing calibration system for this type of sensor as well. Thermistors and Thermocouples are different technology, but behave similarly, just in a vastly different parameter range.

triffid commented 1 year ago

As far as I'm aware, PT100 is a type of thermistor, not thermocouple.

On Wed, 7 Jun 2023 at 14:41, Traumflug @.***> wrote:

Well, I can't really help you, as it's too far back since I looked into this code. My little machine simply works and works, no need to touch anything.

Regarding PT100 I vaguely remember that a first step would be to try to use the existing calibration system for this type of sensor as well. Thermistors and Thermocouples are different technology, but behave similarly, just in a vastly different parameter range.

— Reply to this email directly, view it on GitHub https://github.com/Traumflug/Teacup_Firmware/issues/334#issuecomment-1580969071, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABICGX5S2O2WSZFDTVYFKTXKCHJPANCNFSM6AAAAAAY52UQ7E . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ahmetonat commented 1 year ago

The sensor in the Up Mini has a linear characteristic. After some attempts at creating tables with linear characteristics (I modified configtool/thermistortablefile.h and added a new function which creates a new table for linear sensor under the "thermistor" group just to test the idea), the sensor still did not run report the correct temperatures. I had no other physical sensor to read the correct head temperature so it was not possible to do any sort of meaningful calibration.

Eventually I wrote a simple Arduino code that would do the following:

By pushing PLA through the nozzle, it was seen that it melts nicely at around ADC=325, which corresponds to about 160 degC. Also at room temp (25 deg C), the sensor reads 50. By using these two data points and since the sensor has a linear characteristic, the math is then quite simple, the ADC reading must be divided in half to get the temp value. (Since Teacup uses 4T, actually ADC value must be multiplied* by 2.)

I simply went into temp.c and modified static uint16_t temp_table_lookup(uint16_t temp, uint8_t sensor) function so that it simply returns the analog read value multiplied by 2 as the current temperature.

This works quite nicely.

At first I wanted to add a new selection to the temperature sensor window of the GUI and make the necessary additions, but the code is quite difficult to modify around those parts and the simple hack described above worked nicely. Sorry for machetteing my way through the code and not doing a nice addition but since this printer hardware is essentially obsolete for many years now, I assume there is not much interest. If someone needs, I can try to implement a proper modification which can then be pulled in.