INDEX

Contents 1. Introduction 2. Block Diagram Page no: 3 4

2.1 Power supply 2.2 Microcontroller 2.3 Features of AT89C51 2.4 Pin description

5 7 8 12

3. Programming Flash 4. Softwares Used

17 23

4.1 keil Compiler 4.2 Proload
5. LED Interfacing with the Microcontroller 6. Sensors 24

6.1 Temperature sensor 6.2 Magnetic sensor

26 28

7. RELAY
7.1 Transistor Driver Circuit 7.2 Relay Interfacing with the Microcontroller

32

34 36

1

8. Liquid Crystal Display

37

10.1 LCD screen 10.2 LCD Basic Commands 10.3 LCD Initialization
9. Working Procedure 10. Advantages 11. Scope for Advancements 12. Applications 13. Assembling Instructions

39 40 42
44 46 46 47 48

APPENDIX: source code CONCLUSION REFERENCE

2

1. INTRODUCTION
An embedded system is a combination of software and hardware to perform a dedicated task .

Some of the main devices used in embedded products are Microprocessors and Microcontrollers.

Microprocessors are commonly referred to as general purpose processors as they simply accept the inputs, process it and give the output.

In contrast, a microcontroller not only accepts the data as inputs but also manipulates it, interfaces the data with various devices, controls the data and thus finally gives the result.

All these tasks are possible with the microcontroller because the microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and timer all on a single chip. This fixed amount of RAM, ROM and number of I/O ports in microcontroller makes them ideal for many applications where cost and space are critical.

The Project Petrochemical Level Indicator and Controller with Temperature Monitor in Cotton Industries is an efficient project which eliminates the person involvement completely in process of filling the tank and monitors the temperature continuously.

3

2. BLOCK DIAGRAM

Boiler
Temperature

sensor 8 9 C 5 1

Relay Driver

Level 1

Magnetic sensors for level measurement

Level 2 Level 3 Level 4

Hooter/
Siren driver Motor

LCD

Siren

LED Array Driver

LED Array For level indication

Step down T/F

Bridge Rectifier

Filter Circuit

Regulator Power supply to all sections

4

DESCRIPTION

POWER SUPPLY:
The input to the circuit is applied from the regulated power supply. The a.c. input i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.

230V AC 50Hz

D.C Output

Step down transformer

Bridge Rectifier

Filter

Regulator

Fig: Power supply

5

It converts A. However.Transformer: Usually. a bridge rectifier is used because of its merits like good stability and full wave rectification. Therefore a regulator is applied at the output stage. Rectifier: The output from the transformer is fed to the rectifier. The first number 78 represents positive supply and the numbers 05. In this project. Output received from this filter is constant until the mains voltage and load is maintained constant. The rectifier may be a half wave or a full wave rectifier. 9V or 12V. This is done by a transformer. 12 represent the required output voltage levels. In order to obtain these voltage levels. a step down transformer is employed to decrease the voltage to a required level.C. Thus the a. 6 . voltage received at this point changes.e. Thus. into pulsating D. 230V is to be brought down to the required voltage level. Voltage regulator: As the name itself implies. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level.C.. It removes the ripples from the output of rectifier and smoothens the D.C. D. it regulates the input applied to it. 7805 and 7812 voltage regulators are to be used.c input available at the mains supply i.C. power supply of 5V and 12V are required. But these voltages cannot be obtained directly. DC voltages are required to operate various electronic equipment and these voltages are 5V. if either of the two is varied. Filter: Capacitive filter is used in this project. In this project.

In order to program the device. pin description of the microcontroller and the software tools used are discussed in the following sections. This microcontroller belongs to 8051 family. two timers. The features. AT89C51 is Flash type 8051. ROM. Proload tool has been used to burn the program onto the microcontroller. 8051 is available in different memory types such as UV-EPROM. The fixed amount of on-chip ROM. The microcontroller used in this project is AT89C51. 8051 is an 8-bit processor. A microcontroller has a CPU in addition to a fixed amount of RAM. The Intel 8051 is a Harvard architecture. 7 . one serial port and four ports (each 8-bits wide) all on a single chip. Flash and NV-RAM. single chip microcontroller (µC) which was developed by Intel in 1980 for use in embedded systems. This microcontroller had 128 bytes of RAM. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. meaning that the CPU can work on only 8 bits of data at a time. Atmel Corporation introduced this 89C51 microcontroller. but today it has largely been superseded by a vast range of enhanced devices with 8051-compatible processor cores that are manufactured by more than 20 ind ependent manufacturers including Atmel. I/O ports and a timer embedded all on a single chip. RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost and space are critical. 4K bytes of on-chip ROM.MICROCONTROLLERS: Microprocessors and microcontrollers are widely used in embedded systems products. It was popular in the 1980s and early 1990s. Infineon Technologies and Maxim Integrated Products. Microcontroller is a programmable device. The present project is implemented on Keil Uvision.

FEATURES OF AT89C51:  4K Bytes of Re-programmable Flash Memory.  RAM is 128 bytes.  Two-level Program Memory Lock.7V to 6V Operating Range.  Fully Static Operation: 0 Hz to 24 MHz.  Programmable Serial UART Channel.  128 x 8-bit Internal RAM.  Low-power Idle and Power-down Modes. 8 .  Two 16-bit Timer/Counters.  Six Interrupt Sources.  32 Programmable I/O Lines.  2.

which provides a highly flexible and costeffective solution to many embedded control applications. the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. 9 . In addition.Description: The AT89C51 is a low-voltage. the Atmel AT89C51 is a powerful microcomputer. By combining a versatile 8-bit CPU with Flash on a monolithic chip. serial port and interrupt system to continue functioning. timer/counters. The device is manufactured using Atmel¶s high density nonvolatile memory technology and is compatible with the industry-standard MCS51 instruction set. The power-down mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset. high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable memory. The Idle Mode stops the CPU while allowing the RAM.

Fig: Pin diagram 10 .

Fig: Block diagram 11 .

respectively. of an inverting amplifier that can be configured for use as an on-chip oscillator.PIN DESCRIPTION: Vcc Pin 40 provides supply voltage to the chip. XTAL2 should be left unconnected while XTAL1 is driven. GND Pin 20 is the ground. as shown in the below figure. as shown in Figure 11. To drive the device from an external clock source. The voltage source is +5V. There are no requirements on the duty cycle of the external clock signal. but minimum and maximum voltage high and low time specifications must be observed. since the input to the internal clocking circuitry is through a divide-by-two flip-flop. Fig: Oscillator Connections 12 . Either a quartz crystal or ceramic resonator may be used. XTAL1 and XTAL2 XTAL1 and XTAL2 are the input and output.

Upon applying a high pulse to this pin. 13 . This is often referred to as a power-on reset. the microcontroller will reset and terminate all the activities. C2 = 30 pF ± 10 pF for Crystals = 40 pF ± 10 pF for Ceramic Resonators Fig: External Clock Drive Configuration RESET Pin9 is the reset pin. It is an input and is active high.C1.

ALE (Address latch enable) This is an output pin and is active high. the EA pin is connected to Vcc. Port 0(P0) Port 0 is also designated as AD0-AD7. P1. the EA pin must be connected to GND to indicate that the code is stored externally. the pins of P0 must be connected to a 10Kohm pull-up resistor. 2 and 3 The four ports P0. It is an active low signal. making them 8-bit ports. ALE is used for demultiplexing address and data with the help of an internal latch. it provides data D0-D7. but when ALE=1. it has address A0-A7. Therefore. This is due to the fact that P0 is an open drain. If the code is stored on an external ROM. Ports 0. P2 and P3 each use 8 pins. In such cases. 1. allowing it to be used for both address and data. The 8051 family members all come with on-chip ROM to store programs. PSEN (Program store enable) This is an output pin. All the ports upon RESET are configured as input. since P0-P3 have value FFH on them. When ALE=0. When there is no external memory connection. ALE indicates if P0 has address or data. With external pull-up 14 .EA (External access) Pin 31 is EA. It is an input pin and must be connected to either Vcc or GND but it cannot be left unconnected.

While P0 provides the lower 8 bits via A0-A7. Port 3 Port 3 occupies a total of 8 pins. just like P1 and P2. Port 1 and Port 2 With no external memory connection. Port 3 has an additional function of providing some extremely important signals such as interrupts.resistors connected to P0. port 2 must be used along with P0 to provide the 16-bit address for the external memory. P3 does not need any pull-up resistors. it can be used as a simple I/O. it is the job of P2 to provide bits A8-A15 of the address. Upon reset. P2 and P3 are configured as input ports. With external memory connections. But the ports P1. It can be used as input or output. the same as port 1 and port 2. ports P1. P2 and P3 do not need any pull-up resistors since they already have pull-up resistors internally. pins 10 through 17. both P1 and P2 are used as simple I/O. Table: Port 3 Alternate Functions 15 . Port 2 is designated as A8-A15 indicating its dual function.

In the 8051 family. provides the clock source for the 8051 CPU.Machine cycle for the 8051 The CPU takes a certain number of clock cycles to execute an instruction. the calculation is made as 1/12 of the crystal frequency and its inverse is taken. The assembly language program is written and this program has to be dumped into the microcontroller for the hardware kit to function according to the software. Therefore. one machine cycle lasts 12 oscillator periods. The frequency can vary from 4 MHz to 30 MHz. 16 . The program dumped in the microcontroller is stored in the Flash memory in the microcontroller. depending upon the chip rating and manufacturer. The crystal oscillator. In the original version of 8051. along with on-chip circuitry. this Flash memory has to be programmed and is discussed in the next section. these clock cycles are referred to as machine cycles. Before that. But the exact frequency of 11. The length of the machine cycle depends on the frequency of the crystal oscillator. to calculate the machine cycle for the 8051.0592 MHz crystal oscillator is used to make the 8051 based system compatible with the serial port of the IBM PC.

PROGRAMMING THE FLASH The AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal.3. 17 . the entire memory must be erased using the Chip Erase Mode. The low-voltage programming mode provides a convenient way to program the AT89C51 inside the user¶s system. contents = FFH) and ready to be programmed. To program any nonblank byte in the on-chip Flash Memory. The respective top-side marking and device signature codes are listed in the following table. The AT89C51 is shipped with either the highvoltage or low-voltage programming mode enabled. The AT89C51 code memory array is programmed byte-byte in either programming mode. while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers.

5 ms. Raise EA/VPP to 12V for the high-voltage programming mode. 4. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. Activate the correct combination of control signals. The bytewrite cycle is self-timed and typically takes no more than 1. changing the address and data for the entire array or until the end of the object file is reached. 3. During a write cycle. an attempted read of the last byte written will result in the complement of the written datum on PO. Input the appropriate data byte on the data lines. Input the desired memory location on the address lines. 18 . Data Polling may begin any time after a write cycle has been initiated. and the next cycle may begin. the following steps should be considered: 1. true data are valid on all outputs. the address. Repeat steps 1 through 5. Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. Once the write cycle has been completed. 2. 5. data and control signals should be set up according to the Flash programming mode table.Programming Algorithm: Before programming the AT89C51. To program the AT89C51.7.

and 032H.6 and P 3.4 is pulled high again when programming is done to indicate READY.7 must be pulled to a logic low. P3. (030H) = 1EH indicates manufactured by Atmel (031H) = 51H indicates 89C51 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming 19 . except that P3. The values returned are as follows. 031H. P3. Chip Erase: The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The chip erase operation must be executed before the code memory can be re-programmed. The code array is written with all ³1´s. Reading the Signature Bytes: The signature bytes are read by the same procedure as a normal verification of locations 030H.4 is pulled low after ALE goes high during programming to indicate BUSY.Ready/Busy: The progress of byte programming can also be monitored by the RDY/BSY output signal.

The write operation cycle is self timed and once initiated.Programming Interface: Every code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. will automatically time itself to completion. Fig: Flash Programming Modes 20 . All major programming vendors offer worldwide support for the Atmel microcontroller series.

Fig: Programming the Flash 21 .

Fig: Verifying the Flash 22 .

a source is required. After compilation. that hex code has to be dumped into the microcontroller and this is done by the Proload. 23 . PROLOAD: Proload is a software which accepts only hex files. As the proload pr ogrammer kit requires power supply to be operated. Keil compiler also supports C language code. This microcontroller has a program in it written in such a way that it accepts the hex file from the keil compiler and dumps this hex file into the microcontroller which is to be programmed. the machine source code is converted into hex code which is to be dumped into the microcontroller for further processing. Proload is a programmer which itself contains a microcontroller in it other than the one which is to be programmed. this power supply is given from the power supply circuit designed above. Once the machine code is converted into hex code. It should be noted that this programmer kit contains a power supply section in the board itself but in order to switch on that power supply.4. Thus this is accomplished from the power supply board with an output of 12volts. SOFTWARES USED KEIL COMPILER: Keil compiler is a software used where the machine language code is written and compiled.

5. a voltage difference should exist between the LED terminals. Thus this ground value is provided by the microcontroller port pin. This can be achieved by writing an instruction ³CLR P1. first there should be a current flow through the LED. This current limiting resistor is connected to protect the port pins from sudden flow of high currents from the power supply. power supply and the negative terminal is connected to port pin through a current limiting resistor. To ensure the voltage difference between the terminals and as the positive terminal of LED is connected to power supply Vcc. With this. LED INTERFACING WITH THE MICROCONTROLLER LEDs are the most widely used input/output devices of the 8051. the port pin P1.0 is initialized to zero and thus now a voltage difference is established between the LED terminals and accordingly. Microcontroller port pins cannot drive these LEDs as these require high currents to switch on. current flows and therefore the LED glows. the negative terminal has to be connected to ground. 24 . LED and switches can be connected to any one of the four port pins. LED stands for Light Emitting Diode. In order to have a current flow. Thus in order to glow the LED.0´. Thus the positive terminal of LED is directly connected to Vcc.

0 Fig: LED Interfacing with the microcontroller In this project. 25 . motor running indication and the relay on condition. LEDS are used as the display units to indicate the level of the petrochemical liquid in the processor container which is to be purified.Vcc P1.

and precise inherent calibration make interfacing to readout or control circuitry especially easy. It converts temperature value into electrical signals. LM35 series sensors are precision integrated-circuit temperature sensors whose output voltage is linearly proportional to the Celsius temperature. This temperature value has to be sensed. it has very low self-heating. .1°C in still air. 26 . initially this temperature value has to be read and fed to the microcontroller.6. in order to monitor the temperature continuously and compare this with the set temperature preprogrammed in the microcontroller. linear output. 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. Thus a sensor has to be used and the sensor used in this project is LM35. It can be used with single power supplies. or with plus and minus supplies. SENSORS TEMPERATURE SENSOR (LM35): Precision Centigrade Temperature Sensor In this project. As it draws only 60 A from its supply. less than 0. The LM35 requires no external calibration since it is internally calibrated. The LM35¶s low output impedance.

Operates from 4 to 30 volts 8. Less than 60 A current drain 9.5°C accuracy guaranteed (at +25°C) 4. Rated for full í55° to +150°C range 5.1 W for 1 mA load The characteristic of this LM35 sensor is: For each degree of centigrade temperature it outputs 10milli volts. 0.Features 1. Low self-heating. 0.0 mV/°C scale factor 3. Low impedance output. Low cost due to wafer-level trimming 7. Linear + 10. 27 .08°C in still air 10. Calibrated directly in ° Celsius (Centigrade) 2. Suitable for remote applications 6. 0.

Thus the temperature sensor LM35 has to read the temperature continuously and the microcontrolle r has to compare this temperature value with the set temperature preprogrammed in it. sealed in a dry inertgas atmosphere within a glass capsule. The basic reed switch consists of two identical flattened ferromagnetic reeds. a buzzer indication is provided in the circuit to alert the people in the industry to stop the process immediately. thereby protecting the contact from contamination.ROLE OF LM35: In this project. The reeds are sealed in the capsule in such a way that their free ends overlap and are separated by a small air gap. the temperature is to be monitored continuously and if the temperature exceeds the set value preprogrammed in the microcontroller. Fig: Reed Switch 28 . the microcontroller sends an indication to the buzzer which gives a loud noise. MAGNETIC SENSORS OR REED SWITCHES: The reed switch is an electrical switch operated by an applied magnetic field. When this temperature exceeds the set value.

easier mounting. The stiffness of the reeds causes them to separate. thus completing an electrical circuit. 29 . REED SENSOR: A reed sensor is a device built using a reed switch with additional functionality like ability to withstand higher shock. closing when a magnetic field is present. etc. Good electrical contact is assured by plating a thin layer of precious metal over the flat contact portions of the reeds. A magnetic field from an electromagnet or a permanent magnet will cause the contacts to pull together. additional intelligent circuitry. In production. a metal reed is inserted in each end of a glass tube and the end of the tube heated so that it seals around a shank portion on the reed. when the magnetic field ceases. The hermetic sealing of a reed switch makes them suitable for use in explosive atmospheres where tiny sparks from conventional switches would constitute a hazard.The contacts may be normally open. The leads of the switch must be handled carefully to prevent breaking the glass envelope. or normally closed and opening when a magnetic field is applied. The glass used must have a high electrical resistance and must not contain volatile components such as lead oxide and fluorides. and open the circuit. so an infrared heat source can concentrate the heat in the small sealing zone of the glass tube. Infrared-absorbing glass is used. Since the contacts of the reed switch are sealed away from the atmosphere. The thermal coefficient of expansion of the glass material and metal parts must be similar to prevent breaking the glass-to-metal seal. they are protected against atmospheric corrosion.

Sensitivity is measured in units of Ampere-turns. particularly in the communications field. The overlapping ends of the reeds become opposite magnetic poles. These were formerly used in the keyboards for computer terminals. corresponding to the current in a coil multiplied by the number of turns. Speed sensors on bicycles use a reed switch to detect when the magnet on the wheel passes the sensor. where each key had a magnet and a reed switch actuated by depressing the key.How does a reed switch work? When a magnetic force is generated parallel to the reed switch. One important quality of the switch is its sensitivity. the reeds will be drawn together. Reed switches are commonly used in mechanical systems as proximity switches as well as in door and window sensors in burglar alarm systems and tamper proofing methods. If the magnetic force between the poles is strong enough to overcome the restoring force of the reeds. which attract each other. 30 . Uses: Reed switches are widely used for electrical circuit control. Typical pull-in sensitivities for commercial devices are in the 10 to 60 AT range. the reeds become flux carriers in the magnetic circuit. the amount of magnetic energy necessary to actuate it.

When the floating magnet comes in contact with any of the reed switches. Six reed switches are used in our project to indicate different levels of the petrochemical liquid in the process container. Reed switches are immune to electrostatic discharge (ESD) and do not require any external ESD protection circuits. 4. 31 . to as high as 120W. Free from contamination.Advantages: 1. and contact resistance is as low as 50 milliohms. They are hermetically sealed in glass environment. 5. The isolation resistance between the contacts is as high as 1015 ohms. When the reed switches are combined with magnets and coils. and are safe to use in harsh industrial and explosive environments. they can be used to form many different types of relays. 2. They can directly switch loads as low as a few microwatts without the help of external amplification circuits. 3. magnetic field will be generated and the reeds are drawn together and thus the reed switch is triggered and this change is applied to the microcontroller for further processing.

32 . REL A rel i an electricall S used in industrial controls. The relay allows the isolation of two separate sections of a system with two different voltage sources i. When the coil is not energi ed.e. the coil is energi ed. This causes the armature to be attracted to the coil. The armature¶s contact acts li e a switch and closes or opens the circuit. a magnetic field is created around the coil i.. controllable switch wi el automobiles and appliances. Inductor Fi Operation: Ci i symbol of a relay When current flows through the coil. There are all types of relays for all kinds of applications.7. a spring pulls the armature to its normal state of open or closed.e. a small amount of voltage/current on one side can handle a large amount of voltage/current on the other side but there is no chance that these twovoltages mi up..

In the NC type. There can be one or more contacts. 2. In choosing a relay. 33 . the contacts are closed when the coil is not energi ed. The above diagram shows how a si nal diode (eg 1N4148) is g connected across the relay coil to provide this protection. The diode is connected 'backwards' so that it will normally not conduct. Without the diode no current could flow and the coil would produce a damaging high voltage 'spike' in its attempt to keep the current flowing.Fi : Relay Operation and use of protection diodes Transistors and ICs must be protected from the brief high voltage 'spike' produced when the relay coil is switched off. SPDT (single pole double throw) and DPDT (double pole double throw) relays. different types like SPST (single pole single throw). Conduction occurs only when the relay coil is switched off.. The contacts can be normally open (NO) or normally closed (NC). i. the contacts are closed when the coil is energi ed.e. at this moment the current tries to flow continuously through the coil and it is safely diverted through the diode. In the NO type. the following characteristics need to be considered: 1.

This is in the range of a few volts to hundreds of volts. while the current can be from a few milliamps to 20milliamps. the microcontroller¶s pin can provide a maximum of 1-2milli amps current. while the current can be from a few amps to 40A or more. the relay takes 5V from the microcontroller and drives the loads which consume high currents. This minimum voltage is called the ³pull-in´ voltage. When the current flows through this coil. Thus when there is an input from the microcontroller to the relay. there will be a connection between the common terminal and normally closed pin. The voltage can vary from a few volts to 50 volts. it can drive the loads connected between the common terminal and normally open pin. the coil gets energized. depending on the relay. the relay will be switched on. a driver such as a power transistor is placed in between the microcontroller and the relay. this connection breaks and a new connection between the common terminal and normally open pin will be established. Thus when the relay is on. The voltage and current required to energize the coil. TRANSISTOR DRIVER CIRCUIT: An SPDT relay consists of five pins. 4. below which the coil will not be energized.3. For this reason. 34 . Initially when the coil is not energized. Thus the relay acts as an isolation device. The minimum DC/AC voltage and current that can be handled by the contacts. Digital systems and microcontroller pins lack sufficient current to drive the circuits like relays and buzzer which consume high powers. While the relay¶s coil needs around 10milli amps to be energized. two for the magnetic coil. one as the common terminal and the last pins as normally connected pin and normally closed pin. The relay has a minimum voltage. But when the coil is energized. Therefore.

35 . When the voltage at the pin P1. Thus when the voltage applied to the pin P1. P1.e.Vcc AT89C51 RELAY P1.e. P1..0=1 (>0.0=0 (<0.0 is low i.0 is high i. the transistor will be switched on and thus the relay will be ON and the load will be operated. The transistor will be switched on when the base to emitter voltage is greater than 0.0 GROUND The operation of this circuit is as follows: The input to the base of the transistor is applied from the microcontroller port pin P1. Thus the transistor acts like a current driver to operate the relay accordingly.7V) the transistor will be in off state and the relay will be OFF.0.7V)..7V (cut-in voltage).

0 36 .RELAY INTERFACING WITH THE MICROCONTROLLER: AT 89C51 DRIVER CIRCUIT RELAY LOAD P1.

They are used for writing different messages on a miniature LCD. In contrast. The ability to display numbers. LCD is finding wide spread use replacing LEDs (seven segment LEDs or other multi segment LEDs) because of the following reasons: 1. LIQUID CRYSTAL DISPLAY LCD stands for Liquid Crystal Display. These components are ³specialized´ for being used with the microcontrollers. This is in contrast to LEDs. 4. the LED must be refreshed by the CPU to keep displaying the data. which means that they cannot be activated by standard IC circuits. 3. Incorporation of a refreshing controller into the LCD. 2. thereby relieving the CPU of the task of refreshing the LCD. The declining prices of LCDs. which are limited to numbers and a few characters. characters and graphics. 37 . Ease of programming for characters and graphics.8.

It is based on the HD44780 microcontroller (Hitachi) and can display messages in two lines with 16 characters each. are considered as useful characteristics. mathematical symbols etc.A model described here is for its low price and great possibilities most frequently used in practice. punctuation marks. it is possible to display symbols that user makes up on its own. Pins Functions There are pins along one side of the small printed board used for connection to the microcontroller. Their function is described in the table below: 38 . appearance of the pointer. Automatic shifting message on display (shift left and right). It displays all the alphabets. backlight etc. There are total of 14 pins marked with numbers (16 in case the background light is built in). Greek letters. In addition.

39 . variable voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Each character consists of 5x7 dot matrix.Function Ground Power supply Contrast Pin Number 1 2 3 4 Name Vss Vdd Vee RS Control of operating 5 R/W 6 7 8 9 10 11 12 13 14 E D0 D1 D2 D3 D4 D5 D6 D7 Data / commands 0V +5V 0 . Contrast on display depends on the power supply voltage and whether messages are displayed in one or two lines. When used during operating. For that reason.Vdd D0 D7 are interpreted as 0 commands 1 D0 D7 are interpreted as data Write data (from controller to 0 LCD) 1 Read data (from LCD to controller) 0 Access to LCD disabled 1 Normal operating From 1 to Data/commands are transferred 0 to LCD 0/1 Bit 0 LSB 0/1 Bit 1 0/1 Bit 2 0/1 Bit 3 0/1 Bit 4 0/1 Bit 5 0/1 Bit 6 0/1 Bit 7 MSB Logic State - Description LCD screen: LCD screen consists of two lines with 16 characters each. a resistor for current limitation should be used (like with any LE diode). Some versions of displays have built in backlight (blue or green diodes).

Bits D0 . This address is either previously defined or the address of previously transferred character is automatically incremented. which depends on logic state on pin RS: RS = 1 .D7 are commands which determine display mode. List of commands which LCD recognizes are given in the table below: 40 .Bits D0 . Displaying position is determined by DDRAM address. RS = 0 . Built in processor addresses built in ³map of characters´ and displays corresponding symbols.D7 are addresses of characters that should be displayed.LCD Basic Commands: All data transferred to LCD through outputs D0-D7 will be interpreted as commands or as data.

64mS 1.Command Clear display Cursor home Entry mode set Display on/off control Cursor/Display Shift Function set Set CGRAM address Set DDRAM address Read ³BUSY´ flag (BF) Write to CGRAM or DDRAM Read from CGRAM or DDRAM I/D 1 = Increment (by 1) 0 = Decrement (by 1) S 1 = Display shift on 0 = Display shift off D 1 = Display on 0 = Display off U 1 = Cursor on 0 = Cursor off B 1 = Cursor blink on 0 = Cursor blink off RS RW D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 BF 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 I/D 0 0 1 D U 0 1 D/C R/L x 1 DL N F x CGRAM address DDRAM address DDRAM address 1 x S B x x Execution Time 1.64mS 40uS 40uS 40uS 40uS 40uS 40uS 40uS 40uS 0 D7 D6 D5 D4 D3 D2 D1 D0 1 D7 D6 D5 D4 D3 D2 D1 D0 R/L 1 = Shift right 0 = Shift left DL 1 = 8-bit interface 0 = 4-bit interface N 1 = Display in two lines 0 = Display in one line F 1 = Character format 5x10 dots 0 = Character format 5x7 dots D/C 1 = Display shift 0 = Cursor shift 41 .

display is ready to operate. Mainly but not always! If for any reason power supply voltage does not reach full value in the course of 10mS. After that. Character entry ID = 1 Addresses on display are automatically incremented by 1 S = 0 Display shift off Automatic reset is mainly performed without any problems. Display/Cursor on/off D = 0 Display off U = 0 Cursor off B = 0 Cursor blink off 4. The mode of operating is set by default. LCD is automatically cleared. display will 42 . This process lasts for approximately 15mS. Mode DL = 1 Communication through 8-bit interface N = 0 Messages are displayed in one line F = 0 Character font 5 x 8 dots 3. Display is cleared 2.LCD Initialization: Once the power supply is turned on. This means that: 1.

All left over to be done after that is to give basic commands and of course. Fig: Procedure on 8-bit initialization.start perform completely unpredictably. Algorithm according to the initialization is being performed depends on whether connection to the microcontroller is through 4. 43 . If voltage supply unit can not meet this condition or if it is needed to provide completely safe operating.or 8-bit interface. the process of initialization by which a new reset enabling display to operate normally must be applied.to display messages.

e. There may be a chance tha the tank may t overflow due to the excess addition of the petrochemical liquid. For this purpose. To avoid the manual operation. The motor takes more than one hour to fill the process container. we use AT89C51 Microcontroller to perform all these tasks. Before the advent of this project. This message will be displayed on the LCD display. Six reed switches (magnetic sensors) are used to indicate six different levels of the petrochemical liquid in the process container.. we developed a product which continuously checks the level of the petrochemical liquid and also monitors the temperature continuously. the four switches for four different levels and the last one to 44 .9. In this. The operation of this system starts when the raw material is to be dumped into the process container and the petrochemical based cleaning solutions are added to purify this raw material. One reed switch is to indicate the zero level i. reed switches are used to indicate the level of the petrochemical liquid in the process container. Initially. Thus now the process of transferring the raw material into the process container is carried on and also the petrochemical liquid is added to this process container in order to purify the raw material. This petrochemical liquid is pumped from tank to the process container by using an AC motor. the container is empty. an operator has to pay attention to the container to switch off the motor to avoid overflow of petrochemical. WORKING PROCEDURE The Project Petrochemical Level Indicator and Controller with Temperature Monitoring is an exclusive project that monitors and controls the level of the petrochemical liquid in the process container and also monitors the temperature continuously. The process container is of the capacity of 2000 liters. the pump will be in OFF condition if the process container is empty.

During this process. A floating magnet is provided in the process container which comes in contact with the different sensors based on the liquid level in the container. the magnet comes in contact with the last sensor and triggers it. when the container is empty. Thus a temperature sensor LM35 is used in this project.indicate the 100% level in the container. Once the tank is filled completely. initially this temperature has to be read. As the liquid level increases in the container. the microcontroller sends a signal to the relay to switch on the AC motor through the driver circuit and the process of transferring the raw material and the addition of the petrochemical liquid is carried on. LED array is provided in the circuit for the display indication of different levels of the petrochemical liquid in the container. the first sensor will be triggered and this output is given to the microcontroller. This LM35 senses the container temperature continuously and at any time if this temperature exceeds the set temperature. this magnet comes in contact with the different sensors and the corresponding level is displayed on the LCD display. In order to monitor the temperature. a buzzer indication is provided to alert the people in the industry to stop the process immediately to prevent any accidents during the purification process. even the temperature is monitored continuously. Now the microcontroller reads the output from this particular sensor and sends a signal to the relay to switch off the motor to avoid overflow of the tank. These sensors are fixed at the specified locations of the container. Reading this value. 45 . Thus.

and input switches. By adding some more simple logic.  The system is developed only for temperature monitor.10. SCOPE FOR ADVANCEMENTS:  In addition to LCD display. 46 . ADVANTAGES  Fit and forget system  Digital Level Display on 16X2 LCD  Temperature Monitoring  Magnetic Sensors  Free from floride and oxidization  Buzzer indication on abnormal temperature 11. temperature controller also can be implemented. LED bars can interface to the microcontroller for graphical read-out of the liquid level.

as they use petrochemical for cleaning of raw cotton. This project is best suitable for spinning mills.12.  This system can be used in Pharmaceutical industries.  This system is the best alternate system for domestic water level controller. 47 . Our project is Fit-and-Forget system. as in these industries also direct contact of level electrodes with the medicinal chemicals is not allowed. electrodes are to be cleaned once a week for proper functioning of the system. In this system. APPLICATIONS  This project is specially designed for Spoorthy spinning mill. Hyderabad.  This system is the best system for digital display indication for petrol in automotives. Present water level controllers suffer with fluoride and oxide layer formation. Jeedimetla.

ASSEMBLY INSTRUCTIONS  Check the components supplied in the Kit against the Component list and identify all the components. 48 . Adjust the 10K preset (near LCD) to correct contrast display level of LCD Replace R18 with a jumper wire if the buzzer could not be driven. Ensure the terminals of LM35 temperature sensors and solder in correct direction. For this.          Identify the terminals of transistors and solder them in correct direction.  It is generally best to solder the lowest height components first. if required. IC base. Ensure that the ac voltage to the kit is 12V. Solder the components in the following order:   Jumpers. Connect the LCD with the help of 16-pin male-female work-strip connector. Take care of terminals polarity while soldering diodes. use 230/12V step down transformer with 500mA or more current rating. transistors and other components. resistors. LEDs and electrolytic capacitors. diodes. Use flux cored lead to avoid dry solderability.  Use heat sink for voltage regulator. Inspect the solder points against dry solder / excess solder Now insert the preprogrammed microcontroller in the IC base firmly.13.

********** WK 203 **** **************************** *** .#MESG3B ACALL BACK 49 .********** PETRO CHEMICAL LEVEL INDICATOR AND CONTROLLER ********* .6 CLR P3.#MESG1 ACALL BACK MOV A.#81H ACALL COMN MOV DPTR.5 MOV DPTR.#MESG3A ACALL BACK MOV A.#COMM ACALL BACK1 MOV DPTR.#01H ACALL COMN MOV A.#0B0H ACALL COMN ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 MOV A.*********************************************************************** *** .#0C0H ACALL COMN MOV DPTR.**************************************** ********************************* * ORG 00H MOV P1.7 SETB P3..#07FH MOV P0.#0FFH CLR P3.

#80H ACALL COMN 50 .#MESG4 ACALL BACK ACALL PUMPOFF SETB P0.3 SETB P0.5 MOV A.#01H ACALL COMN MOV A.5 CLR P1.3 SETB P0. .#MESG6 ACALL BACK SETB P0. .4 SETB P0.#80H ACALL COMN MOV DPTR.2 SETB P0.4 SETB P0.#01H ACALL COMN MOV A. .#81H ACALL COMN MOV DPTR.0 MOV A.5 CLR P3.ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 ACALL DELAY1 . .1 SETB P0.2 SETB P0.0 SETB P0. .#01H ACALL COMN MOV A. MOV A.

LOOP5 CLR P0.3.5 MOV A.2 CLR P0.LOOP5 JNB P0.4 SETB P0.#MESG6 ACALL BACK MOV A.#8DH ACALL BACK MOV DPTR.#MESG11 ACALL BACK 51 .2.3 SETB P0.MOV DPTR.#70H ACALL COMN MOV DPTR.3.4 CLRP0.5 MOV A.4.0 SETB P0.1 SETB P0.#01H ACALL BACK MOV A.#8DH ACALL BACK MOV DPTR.2 CLR P0.#8DH ACALL BACK MOV DPTR.0 SETB P0.3 CLR P0.1 SETB P0.LOOP4 CLR P0.#01H ACALL COMN MOV A.#MESG10 ACALL BACK ACALL CHECK_PUMP LOOP4 : JB P1.#MESG6 ACALL BACK MOV A.#MESG9 ACALL BACK ACALL CHECK_PUMP LOOP3 : JB P1.LOOP4 JNB P0.

6.#MESG12 ACALL BACK ACALL CHECK_PUMP LOOP6 : JB P1.6.#80H ACALL COMN MOV DPTR.LOOP7 JNB P0.3 SETB P0.5 SETB P0.#01H ACALL COMN MOV A.#MESG6 ACALL BACK MOV A.6 LJMP LOOP1 CHECK_PUMP : JB P1.PUMPOFF PUMPON : MOV A.4 MOV A.5.LOOP8 SETB P3.#0C4H ACALL COMN 52 .1 SETB P0.4.#MESG7 ACALL BACK ACALL PUMPON LOOP7 : JB P3.0 MOV A.ACALL CHECK_PUMP LOOP5 : JNB P1.LOOP7 CLR P0.7 SETB P0.LOOP6 JB P0.0 SETB P0.LOOP6 CLR P0.5.#80H ACALL COMN MOV DPTR.4 SETB P3.5 SETB P1.0.#8DH ACALL BACK MOV DPTR.2 SETB P0.

2 CLR P3.0EH.84H.06.@A+DPTR JNZ FINISH ACALL FINISH ACALL DELAY DCR DPTR SJMP BACK FINISH : RET BACK FINISH1 COMN : RET : MOV P2.#255 HERE4 : DJNZ R7.01.7 MOV DPTR.#255 HERE3 : MOV R7.#255 : DJNZ R7.HERE4 DJNZ R6.2 CLR P3.CLR P0.#MESG8 ACALL BACK RET : CLR A MOVC A.#10 : MOV R7.4 ACALL DELAY CLR P3.4 RET DELAY HERE1 HERE2 : MOV R6.HERE3 RET COMM : DB 38H.HERE2 DJNZ R6.A CLR P3.0 53 .A SETB P3.3 RET DATAWRT : MOV P2.3 CLR P3.HERE1 RET DELAY1 : MOV R6.

0 : DB "LIQUID LEVEL".MESG1 MESG2 MESG3A MESG3B MESG4 MESG5 MESG6 MESG7 MESG8 MESG9 MESG10 MESG11 MESG12 : DB "WIN KIT".0 : DB " 80%".0 : DB "CONTAINER EMPTY".0 : DB "CONTAINER FULL".0 : DB "PUMP ON ".0 : DB " 40%".0 : DB "LEARNING IS FUN".0 : DB "PUMP OFF".0 : DB " 20%".0 END 54 .0 : DB "LEVEL INDICATOR".0 : DB "PETRO CHEMICAL".0 : DB " 60%".

This is the project that monitors and controls the level of the petrochemical liquid in the process container and also monitors the temperature continuously. The project ³89C51 BASED PETROCHEMICAL LEVEL INDICATOR AND CONTROLLER WITH TEMPERATURE MONITORING FOR SPINNING / COTTON PROCESS INDUSTRIES´ has been successfully designed and tested. using highly advanced IC¶s and with the help of growing technology the project has been successfully implemented.CONCLUSION In this project. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. The programming and interfacing of microcontroller has been mastered during the implementation. 55 . we have studied and implemented a complete model using a Microcontroller. Secondly. It has been developed by integrating features of all the hardware components used.

google.national.com 10.com 7. Electrikindia 6. Electronics for you 5.microsoftsearch. 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS BY MAZZIDI 3. www.com 56 .com 11. www. www.atmel. www.com 9. www.electronicprojects.geocities. Magazines 4.REFERENCE 1. EMBEDDED SYSTEM BY RAJ KAMAL 2. www.com 8.

Sign up to vote on this title
UsefulNot useful