Thermocouple Interfacing with PIC18F4550


A thermocouple consists of two different conductors forming an electrical junction at different temperatures.

Due to the Thermo effect, thermocouples produce a 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 to the topic Thermocouple in the sensors and modules section.

For information about ADC in PIC18F4550 and how to use it, refer to the topic ADC in PIC18F4550 in the PIC Inside section.



Connection Diagram of Thermocouple With PIC18F4550

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

Thermocouple Interfacing with PIC18F4550
Thermocouple Interfacing with PIC18F4550 



  • AD595 is a complete instrumentation amplifier (Monolithic Thermocouple Amplifiers) with a Cold Junction Compensation.
  • AD595 is compatible with K-type thermocouple, while AD594 is compatible with 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 the transfer characteristic of the K-type thermocouple at 25ºC. The output of the 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.
  • The 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 to AD595 datasheet.


Programming steps for Thermocouple


  1. Initialize the ADC and LCD.
  2. Take the data from the AD595 instrumentation amplifier.
  3. Convert the ADC value into ºC using below formula,
C= \frac{(ADC\,value\ast 4.88)-0.0027}{10}

                                                       = (((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 the IC AD-595 instrumentation amplifier for a K-type thermocouple.

         4. Display Temperature on 16x2 LCD.


Thermocouple code for PIC18F4550

   Thermocouple Interfacing with PIC18F4550

#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");    
		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 */



Components Used

K TypeThermocouple Glass Braid Insulated
K TypeThermocouple Glass Braid Insulated
LCD16x2 Display
LCD16x2 Display


PIC18F4550 Thermocouple Project File Download
AD595 Datasheet Download