In this tutorial we will interfacing Temperature Sensor (LM35) with 8051 using ADC0804. ADC0804 interfacing with 8051. ADC0804 is a 8-bit ADC.
- 1 ADC0804 interfacing with 8051
- 2 Introduction
- 3 ADC 0804
- 4 Temperature Sensor (LM35)
- 5 Interfacing
ADC0804 interfacing with 8051
Analog to digital converters find huge application as an intermediate device to convert the signals from analog to digital form. These digital signals are used for further processing by the digital processors. Various sensors like temperature, pressure, force etc. convert the physical characteristics into electrical signals that are analog in nature.
Why we are using ADC for 8051 Microcontroller?
Well. 8051 doesn’t has inbuilt ADC. So we have to use external ADC. There are many ADCs available.
- ADC 0804
- ADC 0808
In this post we will see ADC 0804. In our next post we will see ADC0808. Let’s Start.
- 0V to 5V analog input voltage range with single 5V supply
- Compatible with microcontrollers, access time is 135 ns
- Easy interface to all microprocessors
- Logic inputs and outputs meet both MOS and TTL voltage level specifications
- Works with 2.5V (LM336) voltage reference
- On-chip clock generator
- No zero adjust required
- 0.3[Prime] standard width 20-pin DIP package
- Operates ratio metrically or with 5 VDC, 2.5 VDC, or analog span adjusted voltage reference
- Differential analog voltage inputs
How to use the ADC0804?
- Make Cs(chip select) low(0) to activate the ic. Here we are directly connecting that CS into Ground instead of connecting into 8051.
- Make WR(write) pin low (0).
- Make RD(read) pin high (1).
- Make WR(write) pin high (1) after some delay small delay//This low to high impulse at WR pin starts your conversion.
- Now check the INTR(interrupt) pin if it is high(1) conversion is runing if it is low(0) the conversion is over.
- Make RD=low(0) .
This will bring the converted value to the 8 data output pins of ADC 0804.
Temperature Sensor (LM35)
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ˚ Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of ±1 ⁄4˚C at room temperature and ±3 ⁄4˚C over a full −55 to +150˚C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35’s low output impedance, linear output, and precise inherent calibration make interfacing to readout or control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. As it draws only 60 µA from its supply, it has very low self-heating, less than 0.1˚C in still air. The LM35 is rated to operate over a −55˚ to +150˚C temperature range, while the LM35C is rated for a −40˚ to +110˚C range (−10˚ with improved accuracy). The LM35 series is available packaged in hermetic TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount small outline package and a plastic TO-220 package.
- Calibrated directly in ˚ Celsius (Centigrade)
- Linear + 10.0 mV/˚C scale factor
- 0.5˚C accuracy guarantee able (at +25˚C)
- Rated for full −55˚ to +150˚C range
- Suitable for remote applications
- Low cost due to wafer-level trimming
- Operates from 4 to 30 volts
- Less than 60 µA current drain
- Low self-heating, 0.08˚C in still air
- Nonlinearity only ±1 ⁄4˚C typical
- Low impedance output, 0.1 Ω for 1 mA load
Now we will interface LM35 with MCS51 to monitor the Temperature on LCD display.
- RS : P0.5
- RW : P0.6
- EN : P0.7
- Data Lines : P2
- RD : P0.0
- WR : P0.1
- INTR : P0.2
- Output : P1
Output of Temp sensor – Vin+ (6)
You can download this code on Github… To download Click Here.
#define delay for(i=0;i<1000;i++);
#define lcd P2
void cmd(unsigned int b);
void dat(unsigned int c);
void show(unsigned char *s);
unsigned char adc(),get_value, conv;
show("Temp : ");
get_value = adc();
void cmd(unsigned int b)
void dat(unsigned int c)
void show(unsigned char *s)
unsigned char adc()
In our tutorial we are interfacing Temperature Sensor with 8051 by using ADC0804. Like this you can interface any analog sensor. If you have any doubts mail us or comment below.