What is an RTD sensor


An SMD 0805 platinum temperature sensor is a precision Resistance Temperature Detector (RTD) that measures temperature by exploiting the predictable change in platinum’s electrical resistance with temperature. Compliant with DIN EN 60751, it offers excellent stability and near-linear response over a wide range (−50 °C to +170 °C), making it ideal for accurate temperature monitoring in compact electronic designs. Its technology ensures high repeatability and reliability, commonly used in industrial, automotive, and consumer electronics applications.


To energize an RTD sensor, you typically use a current source. The constant current flowing through the sensor allows its resistance to be calculated by measuring the voltage drop across it. Then, the temperature of the sensor can be determined by exploiting its almost-linear Temperature/Resistance relationship.


Interfacing the Sensor with Roboteq


Calculating the Sensor's Resistance


The SMD 0805 platinum RTD is nearly linear over its operating range, but not perfectly—its resistance follows the Callendar–Van Dusen equation. For practical purposes, between −50 °C and +170 °C, the curve is close enough to linear that simple conversion works well. To read it with a device, we will use a voltage divider instead of a current source. This approach minimizes hardware requirements by simply adding a pull-up resistor in series with a stable supply voltage. The motor drive’s 5 V output can serve as that supply. The RTD voltage can then be measured through the motor drive’s analog input. As the RTD’s resistance increases with temperature, the voltage across it changes proportionally, enabling temperature calculation.


The formula tha can be used by the drive to calculate the sensor's resistance fom the voltage readings follows: 




Figure 1: Calculating the sensor resistance through analog Input measurement



Calculating the Temperature


The RTD sensor provides a temperature coefficient of resistance (TCR), which indicates how much the sensor’s resistance changes per degree of temperature. This value is expressed in parts per million per Kelvin (ppm/K). For example, a TCR of 3850 ppm/K means the resistance changes by 0.00385 per Kelvin relative to its reference resistance.


By knowing the TCR parameter, the sensors nominal resistance (at 0 °C) and the sensors actual resistance, we can calculate the actual temperature. The calculations follow: 






Figure 2: Calculating temperature from sensor specs and measured resistance



Calculation Example


Below we will calculate the temperature by knowing the sensor's resistance, so we can validate the analog input readings and calculations.




Figure 3: Calculation Example



Calculation Considerations and Limitations


One important consideration is resistor tolerances, which, combined with the slight nonlinearity of the sensor, can result in an error of a few degrees. For best results, use a pull-up resistor with minimal tolerance.


Any constant deviation observed can be compensated by adding this value to the calculations. The Micropasic script that will be used allows setting a threshold for that purpose. An easy way to verify the accuracy of the calculations is to test the sensor in a fixed-temperature source, such as boiling water or ice.



MicroBasic Implementation


A MicroBasic script can be used to read the analog input and calculate the motor temperature. 


The script can be parametrized as follows:


ParameterDescription
PULLUPPull-up resistor resistance in Ohms
R0
Sensor Resistance at 0°C
TCR
The sensor PPM/K (points per million per Kelvin)
V_SUPPLY
The voltage supplied to the divider, in mV
INPUT_1
The analog input that sensor 1 is connected. MUST be set to 0 if a sensor is not used on that channel otherwise an error will be triggered. 
INPUT_2

The analog input that sensor 2 is connected. MUST be set to 0 if a sensor is not used on that channel otherwise an error will be triggered. 
VAR_1 
The user VAR to store temperature 1
VAR_2
The user VAR to store temperature2
LOOP_TIME
The script period in ms. MUST NOT be zero. 
OFFSETA temperature offset that can be used to correct the present of a constant error in the calculations. Offset value can also be set to 273, to convert the Celsius to Kelvin. 


The script example follows:


'________________Pt1000 RTD Temperature Sensor via Analog input________________

 

'DISCLAIMER

 

'Script is provided only as an example. It has not been extensively tested and user must validate and use it at their own risk. 

 

' DESCRIPTION: 

 

' Script reads an analog input voltage, calculates the RTD sensor resistance and then temperature, using the RTD sensor Specs.

' The calculated temperature is stored to a user VAR. Sensor specs are configurable by the user. RTD sensor requires a pullup

' for its operation. Preferably, choose a pullup with a value equal to the sensor's resistance in the midpoint of the temperature range.

 

option explicit

 

' ------------ PARAMETRIZE THE SCRIPT BELOW: 

 

'Sensor Specs

 

#define PULLUP 1000 'Set here the pullup resistor value in Ohm.

#define R0 1000 ' Pt1000 nominal resistance at 0°C

 

' -> Below is defined the sensor TCR value, measured in PPM/K (points per million per Kelvin). 

' (!) This value indicates the resistance increase per million of its nominal value per degree of Kelvin. 

 

#define TCR 3850 'The sensor PPM/K (points per million per Kelvin). 

#define V_SUPPLY 5000 'The voltage supplied to the voltage divider in mV. Use 5000 for 5 V.

#define OFFSET_1 'Use this value to compensate for a constant error in the calculations sensor 1 or convert Celsiud to Kelvin (+273)

#define OFFSET_2 'Use this value to compensate for a constant error in the calculations sensor 2 or convert Celsiud to Kelvin (+273)

 

 

#define INPUT_1 'The analog input to use for the temperature measurement of motor 1. Use 0 to disable

#define INPUT_2 'The analog input to use for the temperature measurement of motor 2. Use 0 to disable

#define VAR_1 'The user Var to store temperature 1

#define VAR_2 'The user Var to store temperature 2

 

#define LOOP_TIME 1' The temperature update rate - as well as the script refresh period - in milli seconds.

 

' ----------- FUNCTION STARTS HERE. DO NOT MODIFY

 

' Variable declarations

 

dim V_RTD_1 as integer 'The voltage accross the sensor 1, measured by first analog input

dim V_RTD_2 as integer 'The voltage accross the sensor 2, measured by second analog input

 

dim R_RTD_1 as integer 'The calculated resistance of sensor 1

dim R_RTD_2 as integer 'The calculated resistance of sensor 2

 

dim temp1 as integer ' Calculated temperature of motor 1

dim temp2 as integer ' Calculated temperature of motor 1

 

'Variables initialization

 

V_RTD_1 0

V_RTD_2 0

R_RTD_1 0

R_RTD_2 0

temp1 0

temp2 0

 

if (PULLUP 0or (R0 0or (TCR 0or (V_SUPPLY 0or (VAR_1 0or (VAR_2 0or (LOOP_TIME 0'Check invalid values that can result also in script crash.

 

    print("Improper configuration. Program will terminate \n")

    terminate

 

end if

 

top:

 

if (INPUT_1 <> 0'If Analog input 1 is used

 

    V_RTD_1 GetValue(_AI,INPUT_1)     ' Read Analog input 1 voltage in mV

 

    if (V_SUPPLY V_RTD_1'Check correct values and also avoid dividing by zero. 

    

        print("Posible connection error. Analog input voltage equals the supply voltage. Ensure correct connections. Program will terminate\n")

        terminate

        

    elseif (V_RTD_1 50)

    

        print("Posible connection error. Analog input voltage equals zero. Ensure correct connections. Program will terminate\n")

        terminate        

        

    else

    

         R_RTD_1 = ((PULLUP V_RTD_1) / (V_SUPPLY V_RTD_1)) ' Compute RTD resistance. 

        ' Compute temperature (linear approx) in °C.      

        temp1 = OFFSET_1 + ((R_RTD_1 R0) * 10000) / (R0*TCR/100)   'Divide by 1 million to convert PPM/K to P/K.     1000000 broke to 10000/(a)/100 to avoid integer overflow.   

        SetCommand(_VARVAR_1temp1)  ' Output temperature i expressed in degrees x 10 (meaning that 11.1 degrees of Celsius is reported as 111. 

        print ("Resistance 1: "R_RTD_1,"\tTemperature 1: ",temp1)

    

    end if

 

end if

 

 

if (INPUT_2 <> 0'If Analog input 2 is used

 

    V_RTD_2 GetValue(_AI,INPUT_2)     ' Read Analog input 2 voltage in mV

    

    

    if (V_SUPPLY V_RTD_2'Check correct values and also avoid dividing by zero. 

    

        print("Posible connection error. Analog input voltage equals the supply voltage. Ensure correct connections. Program will terminate\n")

        terminate

        

    elseif V_RTD_2 50)

    

        print("Posible connection error. Analog input voltage equals zero. Ensure correct connections. Program will terminate\n")

        terminate        

        

    else

    

         R_RTD_2 = ((PULLUP V_RTD_2) / (V_SUPPLY V_RTD_2)) ' Compute RTD resistance. 

        ' Compute temperature (linear approx) in °C.      

        temp2 = OFFSET_2  ((R_RTD_2 R0) * 10000) / (R0*TCR/100)       'Divide by 1 million to convert PPM/K to P/K.     1000000 broke to 10000/(a)/100 to avoid integer overflow.   

        SetCommand(_VARVAR_2temp2)  ' Output temperature i expressed in degrees x 10 (meaning that 11.1 degrees of Celsius is reported as 111. 

        print ("Resistance 2: "R_RTD_2,"\tTemperature 2: ",temp2)

    

    end if

    

end if

 

    Wait(LOOP_TIME'The Loop 

    print("\n")

    

goto top