Design a digital temperature meter using one temperature sensor
Temperature Indicator
In the preented circuit diagram, Thermister is used to measure the temperature, Thje thermister is connected at connector (J3).
A LCD is also connected to show the temperature on LCD.
The design is around PIC16F877A microcontroller. This design also controls the heating and cooling using the two relays as Relay-1 and Relay-2.
The working code for the same is given below:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#define SET_POINT_WINTER_LOW_L 0x00
#define SET_POINT_WINTER_LOW_H 0x01
#define SET_POINT_WINTER_HIGH_L 0x02
#define SET_POINT_WINTER_HIGH_H 0x03
#define SET_POINT_SUMMER_LOW_L 0x04
#define SET_POINT_SUMMER_LOW_H 0x05
#define SET_POINT_SUMMER_HIGH_L 0x06
#define SET_POINT_SUMMER_HIGH_H 0x07
#define ADDRESS_SEASON 0x08
#define WINTER 0
#define SUMMER 1
#define DISPLAY_FREQ 25000
#define FLIP_DISP_FREQ 1000
#define BOUNCE_DELAY 200
#define LED_ON 0
#define LED_OFF 1
#define EEPROM_DELAY 200
/* Time delay for LCD On time*/
#define LCD_ON_TIME 40
unsigned char SetPoint_Winter_Low_L=0,SetPoint_Winter_Low_H=0;
unsigned char SetPoint_Winter_High_L=0,SetPoint_Winter_High_H=0;
unsigned char SetPoint_Summer_Low_L=0,SetPoint_Summer_Low_H=0;
unsigned char SetPoint_Summer_High_L=0,SetPoint_Summer_High_H=0;
unsigned char Season=WINTER;
unsigned int CurrentTemp,SetPoint_High,SetPoint_Low;
unsigned int ADCVal=0;
unsigned int DisplayCount=0;
//sbit RL_CH_TEMP at RE0_bit;
//sbit RL_CH_TEMP_Direction at TRISE0_bit;
//sbit RL_CC at RA5_bit;
sbit RL_CH at RA5_bit; //Heatin Relay
sbit RL_CH_Direction at TRISA5_bit;
sbit RL_CC at RE0_bit; //Cooling Relay
sbit RL_CC_Direction at TRISE0_bit;
// Lcd pinout settings
sbit LCD_RS at RC5_bit;
//sbit LCD_CHECK at RD2_bit;
sbit LCD_EN at RC7_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D4 at RD4_bit;
sbit LED_H at RB4_bit;
sbit LED_C at RB5_bit;
sbit LED_H_Direction at TRISB4_bit;
sbit LED_C_Direction at TRISB5_bit;
sbit SW_1 at RB0_bit;
sbit SW_2 at RB1_bit;
// Pin direction
sbit LCD_POWER at RB2_bit;
sbit LCD_POWER_Direction at TRISB2_bit;
sbit LCD_RS_Direction at TRISC5_bit;
//sbit LCD_CHECK_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISC7_bit;
sbit LCD_D7_Direction at TRISD7_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
void DisplayWinterSetPoints(void);
void DisplaySummerSetPoints(void);
void FaultCondition(void);
void EditSeason(void);
const code unsigned int Res_1[] = {
28160,
26920,
25760,
24650,
23600,
22600,
20740,
19870,
19050,
18270,
17510,
16800,
16120,
15470,
14850,
14260,
13700,
13160,
12640,
12160,
11680,
11230,
10800,
10390,
10000,
9624 ,
9265 ,
8921 ,
8591 ,
8276 ,
7973 ,
7684 ,
7406 ,
7140 ,
6885 ,
6641 ,
6406 ,
6181 ,
5965 ,
5758 ,
5559 ,
5368 ,
5185 ,
5008 ,
4839 ,
4676 ,
4520 ,
4370 ,
4225 ,
4086 ,
3953 ,
3824 ,
3700 ,
3581 ,
3467 ,
3356 ,
3250 ,
3147 ,
3049 ,
2954 ,
2862 ,
2774 ,
2689 ,
2607 ,
2528 ,
2451 ,
2378 ,
2306 ,
2238 ,
2172 ,
2108 ,
2046 ,
1986 ,
1929 ,
1873 ,
1820 ,
1768 ,
1717 ,
1669 ,
1622 ,
1577 ,
1533 ,
1490 ,
1449 ,
1410 ,
1371 ,
1334 ,
1298 ,
1263 ,
1229 ,
1197 ,
1165 ,
1134 ,
1105 ,
1076 ,
1048 ,
1021 ,
995 ,
969 ,
945 ,
};
unsigned char EditSetPoints(unsigned char EditData)
{
unsigned char FlagEdit=1,tempEditData;
tempEditData = EditData;
while(FlagEdit)
{
Lcd_Chr(2,8,0x30+(EditData/10));
Lcd_Chr(2,9,0x30+(EditData%10));
if(SW_1==0) {Delay_ms(BOUNCE_DELAY);tempEditData=tempEditData+1;if(tempEditData>50) tempEditData=0;}
if(SW_2==0) FlagEdit=0;
}
return(tempEditData);
}
void FaultCondition(void)
{
Lcd_Out(1,1," FAULT ");
Lcd_Out(2,1," SENSOR OPEN ");
RL_CH=0;
RL_CC=0;
LED_H=~LED_H;
LED_C = LED_OFF;
Delay_ms(500);
}
void EditSeason(void)
{
if(Season==WINTER) Season = SUMMER;
else Season = WINTER;
Lcd_Out(1,1,"SEASON CHANGED..");
if(Season==WINTER) Lcd_Out(2,1,"NOW -> WINTER ");
if(Season==SUMMER) Lcd_Out(2,1,"NOW -> SUMMER ");
while(SW_1==0){} Delay_ms(500);
}
void MakeLCDOff(void)
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
LCD_POWER=0;
}
unsigned int LCDDisplayCount=0;
void MakeLCDON(void)
{
LCD_POWER=1;
LCDDisplayCount=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
}
void main(void)
{
unsigned int TempChar,FinalTemperature,TResistance,Tempt=0,FlipDispCount=0;
unsigned char Flag=1,dCnt,EditCount=0,Flip=1,Error=0,FlagUp=0,FlagDown=0,H=0,C=0,FlagIO=0,y_1=0,y_2=0;
unsigned long CountEditSeason=0,DisplayONCount=0;
unsigned char FlagDisplaySetPoints=1,FlagSeason=WINTER,FlagH=0,FlagC=0,FlipDisplay=1,FirstTimeFlag=1;
unsigned long Temp,Qt,Rem,Tr;
signed char TempDir=1,TempPrev=0,TempCurrent=0;
TRISE = 0x00;
TRISD=0x00;
TRISC=0x00;
TRISB = 0x03;
TRISA = 0x0F;
ADC_Init();
LCD_POWER=1;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
RL_CH=0; RL_CC=0; //Both Relay OFF
DisplayCount=DISPLAY_FREQ;
SetPoint_Winter_Low_L = 17;// = EEPROM_Read(SET_POINT_WINTER_LOW); Delay_ms(EEPROM_DELAY);
SetPoint_Winter_Low_H = 19;//High = EEPROM_Read(SET_POINT_WINTER_HIGH); Delay_ms(EEPROM_DELAY);
SetPoint_Winter_High_L = 21;// = EEPROM_Read(SET_POINT_WINTER_LOW); Delay_ms(EEPROM_DELAY);
SetPoint_Winter_High_H = 23;//High = EEPROM_Read(SET_POINT_WINTER_HIGH); Delay_ms(EEPROM_DELAY);
SetPoint_Summer_Low_L = 19;// = EEPROM_Read(SET_POINT_WINTER_LOW); Delay_ms(EEPROM_DELAY);
SetPoint_Summer_Low_H = 21;//High = EEPROM_Read(SET_POINT_WINTER_HIGH); Delay_ms(EEPROM_DELAY);
SetPoint_Summer_High_L = 23;// = EEPROM_Read(SET_POINT_WINTER_LOW); Delay_ms(EEPROM_DELAY);
SetPoint_Summer_High_H = 25;//High = EEPROM_Read(SET_POINT_WINTER_HIGH); Delay_ms(EEPROM_DELAY);
Season = EEPROM_Read(ADDRESS_SEASON); Delay_ms(EEPROM_DELAY);
if(Season!=WINTER && Season!=SUMMER) {Season = WINTER;}
// Season = WINTER;
while(1)
{
if(DisplayCount>=DISPLAY_FREQ)
{
TempPrev = TempCurrent;
if(LCDDisplayCount < LCD_ON_TIME) LCDDisplayCount++;
if(LCDDisplayCount >= LCD_ON_TIME) MakeLCDOff();//LCD_POWER=0;
FlipDispCount++;
if(FlipDispCount >= FLIP_DISP_FREQ) {FlipDisplay=1-FlipDisplay; FlipDispCount=0;}
DisplayCount=0;
Flag=1;
Temp = ADC_Read(0);
if(Temp < 950)
{
LED_H = LED_OFF;
Error=0;
Qt = ((Temp *10)/(1024 - Temp))*1000;
Rem = (Temp *10)%(1024 - Temp);
Tr = Qt + Rem;
if(FlipDisplay)
{
if(Season==SUMMER) {Lcd_Out(1,1,"SUMMER (HIGH)");}
else {Lcd_Out(1,1,"WINTER (LOW) ");}
Lcd_Out(2,1,"COACH TEMP= C");
y_1=2;
}
else
{
Lcd_Out(1,1,"COACH TEMP= C");
y_1=1;
}
for(dCnt=0;(dCnt < 99 && Flag==1);dCnt=dCnt+1)
{
if(Flag==1 && Tr > Res_1[dCnt+1] && Tr <= Res_1[dCnt])
{
Flag=0;
FinalTemperature = dCnt+1;
}
}
if(TempDir!=0)
{
Lcd_Chr(y_1,15,0xDF);
TempChar = 0x30 + (FinalTemperature/10); Lcd_Chr(y_1,13,TempChar);
TempChar = 0x30 + (FinalTemperature%10); Lcd_Chr(y_1,14,TempChar);
}
// TempChar = 0x30 + (LCDDisplayCount/10); Lcd_Chr(1,15,TempChar);
// TempChar = 0x30 + (LCDDisplayCount%10); Lcd_Chr(1,16,TempChar);
TempCurrent = FinalTemperature;
TempDir = TempCurrent - TempPrev;
}
else
{
MakeLCDON();
FaultCondition();
Error=1;
LED_H=LED_OFF;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
}
}
DisplayCount++;
if(Error==0)
{
if(Season==WINTER)
{
if(FinalTemperature >= 23 ) C=1;
if(FinalTemperature > 21 && FinalTemperature < 23 && TempDir < 0) C=1;
if(FinalTemperature <= 21 && TempDir < 0) C=0;
if(FinalTemperature > 21 && FinalTemperature < 23 && TempDir > 0) C=0;
if(FinalTemperature <= 17 ) H=1;
if(FinalTemperature > 17 && FinalTemperature < 19 && TempDir > 0) H=1;
if(FinalTemperature >= 19 ) H=0;
if(FinalTemperature > 17 && FinalTemperature < 19 && TempDir < 0) H=0;
if(H) {RL_CH=1; RL_CC=0;}
if(C) {RL_CH=0; RL_CC=1;}
if(H==0 && C==0) {RL_CH=0; RL_CC=0;}
}
if(Season==SUMMER)
{
if(FinalTemperature >= 25 ) C=1;
if(FinalTemperature > 23 && FinalTemperature < 25 && TempDir < 0) C=1;
if(FinalTemperature <= 23 ) C=0;
if(FinalTemperature <= 19 ) H=1;
if(FinalTemperature > 19 && FinalTemperature < 21 && TempDir > 0) H=1;
if(FinalTemperature >= 21 ) H=0;
if(FinalTemperature > 19 && FinalTemperature < 21 && TempDir < 0) H=0;
if(H) {RL_CH=1; RL_CC=0;}
if(C) {RL_CH=0; RL_CC=1;}
if(H==0 && C==0) {RL_CH=0; RL_CC=0;}
}
if(!FlipDisplay)
{
if(H==1 && C==0) Lcd_Out(2,1,"Htr-ON AC-OFF");
if(H==0 && C==1) Lcd_Out(2,1,"Htr-OFF AC-ON");
if(H==0 && C==0) Lcd_Out(2,1,"Htr-OFF AC-OFF");
}
if(SW_1==0)
{
MakeLCDON();
FlagDisplaySetPoints=1;
Delay_ms(BOUNCE_DELAY);
Flip=1-Flip;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
if(Flip==1) DisplayWinterSetPoints();
if(Flip==0) DisplaySummerSetPoints();
while(FlagDisplaySetPoints)
{
CountEditSeason=0;
if(SW_1==0)
{
Delay_ms(BOUNCE_DELAY);
while(SW_1==0)
{
CountEditSeason++;
if(CountEditSeason>100000)
{
EditSeason();
EEPROM_Write(ADDRESS_SEASON,Season); Delay_ms(EEPROM_DELAY);
}
}
FlagDisplaySetPoints=0;
}
else
{
Delay_ms(1500); FlagDisplaySetPoints=0;
}
}
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
DisplayCount=DISPLAY_FREQ;
}
/*
if(SW_2==0)
{
Delay_ms(BOUNCE_DELAY);
if(EditCount==0)
{
SetPoint_Winter_Low_L = EditSetPoints(SetPoint_Winter_Low_L);
EEPROM_Write(SET_POINT_WINTER_LOW_L,SetPoint_Winter_Low_L); Delay_ms(EEPROM_DELAY);
}
if(EditCount==1)
{
SetPoint_Winter_Low_H = EditSetPoints(SetPoint_Winter_Low_H);
EEPROM_Write(SET_POINT_WINTER_LOW_H,SetPoint_Winter_Low_H); Delay_ms(EEPROM_DELAY);
}
if(EditCount==2)
{
SetPoint_Winter_High_L = EditSetPoints(SetPoint_Winter_High_L);
EEPROM_Write(SET_POINT_WINTER_HIGH_L,SetPoint_Winter_High_L); Delay_ms(EEPROM_DELAY);
}
if(EditCount==3)
{
SetPoint_Winter_High_H = EditSetPoints(SetPoint_Winter_High_H);
EEPROM_Write(SET_POINT_WINTER_HIGH_H,SetPoint_Winter_High_H); Delay_ms(EEPROM_DELAY);
}
if(EditCount==4)
{
SetPoint_Summer_Low_L = EditSetPoints(SetPoint_Summer_Low_L);
EEPROM_Write(SET_POINT_SUMMER_LOW_L,SetPoint_Summer_Low_L); Delay_ms(EEPROM_DELAY);
}
if(EditCount==5)
{
SetPoint_Summer_Low_H = EditSetPoints(SetPoint_Summer_Low_H);
EEPROM_Write(SET_POINT_SUMMER_LOW_H,SetPoint_Summer_Low_H); Delay_ms(EEPROM_DELAY);
}
if(EditCount==6)
{
SetPoint_Summer_High_L = EditSetPoints(SetPoint_Summer_High_L);
EEPROM_Write(SET_POINT_SUMMER_HIGH_L,SetPoint_Summer_High_L); Delay_ms(EEPROM_DELAY);
}
if(EditCount==7)
{
SetPoint_Summer_High_H = EditSetPoints(SetPoint_Summer_High_H);
EEPROM_Write(SET_POINT_SUMMER_HIGH_H,SetPoint_Summer_High_H); Delay_ms(EEPROM_DELAY);
}
EditCount=EditCount+1;
if(EditCount>7) EditCount=0;
DisplayCount=DISPLAY_FREQ;
}
*/
}
}
}
void DisplayWinterSetPoints(void)
{
Lcd_Out(1,1,"WINTER:");
Lcd_Chr(1,9, 0x30+(SetPoint_Winter_Low_L/10));
Lcd_Chr(1,10,0x30+(SetPoint_Winter_Low_L%10));
Lcd_Chr(1,14,0x30+(SetPoint_Winter_Low_H/10));
Lcd_Chr(1,15,0x30+(SetPoint_Winter_Low_H%10));
Lcd_Chr(2,9, 0x30+(SetPoint_Winter_High_L/10));
Lcd_Chr(2,10,0x30+(SetPoint_Winter_High_L%10));
Lcd_Chr(2,14,0x30+(SetPoint_Winter_High_H/10));
Lcd_Chr(2,15,0x30+(SetPoint_Winter_High_H%10));
}
void DisplaySummerSetPoints(void)
{
Lcd_Out(1,1,"SUMMER:");
Lcd_Chr(1,9, 0x30+(SetPoint_Summer_Low_L/10));
Lcd_Chr(1,10,0x30+(SetPoint_Summer_Low_L%10));
Lcd_Chr(1,14,0x30+(SetPoint_Summer_Low_H/10));
Lcd_Chr(1,15,0x30+(SetPoint_Summer_Low_H%10));
Lcd_Chr(2,9, 0x30+(SetPoint_Summer_High_L/10));
Lcd_Chr(2,10,0x30+(SetPoint_Summer_High_L%10));
Lcd_Chr(2,14,0x30+(SetPoint_Summer_High_H/10));
Lcd_Chr(2,15,0x30+(SetPoint_Summer_High_H%10));
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

If an analog temperature sensor is used with an 8 bit ADC (analog to digital converter) and a 5 volt power source, what is the smallest temperature increment you could measure? That is, what is the resolution here?
11.5 A temperature sensor is connected to a 16F873A ADC input. The sensor has an output of 40 mV/?C. The ADC operates with a 4.096 V reference. (a) For a certain temperature value, the ADC output reads 1010011100. What is the equivalent temperature for this reading? (b) The measured temperature is to be displayed on a digital display, showing values in the range 00.0?C to 99.9?C. Describe what data manipulation steps can be taken to achieve this, using fixed-point arithmetic...
Liquid Level 1. You are using a 1 turn rotatory potentiometer to design a level sensor to measure liquid level on a tank. The total resistance of the potentiometer R = 10K and the output voltage that is measured by an Arduino is IV. Find the angle of turned in the potentiometer as well as the height of liquid level in the tank. 2. A platinum resistance coil is to be used as a temperature sensor (Rthermal) and has a...
A single intraoral image using a digital sensor results in an effective exposure dose of? a. 0.002 mSv b. 0.020 mSv c. 0.2000 mSv d. 2.000 mSv e. 20.00 mSv
1. Design a pheromone sensor. 2. Design a taste sensor.
Design a sensor to measure the human weight using the piezoelectric concept
(i)explain how reading an analogueeter differ from a digital meter (ii) describe how volt-meter are connected to a circuit. (iii) describe how amp-meter are connected to a circuit. (iv) explain how analogue ohm-meter differ from a digital ohm-meter in setup. (v) explain what precautions one should take while testing a circuit using an ohm-meter.
Two pressure sensors are installed on a 9-meter-high submarine: one sensor is on the top and another one in at the bottom of the submarine. When the submarine dives, what is the difference in readings of the two pressure sensors? The density of water is 1000 kg/m.
help with the following problem please Proceed to design a digital circuit in which you want to control two filling water pumps from a well to a reservoir. The system has 4 different sensors: 1. T1: Pump temperature 1 2. T2: Pump temperature 2 3. c: Minimum water level in the tank 4. d: Maximum water level in the tank The system must operate taking into account the following conditions: A) If the water level of the tank is between...
the component To measure voltage using a digital multimeter the probes of the meter would be placed O A. Parallel OB. Adjacent O C.Perpendicular OD. Tangent