Wednesday 15 May 2013

Algebraic Thermistor readings

As part of a larger piece of work to make it easier for users of RepRapPro Marlin to use a Panelolu2 I have implemented RepRapPro's use of maths to convert the raw ADC values from the thermistor inputs into temperature readings.

The maths in question is the B parameter equation which uses the Beta value specified for NTC thermistor to approximate the curve.

I added the following code to temperature.cpp:-

float analog2tempi(int raw, const float& beta, const float& rs, const float& r_inf)
   return = ABS_ZERO + beta/log( (raw*rs/(AD_RANGE - raw))/r_inf );

along with some #ifdef ALGEBRA_TEMP to compile the computational functions and information only if required.

In order to use this, download the latest version of the T3P3 branch of Marlin and make the following changes to Configuration.h

//use RepRapPro Algebraic Temperature calculation rather than
//the tables - still experimental in this version of Marlin.

and define the series resistor and Thermistors specific to your setup:

// Uncomment ONE of the next two lines - the one for the series resistors on your controller (most common is 4700)
#define SERIAL_R 4700
//#define SERIAL_R 10000

// EPCOS B57560G104F (the standard 100K one)
#define E_BETA 4036.0
#define E_NTC 100000.0
#define BED_BETA 4036.0
#define BED_NTC 100000.0

The data sheet for your thermistor will give the Beta value, the E_NTC or B_NTC is the value of the thermistor at 25C which for a "100K" thermistor is 100 000.

Warning: This is only tested with a variable resistor and an EPCOS B57560G104, and the equation used is an approximation - it is not as accurate as a well defined table.

To do: Investigate using a better equation, such as the equation that Nophead describes here which is in the new script in Marlin.

1 comment:

  1. Hi Tony, I've download the T3P3 version to replace the marlin on my prusa i3 with melzi v2.0. At first i put in my old config and everything looks great. Then i try to use the algebraic temp function. The temperature reading and extruder works fine, but the heat bed cannot heat up when i turn it on via Repetier-Host or try to print things, it only work when i run M303 the PID test, in both case it shows no power output to the bed in Repetier-host. Did i set anything wrong?


Comments are now moderated to reduce spam, please excuse the additional time this will entail.

Note: only a member of this blog may post a comment.