Thermocouple Interfacing with PIC18F4550

Thermocouple Interfacing with PIC18F4550


Introduction

Thermocouple consists of two different conductors forming an electrical junction at different temperatures.
Due to thermo effect, thermocouples produce voltage which is dependent on temperature.
Temperature can be found out from this voltage.
ADC output of this voltage can be processed by a microcontroller to give the temperature.
For more information about Thermocouple and how to use it, refer the topic Thermocouple in the sensors and modules section.
For information about ADC in PIC18F4550 and how to use it, refer the topic ADC in PIC18F4550in the PIC Inside section.
Thermocouple
Thermocouple

Interfacing Diagram

 The complete interfacing diagram of the thermocouple is shown in the figure below.

Thermocouple Interfacing with PIC18F4550
Thermocouple Interfacing with PIC18F4550 
AD595:
  • AD595 is a complete instrumentation amplifier (Monolithic Thermocouple Amplifiers) with a Cold Junction Compensation.
  • AD595 is compatible for K-type thermocouple, while AD594 is compatible for the J-type thermocouple.
  • It combines ice point reference with the pre-calibrated amplifier to produce a high-level output (10mV/ºC)directly from the thermocouple output.
  • AD595 gain trimmed to match transfer characteristic of the K-type thermocouple at 25ºC. The output of K-type thermocouple in this temperature range is 40.44uV/ºC.
  • The resulting gain for AD595 is 247.3 (10mV/ºC divided by 40.44uV/ºC).
  • The input offset voltage for AD595 is 11uV, this offset arises because the AD595 is trimmed for a 250 mV output while applying a 25°Cthermocouple input.
  • Output of AD595 is,
AD595\,Output = (Type\,K\,Voltage + 11\mu V)\ast 247.3
  • The IC AD595 pin diagram is shown in the figure below.
AD595 Instrumentation Amplifier Pin Diagram
AD595 Instrumentation Amplifier Pin Diagram

Note: if you connect +5 volt and ground to the AD595 you can measure the temperature 0ºC to +300ºC, for more information refers AD595 datasheet.
Programming steps for Thermocouple
Steps:
  1. Initialize the ADC and LCD.
  2. Take the data from AD595 instrumentation amplifier.
  3. Convert the ADC value into ºC using below formula,
    º C= \frac{(ADC\,value\ast 4.88)-0.0027}{10} ºC
                                                       = (((ADC Value)* 4.88) - 0.0027) / 10
Why 0.0027 subtracted in above formula
AD595 provides output as follows,
AD595 Output = (Type K Voltage + 11 uV) x 247.3
·         The above formula shows AD595 provides output with amplified offset voltage. So, we must eliminate total offset voltage (11 uV * 247.3) to get accurate temperature value.

Note:11 uV is an offset voltage of IC AD-595 instrumentation amplifier for a K-type thermocouple.

         4. Display Temperature on 16x2 LCD.

Program

/*
   Thermocouple Interfacing with PIC18F4550
   http://www.electronicwings.com
 */ 

#include <pic18f4550.h>
#include <string.h>
#include <stdio.h>
#include "LCD_16x2_8-bit_Header_File.h"
#include "PIC18F4550_ADC_Header_File.h"

void main(void)
{
    OSCCON =0x72;
 LCD_Init();               /* initialize LCD16x2 */
 LCD_Clear();              /* clear LCD */
 ADC_Init();               /* initialize ADC */
 char Temperature_buffer[10];
 int Analog_Input;
 float Temperature;
 LCD_String_xy(0, 0, "Temperature");    
    while(1)
 {
  Analog_Input = ADC_Read(0); /* store the analog data on a variable */
  
        /* convert analog voltage into ºC and substract the offset voltage */ 
   Temperature = ((Analog_Input * 4.88)-0.0027)/10.0; 
  
        sprintf(Temperature_buffer,"%d%cC  ",(int)Temperature,0xdf);  /* convert integer to ASCII string */
        LCD_String_xy(1, 2, Temperature_buffer);
  MSdelay(1000); /* wait for 1 second */
 }
}

No comments:

Post a Comment