Using TC74 Temp Sensor
Using TC74 Temp Sensor
HOME
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
NETDUINO
PIC TUTORIALS
CHIPKIT
AVR XMEGA
PRODUCTS
STM32
ARDUINO PROJECTS
THEORY
PIC PROJECTS
CONTACT US
Embedded Lab
by R-B
19 comments |
Search...
SUBSCRIBE
Subscribe through
email
Sign Up
Theory
The TC74 digital temperature sensor is available in SOT-23
and TO-220 packages. The communication with the device
is accomplished via a 2-wire I2C compatible serial
bus. Temperature resolution is 1C and conversion rate is
http://embeddedlab.com/blog/?p=3146
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
(PPG) as a non-invasive
technique for detecting
cardio-vascular pulse
wave. Read More ...
International
customers buy here
2/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
CATEGORIES
http://embeddedlab.com/blog/?p=3146
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Robotics (9)
STM32 (7)
Tech News (110)
Texas Instruments (4)
Tips and Tricks (85)
Uncategorized (2)
XMega (4)
Circuit diagram
Software
The firmware for PIC18F2550 is developed in C using
mikroC Pro for PIC compiler. The compiler provides the
built-in library for I2C support. The microcontroller reads
the temperature word from the TC74s internal
temperature register and displays it on the LCD. The
http://embeddedlab.com/blog/?p=3146
4/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
//DefineLCDmoduleconnections.
sbitLCD_RSatRC6_bit;
sbitLCD_ENatRC7_bit;
sbitLCD_D4atRB4_bit;
sbitLCD_D5atRB5_bit;
sbitLCD_D6atRB6_bit;
sbitLCD_D7atRB7_bit;
sbitLCD_RS_DirectionatTRISC6_bit;
sbitLCD_EN_DirectionatTRISC7_bit;
sbitLCD_D4_DirectionatTRISB4_bit;
sbitLCD_D5_DirectionatTRISB5_bit;
sbitLCD_D6_DirectionatTRISB6_bit;
sbitLCD_D7_DirectionatTRISB7_bit;
//EndLCDmoduleconnectiondefinition
unsignedcharTemp;
unsignedshortnum;
constintTC74A0=0x90;
voidcheck_device(unsignedshortdev_address){
I2C1_Start();
if(I2C1_Wr(dev_address)){
Lcd_Out(1,1,"Devicenotfound");
}
elseLcd_Out(1,1,"TC74device");
I2C1_Stop();
}
unsignedshortRead_Temp(){
unsignedshortresult;
I2C1_Start();//Issuestartsignal
I2C1_Wr(TC74A0);//Address+Writebit
I2C1_Wr(0x00);//ReadTemp
I2C1_Repeated_Start();//Issuestartsignal
I2C1_Wr(TC74A0+1);//Address+Readbit
result=I2C1_Rd(0u);
returnresult;
}
chartemperature[]="000C";
voidmain(){
CMCON=0x07;//Disablecomparators
ADCON1=0x0F;//DisableAnalogfunctions
TRISA=0x00;
TRISC=0x00;
TRISB=0x00;
I2C1_Init(100000);//InitiateI2C
Lcd_Init();//InitializeLCD
Lcd_Cmd(_LCD_CLEAR);//CLEARdisplay
Lcd_Cmd(_LCD_CURSOR_OFF);//Cursoroff
Lcd_Out(1,1,"TestingTC74");
Lcd_Out(2,1,"Thermalsensor");
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
do{
check_device(TC74A0);
num=Read_Temp();
http://embeddedlab.com/blog/?p=3146
5/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
//Checkfornegativetemperature
if(num>127){
temperature[0]='';
num=~num+1;
}
elsetemperature[0]='+';
temperature[1]=num/100+48;
temperature[2]=(num/10)%10+48;
temperature[3]=num%10+48;
temperature[5]=223;
//eliminate0satbeginning
if(temperature[1]=='0'){
temperature[1]='';
if(temperature[2]=='0')temperature[2]='';
}
Lcd_Out(2,4,temperature);
Delay_ms(500);
}while(1);
}
http://embeddedlab.com/blog/?p=3146
6/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Conclusion
The technique of interfacing Microchips TC74 sensor with
a PIC microcontroller to measure the ambient
temperature was discussed and demonstrated
successfully. The communication with the TC74 sensor was
accomplished through an I2C bus interface of PIC18F2550.
The 8-bit temperature word was read from the internal
temperature register and displayed on a LCD screen by the
PIC18F2550 microcontroller.
Related posts:
1. Lab 12: Basics of LED dot matrix display
2. Lab 11: Multiplexing seven segment LED displays
3. Lab 14: Inter-Integrated Circuit (I2C)
communication
4. Expanding the number of I/O lines using Microchip
MCP23008
7/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Embedded Lessons
PIC18F
19 COMMENTS
shab132
hello, nice to meet you, i have tried the code and but is
given me error that the device not found. And can i used
PIC 16f877A for the same code? thanks.
Reply
Konstantin
Hi
Thank you about your excellent website.its very useful
This project was very useful for me but your program has a
tiny problem :
in the read_temp function after you got the result ,
you must stop the i2c with i2c_stop(); if you dont do it,your
program (after going in this function for the first time)
cant use the i2c protocol again.you can repair it by steps
below :
1) at the program (wich shown in the site) where function
unsigned short Read_Temp(){ is developed
2)after result = I2C1_Rd(u);
and before return result;
3) add I2C1_stop();
thank you for your site.
Ill be happy to answer me by e_mail
Reply
http://embeddedlab.com/blog/?p=3146
8/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Konstantin
Hi! Thank you for your reply. I am not trying to say that
the code is wrong or anything like that. Obviously, I
miss subtle details. However, I still cant run the
simulation in Proteus.
Please, help if possible. I could send you the Proteus
project if it is necessary.
Regards, Konstantin
[email protected]
Reply
Konstantin
hello,,good day.
will the project still work the same if we will use TC74-5.0
VCTTR instead of VAT?
Reply
R-B
Hi,
Im making a project with this sensor; Ive got an A0 type.
http://embeddedlab.com/blog/?p=3146
9/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Hi,
Im a newbee for uControllers and unfortunately I have
only a TC74A2 5.0VAT sensor. Which part of the original
program do I have to modify for the proper functionality.
Thanks in advance,
http://embeddedlab.com/blog/?p=3146
10/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Miklos
Reply
R-B
@Miklos,
The I2C slave address of TC74A2 5.0VAT is 092. So you
need to change it in the following line of the code:
const int TC74A0 = 090;
Replace 090 by 092, and it should work.
Reply
Michael Havenga
Good day,
I am enjoying working with this project, but I would like to
be able to do a conditional operator to set a temperature
point where something happens:
Psuedo
When temp >= 28C then print additional message to LCD;
When temp >= 28C then set port to start fan;
Simple, yes but I cant figure out how to work with tha data
types. If I convert temperture to int then it stays at a value
of 36.
If I just fo a conditional operator ie:
void checktemp(){
if (temperature >=28) Lcd_Out(2,6,T HIGH!);
}
Then when the temp on the display is no where near
28and the additional message is already typed. Any help
please, it would be greatly appreciated.
Regards
Michael
PS: I am in the process of converting to 3v3 uMicro. So I
will let you know how the project works on low voltage J
type PICs.
Reply
Michael Havenga
Go to Top| Contact Us |
Privacy Policy | Log In
Hi,
Thanks for the great project, got it working. I was however
perplexed by a problem I first experienced when trying to
get the code to work on a PIC16F887 I might be mising
http://embeddedlab.com/blog/?p=3146
11/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
Hi,
Has this been tested on SMBUS I would like to use this is
in a 3v3 application ?
Regards
Michael
Reply
Pingback: I liked this: How to use Microchips TC74 sensor
for temperature measurement | Road to 2012
Pingback: Electronics-Lab.com Blog Blog Archive How to
use Microchips TC74 sensor for temperature
measurement
LEAVE A REPLY
Your email address will not be published. Required fields
are marked *
Name *
Email *
Website
Comment
Post Comment
http://embeddedlab.com/blog/?p=3146
12/13
13/12/2014
UsingTC74(Microchip)thermalsensorfortemperaturemeasurement|EmbeddedLab
http://embeddedlab.com/blog/?p=3146
zeeDynamic Theme
13/13