 |
plc.myforum.ro PLCs users www.plc.myforum.ro!
|
| View previous topic :: View next topic |
| Author |
Message |
mojo Senior

Joined: 01 Oct 2011 Posts: 2404
|
Posted: 08/01/2012 16:53 Post subject: LM35 Tepm. read. with Codevision AVR LCD viewer |
|
|
LM35 TEMPERATURE READINGS APPLICATIONS BY USING codevision AVR LCD viewer
Application temperature readings (temperature monitoring), using an LM35 sensor is a temperature sensor with a relatively cheap price and its output is a voltage that is linear.
According to the LM35 datasheet, to rise 1 degree Celsius will result in changes to the output voltage is 10mV. Where when the temperature is 0 ° Celsius sensor has an offset voltage of 0 V. To get the LM35 datasheet, please download here .
Here I will make temperature readings in units of degrees Celsius with a measurement range of 0 ° -100 ° Celsius. So that the output voltage of the LM35 is 0-1 V.
The output voltage can already be read by the microcontroller through ADC without the need for a voltage amplifier. I have made this application in the form of real (true) and I also simulated using Proteus. Schematic LM35 which is then displayed on the LCD can be viewed above.
As for the program using CodeVision AVR, the following is a complete program listing.
| Code: | int TEMPERATURE;
char temp [8];
suhu_celcius float;
# Conține <mega16>
# Include <stdlib>
# Include <lcd>
# Include <delay>
/ / Alphanumeric LCD Module functions
# Asm
. Equ __lcd_port = 0x15; PORTC
# Endasm
0x40 # define ADC_VREF_TYPE
/ / Read the AD conversion result
read_adc unsigned int (unsigned char adc_input)
{
ADMUX = adc_input | (ADC_VREF_TYPE & 0xff);
/ / Delay needed for the stabilization of the ADC input voltage
delay_us (10);
/ / Start the AD conversion
ADCSRA | = 0x40;
/ / Wait for the AD conversion to complete
while ((ADCSRA & 0x10) == 0);
ADCSRA | = 0x10;
ADCW return;
}
void main (void)
{
/ / Analog Comparator initialization
/ / Analog Comparator: Off
/ / Analog Comparator Input Capture by Timer / Counter 1: Off
ACSR = 0x80;
SFIOR = 0x00;
/ / ADC initialization
/ / ADC Clock frequency: 750.000 kHz
/ / ADC Voltage Reference: AVCC pin
/ / ADC Auto Trigger Source: None
ADMUX = ADC_VREF_TYPE & 0xff;
ADCSRA = 0x84;
/ / LCD module initialization
lcd_init (16);
lcd_clear ();
lcd_gotoxy (0.0);
lcd_putsf ("Electro-control");
lcd_gotoxy (0.1);
lcd_putsf ("LM35 TEMPERATURE SENSOR");
Delay_ms (1000);
while (1)
{
lcd_clear ();
TEMPERATURE = read_adc (0);
suhu_celcius = (float) TEMPERATURE * 500/1023; / / formula to convert Celsius into degrees
lcd_gotoxy (0.0);
lcd_putsf ("Electro-control");
ftoa (suhu_celcius, 1, temp); / / change the data type to data type float array that will be displayed on the LCD
lcd_gotoxy (0.1);
lcd_puts (temp);
lcd_gotoxy (5.1);
lcd_putchar (0xdf); / / display the character degrees
lcd_putsf ("C");
Delay_ms (500);
};
} |
If you want to get the program files in the form of AVR and simulation proteus CodeVision please download the link below.
http://downloads.ziddu.com/downloadfile/15512283/lm35_V2.rar.html |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|