In most of the manufacturing industries like chemical, petrochemical, food processing, pharmaceutical etc temperature is one of the main parameter to be control. Because in these kind of industries some product need the required temperature to be maintained at highest priority otherwise the product will fail (in case of preparing any medicine in pharmaceutical company the temperature pays vital role. If it is not maintained then medicine may become poison.). So the temperature controller is most widely used in almost all the industries.
It’s basically close loop control system. It may be simply ON-OFF type or continuous type system.
ON-OFF type: –
It continuously senses temperature, displays it, compares it with set value. If its greater, then it switch off heating element and if its very less, then switch on heating element.
Continuous type:-
It continuously senses temperature, displays it, compares it with set value. If its greater / less, then control the heat produce by heating element by changing its supplied current.
Here I have given an example of ON-OFF type close loop control system. Here the set value can be externally set by user for the temperature. Then the actual temperature is sensed by sensor, indicated on display with set value. If it exceeds set value then the heater is turned OFF. After then when temp falls bellow the specified limit again heater is turned ON. Also if there is failure in turning ON / OFF heater there is an alarm system. If the turning off heater failed and temperature goes on increasing then immediately the cooler/fan/AC is turned on and alarm sounds.
The figure given in circuit diagram tab shows actual schematic diagram of the temperature control system.
The major components are micro controller 89C51, ADC 0848 and LCD. Other required components are temperature sensor LM35, relay driver chip ULN2003A and C/O relays.
Connections: –
o/p of temperature sensor is connected with channel 1 i/p of ADC. Slider of 10K pot is connected as i/p to channel 2. The data bus (DB0-DB7) is connected with port P1. Control pins RD, WR, CS & INTR of ADC are connected with port P3 pins as shown. The data pins of LCD are connected with port P0 and control pins R/W, RS & EN are connected with port P2 pins as shown in figure. Pins P2.0 & P2.1 drives two relays through ULN chip one two switch on/off cooler and other to switch on/off heater.
Operation: –
Complete operation depends upon the software loaded in 89C51.
1) Controller selects 2nd channel and receives data on P1 through ADC
2) It displays this data on LCD as set value of temperature or reference temperature
3) After 2 to 3 seconds, controller selects 1st channel and get the data on P1 and display it on LCD as current temperature
4) Then it compares current temperature with set or reference temperature
5) If current temperature is lower, then heater is ON but if its higher then heater is turned off and cooler is turned on.
6) Now after every 2 / 3 sec of time controller takes the input from 1st channel, display it on LCD and compare it with set value and based on that either switch on cooler or heater
Software and logic: –
The software loaded in 89C51 has to handle ADC, LCD and also has to switch ON / OFF cooler or heater depending upon set and current temperature value. To handle the ADC
A) First we have to apply active low signal to CS and WR signal and then latch the desired address of channel on MA0 to MA4 through P1
B) Then we have to wait for INTR signal to be low. When it is low it means that conversion is over.
C) When INTR becomes we have to apply CS and RD signal to read digital data from ADC on port P1
To handle the LCD
- The digital equivalent o/p that is received on P1 from ADC is in HEX format and to display it on LCD we have to convert it in ASCII
- So we shall separate lower nibble and upper nibble of received data byte. Convert them in to ASCII and then display them on LCD screen
Complete software is written in embedded C language and compiled using microvision Keil (IDE).
Project Source Code
###
#include<reg51.h> //include file for 8051 registers
#include <string.h>
sbit en = P2^7; // define en, rs & rw pins for LCD
sbit rs = P2^5;
sbit rw = P2^6;
sbit b = P0^7; // define b as busy flag
sbit cs = P3^0; // define cs, wr, rd & intr as pins for
sbit wr = P3^1; // ADC
sbit rd = P3^2;
sbit intr = P3^3;
sbit heater = P2^0; // define P2.0 & P2.1 as pins to on/off
sbit cooler = P2^1; // heater and cooler
unsigned char data1,data2;
int c=0; // initialize counter
void writecmd(unsigned char a); //function that writes command on LCD
void writedat(unsigned char b); // function that sends data to LCD
void busy(void); // function to check LCD busy
void writestr(unsigned char *s); // function that writes string on LCD
void delay(void); // to generate delay
void display(unsigned char z); //converts hex in to ASCII and display it
void timr1(void) interrupt 3 //timer 1 overflow interrupt subroutine
{
c++; // increase count when interrupt occur
ET1=0;
TH1 = 0x3C; // load same value again in T1
TL1 = 0xAF;
if(c==50) //if count is 50 means 50×50ms=2.5 sec
{
c=0; // set counter again to 0
EA = 0; // disable all interrupts
writecmd(0xC0); // go to next line in LCD
writestr("curr temp="); // write string
intr = 1;
cs = 0;
rd = 1;
wr = 0; // write enable to ADC
P1 = 0x01; // select channel 1
while(!intr); // wait for conversion over
rd = 0; // read enable
wr = 1;
data2=P1; // get the data from P1
display(data2); // display it
writestr("'C ");
if(data2>=data1) // if current temp is higher
{
writecmd(0xC0);
writestr("over temperature"); //display message
heater = 0; // turn off heater
cooler = 1; // turn on cooler
}
else
{
heater = 1; // or turn on heater
cooler = 0; // turn off cooler
}
EA = 1; //enable interrupt before exiting
} // loop
}
void display(unsigned char z)
{
unsigned char tmp; // define temporary variable
unsigned char ASCII[2]; // define 2 digit variable
tmp = z>>4; // get upper nibble
if(tmp <= 0x09) // if its less then 9 convert it
ASCII[1] = tmp+0x30; // in ASCII by adding 30
else
{
ASCII[1] = tmp-0x09; //otherwise first deduct 9
ASCII[1] += 0x40; // then convert it in ascii
}
tmp = (z & 0x0f); // get lower nibble and perform
if(tmp <= 0x09) // same operation
ASCII[0] = tmp+0x30;
else
{
ASCII[0] = tmp-0x09;
ASCII[0] += 0x40;
}
writedat(ASCII[1]);
writedat(ASCII[0]);
}
void delay(void)
{
int x;
for(x=0;x<10000;x++);
}
void writecmd(unsigned char a)
{
busy(); //check if LCD is busy or not
rs = 0; // select command register
rw = 0; // write to LCD
P0 = a; // send byte to LCD
en = 1; // apply strobe
en = 0;
}
void writedat(unsigned char b)
{
busy(); //check if LCD is busy or not
rs = 1; // select data register
rw = 0;
P0 = b; // write to LCD
P0 = a; // send byte to LCD
en = 1; // apply strobe
en = 0;
}
void busy()
{
en = 0; //disable display
P0 = 0xFF; // P0 as input port
rs = 0; // select command register
rw = 1; // read enable
while(b==1) // wait until busy flag is 1
{
en=0;
en=1;
}
en=0;
}
void writestr(unsigned char *s)
{
unsigned char l,i;
l = strlen(s); //get the length of string
for(i=1;i<l;i++) // send all characters one by one
{
writedat(*s); // till the end of string
s++;
}
}
void main()
{
TMOD = 0xA0; // initialize timer 1 with 16 bit timer
TH1 = 0x3C; // load initial count 15,535 = 3CAFh
TL1 = 0xAF;
heater = 1; // initially heater is on
cooler = 0;
writecmd(0x3C); // initialize LCD
writecmd(0x0E);
writecmd(0x01);
writestr("set temp="); // send string to LCD
delay();
intr = 1;
cs = 0; // enable ADC
rd = 1;
wr = 0; // write enable
P1 = 0x02; // select 2nd channel
while(!intr); // wait until conversion is over
rd = 0; // read enable
wr = 1;
data1=P1; // get digital data from ADC
display(data1); // display it
writestr("'C ");
TR1=1; // start timer 1
IE = 0x88; // enable timer 1 overflow interrupt
while(1); // continuous loop
}
###
Circuit Diagrams
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.