Professional Documents
Culture Documents
PROJECT REPORT
Design: A system for measuring and monitoring environment
temperature using Microcontroller 8051, temperature sensor
to display on LCD and control motor with 2 modes
- Temperature sensor:
+ Choose LM35 due to:
Does not require any external calibration;
The shell can protect it from overheating;
Low cost and high accuracy.
- Analog-to-Digital Converter:
+ Choose ADC0804 due to:
Low cost, easy to use, simple interface;
Good resolution: 8-bit resolution, high precision;
High stability: automatic compensation of input signal and noise;
Compatible with a wide range of microcontrollers.
- LCD:
+ Choose LCD16x2 due to:
Popular size
Good resolution
Simple and easy to use interface
Energy saving
Reasonable price, stable features
- Motor driver module:
+ Choose L293D due to:
Simple and easy to use interface
Over-current and over-temperature protection
Reasonable price and stable features
- Microcontroller: AT89C51
- Fan: DC motor
II. Working principle:
LM35:
Pin 1 - VCC:
+ Supply 5V power to the sensor.
Pin 2 - Analog output:
+ Vout = 10mV/°C x T (-55°C - 150°C);
+ Connect to VIN+ Pin of ADC0804 to transm
wait for ADC to process.
ADC0804:
Pin 20 - VCC:
+ Supply 5V power to the sensor.
Pin 11-18 - DBi (0< i <7):
+ Export digital data to P2 Pins of
MC8051 and wait for MC8051 to
process before exporting to LCD.
Pin 1 – CS (Chip Select):
+ Connect it to mass to work.
Pin 9 – VREF/2:
+ Input voltage used as reference
voltage.
+ Connect to potentionmeter to
create 1.28mV input voltage.
AT89C51:
Port P1:
+ Connect to LCD to export ASCII data to LCD to display.
Port P2:
+ Connect to DB Pins to take digital data of temperature.
+ This digital data is temperature in hexa form. So, I need create a sub-program to
convert HEXA data into ASCII data before exporting to LC
Pin VDD:
+ Supply 5V power to the sensor.
Pin VEE:
+ Connect to the potentionmeter to adjust the contrast of LCD.
Pin RW (Read/Write):
+ Connect to GND => RW=0: Write mode.
Pin E (Enable):
+ Create a high-to-low pulse to enable the LCD by using commands “SETB” and
“CLR” with pin P3.7 of MC8051.
Pins D0 – D7:
+ Receive the data to be displayed on LCD or the command instructions.
L293D:
Pin EN1:
+ Supply PWM pulse from MC8051 to rotate the motor and the rotational speed can
be adjusted by code.
- Main program:
+ First, I adjust LCD to correctly operate requirements.
+ Next, call LCD_String display “TEMPERATURE IS: ” in LCD.
+ Call ADC_0804 to process analog signal from LM35 before displaying in LCD by
LCD_Display.
+ Afterthat, MC8051 create pulse and output to motor driver to control motor.
+ And jump to Main to continue the loop.
- ADC_0804:
+ First, I adjust the state of pins before starting process analog signal.
+ Next, set bit the pin ADC_WR to start conversion.
- LCD_Display:
+ First, move the digital signal that is just processed by ADC0804 to A-register.
+ Next, perform calculations to convert binary numbers to ASCII and display in
LCD.
+ The spaces are to center align.
- Auto_Mode:
+ Perform the comparison the temperature to find the right auto-mode.
- Auto_Mode1,2,3:
+ First, check state of manual-buttons: if is ON, jump back to Motor_Choose; else,
perform the next commands.
+ Next, check if temperature changes, jump to Return to return to Back.
+ If temperature does not change, run the corresponding motor-mode.
- Manual_Mode1,2,3:
+ First, check state of manual-buttons: if is ON, jump back to Motor_Choose; else,
perform the next commands.
+ Next, check if the state of corresponding manual-button: if is ON, run the
corresponding motor-mode; else, jump to RET.
- Mode1,2,3:
+ Set bit EN1-pin to start high pulse.
+ Move the suitable values into TH0 and TL0 to be counted when I start the Timer0
by calling Pulse.
+ Clear bit EN1-pin to start low pulse.
+ Move the suitable values into TH0 and TL0 to be counted when I start the Timer0
by calling Pulse.
- Pulse:
+ First, clear the overflow flag TF0 to start the new counter.
+ Run Timer0 and wait until TF0 = 1, stop Timer0 to create delay as required.
- Delay:
V. Simulation results:
Auto_Mode:
+ When I press AUTO button, motor will automatically run according to the
temperature displayed on the LCD.
+ When temperature is t<25°C
+ Similarly, when I press button MODE 2, even though AUTO button and
MODE 1 button are ON, motor runs mode-2 speed.
+ When I press button MODE 3, even though AUTO button, MODE 1 and
MODE 2 are ON, motor runs mode-3 speed.