Using PT100 Sensor

Hi everybody, I picked myself up a pt100 sensor from e3d so I could start experimenting in poly carbonate, while also improving the overall accuracy of the temperature.

I found a post (Using PTC (PT1000)) that explained that you needed to change “the ‘t’ formula, to the formula of your temperature sensor”

According to this post I can just open up the thermister.ccp file and edit the parameters and be done, but I cant find what to edit in the file! How can I start using the PT100? There is no documentation or guide for it, however I will probably add one after you guys help me figure it out.

Please help!
Thanks!

Also Here is a copy of my “thermister.cpp” file

/*
      This file is part of Smoothie  The motion control part is heavily based on Grbl       Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
      Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
      You should have received a copy of the GNU General Public License along with Smoothie. If not, see 
*/

#include “libs/Kernel.h”
#include <math.h>
#include “libs/Pin.h”
#include “Config.h”
#include “checksumm.h”
#include “Adc.h”
#include “ConfigValue.h”
#include “libs/Median.h”
#include “Thermistor.h”

// a const list of predefined thermistors
#include “predefined_thermistors.h”

#include “MRI_Hooks.h”

#define UNDEFINED -1

#define thermistor_checksum CHECKSUM(“thermistor”)
#define r0_checksum CHECKSUM(“r0”)
#define t0_checksum CHECKSUM(“t0”)
#define beta_checksum CHECKSUM(“beta”)
#define vadc_checksum CHECKSUM(“vadc”)
#define vcc_checksum CHECKSUM(“vcc”)
#define r1_checksum CHECKSUM(“r1”)
#define r2_checksum CHECKSUM(“r2”)
#define thermistor_pin_checksum CHECKSUM(“thermistor_pin”)

Thermistor::Thermistor()
{
}

Thermistor::~Thermistor()
{
}

// Get configuration from the config file
void Thermistor::UpdateConfig(uint16_t module_checksum, uint16_t name_checksum)
{
// Values are here :
this->r0 = 100000;
this->t0 = 25;
this->beta = 4066;
this->r1 = 0;
this->r2 = 4700;

// load a predefined thermistor name if found
string thermistor = THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, thermistor_checksum)-&gt;as_string();
for (auto i : predefined_thermistors) {
    if(thermistor.compare(i.name) == 0) {
        this-&gt;beta = i.beta;
        this-&gt;r0   = i.r0;
        this-&gt;t0   = i.t0;
        this-&gt;r1   = i.r1;
        this-&gt;r2   = i.r2;
        break;
    }
}

// Preset values are overriden by specified values
this-&gt;r0 = THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, r0_checksum  )-&gt;by_default(this-&gt;r0  )-&gt;as_number(); // Stated resistance eg. 100K
this-&gt;t0 = THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, t0_checksum  )-&gt;by_default(this-&gt;t0  )-&gt;as_number(); // Temperature at stated resistance, eg. 25C
this-&gt;beta = THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, beta_checksum)-&gt;by_default(this-&gt;beta)-&gt;as_number(); // Thermistor beta rating. See 
this-&gt;r1 = THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, r1_checksum  )-&gt;by_default(this-&gt;r1  )-&gt;as_number();
this-&gt;r2 = THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, r2_checksum  )-&gt;by_default(this-&gt;r2  )-&gt;as_number();

// Thermistor math
j = (1.0 / beta);
k = (1.0 / (t0 + 273.15));

// Thermistor pin for ADC readings
this-&gt;thermistor_pin.from_string(THEKERNEL-&gt;config-&gt;value(module_checksum, name_checksum, thermistor_pin_checksum )-&gt;required()-&gt;as_string());
THEKERNEL-&gt;adc-&gt;enable_pin(&amp;thermistor_pin);

}

float Thermistor::get_temperature()
{
return adc_value_to_temperature(new_thermistor_reading());
}

float Thermistor::adc_value_to_temperature(int adc_value)
{
if ((adc_value == 4095) || (adc_value == 0))
return infinityf();
float r = r2 / ((4095.0 / adc_value) - 1.0);
if (r1 > 0)
r = (r1 * r) / (r1 - r);
return (1.0 / (k + (j * log(r / r0)))) - 273.15;
}

int Thermistor::new_thermistor_reading()
{
int last_raw = THEKERNEL->adc->read(&thermistor_pin);
if (queue.size() >= queue.capacity()) {
uint16_t l;
queue.pop_front(l);
}
uint16_t r = last_raw;
queue.push_back(r);
for (int i=0; i<queue.size(); i++)
median_buffer[i] = *queue.get_ref(i);
uint16_t m = median_buffer[quick_median(median_buffer, queue.size())];
return m;
}

Imported from wikidot