RTD PT100 temperature sensor using Microcontroller - TricksMenu

Post Top Ad

Thursday, 16 March 2017

RTD PT100 temperature sensor using Microcontroller

PT-100 is a thermocouple which means it changes its resistance with temperature. However microcontroller cannot measure resistance directly. Its analogue pins can only measure voltage. For this reason PT-100 cannot directly be interfaced with microcontroller. It will require some external circuitry to convert resistance into voltage to interface RTD PT100 with microcontroller.
RTD transmitter circuit (external circuitry) must be able to sense variation in PT100 resistance due to change in 1 ᵒC and must have the facility to amplify it so that it can be read by microcontroller.
The detailed requirement, design and explanation can be found in article 3 wire RTD temperature transmitter circuit 
RTD PT100 temperature sensor connection diagram
Now questions arise, why bridge circuit is used? Why 100Ω resistors are selected? Why instrumentation amplifier with above stated resistors values is selected? What are the advantages of above arrangement?
All answers to above questions is explained in my article 3 wire RTD temperature transmitter circuit.

Connection diagram for RTD PT100 temperature sensor using microcontroller

Following figure shows the connection diagram for temperature sensor PT100 using microcontroller. PT100 is connected in bridge circuit whose output is amplified by instrumentation amplifier. Using the resistors RV5 and RV6 of instrumentation amplifier, the gain is set at almost 10. Consider the following equation for.
Gain=\left(1+\ \frac{2RV5}{RV6}\ \right)\ \frac{R9}{R8}
Since the resistance of PT100 is 100Ω at 0 ᵒC, so by selecting the other resistors of bridge circuit of 100Ω value, 0ᵒC is set as reference point. It is because the output  VAB at this temperature will be zero. The detailed explanation of  reference value selection is also explained in 3 wire RTD temperature transmitter circuit article.
RTD PT100 temperature sensor using microcontroller connection diagram
The amplified Voltage VAB is given to the analogue pin of microcontroller. The microcontroller after necessary calculation displays temperature on LCD. The necessary calculations are explained in next portion.
LCD is interfaced with port C of microcontroller. To understand LCD interfcing click interfacing LCD with microcontroller.

How to find temperature from the voltage measured by Microcontroller

NOTE: For this article range of temperature to be measured is 0 ᵒ to 100 ᵒC.

Classical method

In this method, resistance is first determined from the measured voltage and temperature is then calculated.
Let us say the voltage V0 is measured by the microcontroller. Say V0 = 2V.
Now this is the voltage after multiplying gain “G” of amplifier. In our case gain G =10.
Now to get the actual voltage VAB between point A and B
V_{AB}=\ \frac{V_o}{G}=\ \frac{2}{10}=0.2   …………………………………..1
This is the voltage between point A and B. From this value we can find the voltage drop across PT-100.
One leg of bridge rectifier has both resistors of 100Ω (R1 and R3). So voltage drop across each is 2.5V because input voltage is 5V and it is equally divided between two. It means voltage at point B is always 2.5V.
So voltage across R3 is 2.5V and voltage drop across PT100 should be 2.5+VAB = 2.5+ 0.2 = 2.7V.
So voltage drop across PT100  VPT100 = 2.7V
So now using voltage divider circuit, resistance of PT100 can be found
V_{PT100}=\ \ V_{in}\left(\ \ \frac{R_{PT100}}{R_{PT100}+R2}\ \right)   …………………………….2
By solving above equation
R_{PT100}=\left\{\frac{\left(\frac{V_{PT100}}{V_{in}}\right)R_2}{1-\ \left(\frac{V_{PT100}}{V_{in}}\right)\ }\right\}   ………………………..3
In our case Vin = 5V, R2= 100Ω, VPT100 = 2.7V ( method shown)
By finding the resistance, we can find the temperature by using temperature coefficient of resistance method.
R_{P??100}=\ R_{ref}\ (1-a(T-T_{ref})  …………………4
Since our reference point is TRef is  0ᵒC at which resistance of PT100 is Rref  is 100 Ω.
Rewriting above equation
T=\left\{\ \frac{\left(1-\ \frac{R_{PT100}}{R_{ref}}\right)}{a}\ \right\} ………………………..5
Where RPT100 is found from equation 3, Rref  = 100 Ω, α= temperature coefficient of resistance and its value can be determined from its datasheet which is 0.00385.
NOTE: The above method is long and contain too many calculations. Also the temperature cofficient of resistance α is not constant and varies with temperature. Therefore in next section we will discuss alternate method.

Direct method

In this method, a direct relation can be determined between the output voltage and temperature. The line equation is used and modified according to requirement. General line equation is
y\ =mx+C
Where m = slope, C= y intercept and y = independent quantity x= dependent quantity.
To find the relation between voltage and temperature, output voltage for various values of temperature is found from the transmitter circuit and given in the table.
Temperature TBridge output    VAB    (mv)V output of instrumentation amplifier ( V AB x 10) VoltsIncrease in voltage per degree rise in temperature ( VAB / T) (volts/ ᵒC)
Slope (m)
000N/A
524240.0048
1047.4480.0047
1570.4720.0046
2092.5950.0046
251151170.0046
301371390.0045
351581610.0045
401791820.0044
451992030.0044
502192230.0043
552392430.0043
602582630.0043
652772820.0042
702953010.0042
753143200.0041
803313380.0041
853503570.0041
903673740.0040
953843910.0040
1004004090.0040
Since at 0ᵒC, VAB = 0. So put Y intercept C=0 in line equation
So equations becomes
T=\ \frac{V_{AB\ }(in\ volts)}{m}
It can be seen from the table that value of m (slope) varies with temperature so a single value cannot be used. For each 10 ᵒC range, separate value of m is used. This is simplest form of linearization. Other techniques of linearization can also be used.
This article uses the direct relationship between temperature and voltage to construct microcontroller based temperature sensor using PT100.

Simulation and result for microcontroller temperature sensor using RTD PT100

Above circuit is simulated in ISIS Proteus and results are shown below. RTD temperature sensor using microcontroller is checked for different values of temperature and results are accurate with maximum error up to 0.5 ᵒC.
 RTD PT100 temperature sensor results and simulation

Program for RTD PT100 temperature sensor using microcontroller

The code is written and complied in MIKRO C.
long double inputread, voltage1, voltageAB, resistance, resistance2, temperature1, temperature2;
// Lcd module connections start
sbit LCD_RS at LATC3_bit;
sbit LCD_EN at LATC2_bit;
sbit LCD_D4 at LATC4_bit;
sbit LCD_D5 at LATC5_bit;
sbit LCD_D6 at LATC6_bit;
sbit LCD_D7 at LATC7_bit;
sbit LCD_RS_Direction at TRISC3_bit;
sbit LCD_EN_Direction at TRISC2_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// Lcd module connections ends
// copy above statments into your code for every project involving LCD
char txt[4];// declare a char array
void main(){
  TRISA=0XFF;// PORTA is input
  TRISC=0X00;// PORTC is Output
  TRISD=0X00;// PORTD is Output
  ADC_Init();// Initialize ADC
  Lcd_Init();// Initialize Lcd
  Lcd_Cmd(_LCD_CLEAR);// Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);// Cursor off
  Lcd_Out(1,1,”Welcome to”);// dsiaplay the welcome logo on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(2,1,”help2educate”);
  delay_ms(3000);// keep displaying logo for 5s
  Lcd_Cmd(_LCD_CLEAR);// Clear display
  Lcd_Out(1,1,”Please wait”);// dsiaplay the welcome logo on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(2,1,”loading…..”);
  delay_ms(6000);
  while(1){
  inputread = ADC_Read(0);// Read analog value from channel 0
  delay_ms(4000);
  Lcd_Cmd(_LCD_CLEAR);// Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);// Cursor off
  voltage1=(inputread*4.88)/1000;//
  voltageAB=voltage1/10;// diving voltage by gain 10 to get acutal VAB voltage
   if(voltageAB<0.048)//for temperature 0-10 deg C
  {  temperature2=voltageAB/0.0048;  }//  value of slope m at 5 deg C is used
  if(voltageAB>=0.048 && voltageAB<0.095)//for temperature 10-20 deg C
  {  temperature2=voltageAB/0.00469;  }//  value of slope m at 15 deg C is used
  if(voltageAB>=0.095 && voltageAB< 0.139)//for temperature 20-30 deg C
  {   temperature2=voltageAB/0.0046;  }//  value of slope m at 25 deg C is used
  if(voltageAB>=0.139 && voltageAB< 0.182)//for temperature 30-40 deg C
  {   temperature2=voltageAB/0.00451;  }//  value of slope m at 35 deg C is used
  if(voltageAB>=0.182 && voltageAB< 0.223)//for temperature 40-50 deg C
  {  temperature2=voltageAB/0.00442;  }//  value of slope m at 45 deg C is used
  if(voltageAB>=0.223 && voltageAB< 0.263)//for temperature 50-60 deg C
  {  temperature2=voltageAB/0.00434;  }//  value of slope m at 55 deg C is used
    if(voltageAB>=0.263 && voltageAB< 0.301)//for temperature 60-70 deg C
  {  temperature2=voltageAB/0.00426;  }//  value of slope m at 65 deg C is used
 if(voltageAB>=0.301 && voltageAB< 0.338)//for temperature 70-80 deg C
  {  temperature2=voltageAB/0.00418;  }//  value of slope m at 75 deg C is used
  if(voltageAB>=0.338 && voltageAB< 0.374)//for temperature 80-90 deg C
  {  temperature2=voltageAB/0.00411;  }//  value of slope m at 85 deg C is used
  if(voltageAB>=0.374)//for temperature 90-100 deg C
  {   temperature2=voltageAB/0.00402;  }//  value of slope m at 95 deg C is used
    floatToStr(temperature2, txt);//convert float variable value to characters to be displayed on the LCD
  delay_ms(5);
  lcd_out(1,1,txt);// dsiaplay the input voltage value stored in character text on the LCD screen at position ROW=1 COLUMN=1
  Lcd_Out(1,10,”deg C”);// dsiaplay the character input volts on the LCD screen at position ROW=1 COLUMN=5
  delay_ms(1000);// wait 2s before taking next value
}}
If you have any questions you can ask in comments. You can also share your ideas and suggest any improvments in above article.

No comments:

Post a Comment

Post Top Ad