Professional Documents
Culture Documents
On
AUTOMATIC INDUSTRIAL APPLIANCES CONTROL USING PC
CERTIFICATE OF RECOMENDATION
_______________________ _______________________
PROJECT GUIDE (Head of the Department)
Prof. R.R.Pandey (Department of E.C.E)
H.O.D (IE&IT)
(Dept. of E.C.E)
ACKNOWLEDGEMENT
Aamir Alamgir
Anurag Sharan
Krishna Kumar
Sumit Sumar Mandal
CONTENTS
MICROCONTROLLER :
A microcontroller (sometimes abbreviated µC, uC or MCU) is a small
computer on a single integrated circuit containing a processor core, memory, and
programmable input/output peripherals. Program memory in the form of NOR
flash or OTP ROM is also often included on chip, as well as a typically small
amount of RAM. Microcontrollers are designed for embedded applications, in
contrast to the microprocessors used in personal computers or other general
purpose applications.
Programming environments
Microcontrollers were originally programmed only in assembly language,
but various high-level programming languages are now also in common use to
target microcontrollers. These languages are either designed specially for the
purpose, or versions of general purpose languages such as the C programming
language. Compilers for general purpose languages will typically have some
restrictions as well as enhancements to better support the unique characteristics of
microcontrollers. Some microcontrollers have environments to aid developing
certain types of applications. Microcontroller vendors often make tools freely
available to make it easier to adopt their hardware.
Many microcontrollers are so quirky that they effectively require their own non-
standard dialects of C, such as SDCC for the 8051, which prevent using standard
tools (such as code libraries or static analysis tools) even for code
unrelated to hardware features. Interpreters are often used to hide such
low level quirks.
Interpreter firmware is also available for some microcontrollers. For example,
BASIC on the early microcontrollers Intel 8052 .BASIC and FORTH on the Zilog
Z8 as well as some modern devices. Typically these interpreters support interactive
programming
8051 MICROCONTROLLER
ARCHITECTURE:
Block diagram
The block diagram of the 8051 in the given figure shows all of the features unique
to microcontrollers :
Internal ROM and RAM.
I/O ports with programmable pins.
Timers And counters.
Serial data communication.
The figure also shows the usual CPU components-Program counter, ALU, working
registers, and clock circuits.
The 8051 architecture consists of these specific features :
Eight-bit CPU with registers A (the accumulator) and B
Sixteen-bit program counter(PC) and data pointer (DPTR)
Eight-bit program status word (PSW)
Eight-bit stack pointer(SP)
Internal Rom or EPROM(8751) of 0 (8031) to 4K(8051)
Internal RAM of 128 bytes :
Four register banks, each containing eight registers
Sixteen bytes, which may be addressed at the bit level
Eighty bytes of general-purpose data memory
Thirty-two input/output pins arranged as four 8-bit ports : P0-P3
Two 16-bit timer/counters : T0 & T1
Full duplex serial data receiver/transmitter ; SBUF
Control registers : TCON, TMOD, SCON, PCON, IP, & IE
Two external and three internal interrupt sources
Oscillator & clock circuits.
Block diagram
Fig- Block diagram of AT 89C51 micro controller
Pin Description :
VCC: pin-40
Supply voltage.
GND: pin-20
Ground.
ALE/PROG: pin-30
Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming. In normal operation ALE is emitted at a
constant rate of 1/6 the oscillator frequency, and may be used for external
timing or clocking purposes. Note, however, that one ALE
Pulse is skipped during each access to external Data Memory. If desired,
ALE operation can be disabled by setting bit 0 of SFR location 8EH. With
the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no
effect if the microcontroller is in external execution mode.
RESET: pin-09
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
Fig- .1 Power on reset circuit, .2 Power on reset with debounce
PSEN: pin-29
Program Store Enable is the read strobe to external program memory. When
the AT89C51 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are
skipped during each access to external data memory.
EA/VPP: pin-31
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at
0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA
will be internally latched on reset. EA should be strapped to VCC for
internal program executions. This pin also receives the 12-volt programming
enable voltage (VPP) during Flash programming, for parts that require 12-
volt VPP.
XTAL1: pin-19
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2: pin-18
Output from the inverting oscillator amplifier.
Idle Mode:
In idle mode, the CPU puts itself to sleep while all the on chip peripherals
remain active. The mode is invoked by software. The content of the on-chip
RAM and all the special functions registers remain unchanged during this
mode. The idle mode can be terminated by any enabled interrupt or by a
hardware reset. It should be noted that when idle is terminated by a hard
ware reset, the device normally resumes program execution, from where it
left off, up to two machine cycles before the internal reset algorithm takes
control. On-chip hardware inhibits access to internal RAM in this event, but
access to the port pins is not inhibited. To eliminate the possibility of an
unexpected write to a port pin when Idle is terminated by reset, the
instruction following the one that invokes Idle should not be one that writes
to a port pin or to external memory.
Programming Algorithm:
Before programming the AT89C51, the address, data and control signals
should be set up according to the Flash programming mode table. To
program the AT89C51, take the following steps.
1. Input the desired memory location on the address lines.
2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals.
4. Raise EA/VPP to 12V for the high-voltage programming mode.
5. Pulse ALE/PROG once to program a byte in the Flash array or the lock
bits. The byte-write cycle is self-timed and typically takes no more than 1.5
ms.
Repeat steps 1 through 5, changing the address and data for the entire array
or until the end of the object file is reached.
Data Polling: The AT89C51 features Data Polling to indicate the end of a
write cycle. During a write cycle, an attempted read of the last byte written
will result in the complement of the written datum on PO.7. Once the write
cycle has been completed, true data are valid on all outputs, and the next
cycle may begin. Data Polling may begin any time after a write cycle has
been initiated.
Program Verify: If lock bits LB1 and LB2 have not been programmed, the
programmed code data can be read back via the address and data lines for
verification. The lock bits cannot be verified directly. Verification of the
lock bits is achieved by observing that their features are enabled.
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 code array is written with all “1”s. The chip erase operation must be
executed before the code memory can be re-programmed.
Reading the Signature Bytes: The signature bytes are read by the same
procedure as a normal verification of locations 030H, 031H, and 032H,
except that P3.6 and P3.7 must be pulled to a logic low. The values returned
are as follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 51H indicates 89C51
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming
Fig- data transfer through Simplex, Half duplex and Full duplex
A protocol is a set of rules agreed by both the sender and receiver on; How
the data is packed .How many bits constitute a character When the data begins and
ends. Asynchronous serial data communication is widely used for character-
oriented transmissions; Each character is placed in between start and stop bits, this
is called framing. Block-oriented data transfers use the synchronous method. The
start bit is always one bit, but the stop bit can be one or two bits The start bit is
always a 0 (low) and the stop bit(s) is 1 (high)
Fig-
SBUF is an 8-bit register used solely for serial communication. For a byte
data to be transferred via the TxD line, it must be placed in the SBUF Register.
The moment a byte is written into SBUF, it is framed with the start and stop bits
and transferred serially via the TxD line SBUF holds the byte of data when it is
received by 8051 RxD line. When the bits are received serially via RxD, the 8051
de-frames it by eliminating the stop and start bits, making a byte out of the data
received, and then placing it in SBUF
Block Diagram:
viewer
///////////////////////////////////// Polarizer
_____________________________________ glass
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Liquid Crystal
_____________________________________ glass
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Polarizer
Backlight
Figure : Cross Section of a Simple LCD Display
________________________________________
| |
| IC IC | Source/Column ICs
| | |
| | |
|IC---------------------Pixel |
| |
|IC <---- Gate Line/Row IC |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* An IC driver will address a number of row/column lines and not just the single
pixel in the diagram above
Polarizers are an integral part of a LCD display, possessing the unique property of
only passing light if it is oriented in a specific (oriented) direction. To utilize this
phenomenon in TN LC displays, the bottom polarizer orients incoming light in one
direction. The oriented light passes through the LC material and is either unaltered
or "bent" 90 degrees. Depending on the orientation of the top polarizer, this light
will either pass through or be diffused. If the light is diffused, it will appear as a
dark area. Figure 3 is a simple illustration of the sequence of events that occur
when light passes through a simple twisted nematic LC display.
LCD CONNECTION AND CONTROLING:
Fig- Solder a 8 Pin connector to the Data pins and wires to the others
There are 16 pins in all. They are numbered from left to right 1 to 16 (if you are
reading from the backside).
Pin 1 and 2 are the power supply pins. They need to be connected to the negative
rail and the positive rail of a +5v power supply respectively. To get a stable +5v
Power supply, you can use a 7805 voltage regulator. It will regulate any voltage
that you give it into +5v.
Pin 3 is the contrast setting pin. It is said that it must be connected to a
potentiometer to control the contrast. However, we have found that it work if you
just connect a variable resistor in series with it to GND. The lower the resistance,
the greater the contrast. I recommend setting it at around 1.5K – 2K.
If you set the value too low or short the pin directly to ground, you will see
only dark boxes on the screen. As far as I know, doing this does not have any
adverse affect on the LCD.
The RS Pin : The LCD has basically two operating modes : Instruction mode and
Character Mode. Depending on the status of this pin , the data on the 8 data pins
(D0-D7) is treated as either an instruction or as character data. You have to activate
the command mode if you want to give a Instruction to the LCD. Example – “Clear
the display” , “Move cursor to home” etc. You have to activate the character mode
if you want to tell the LCD to display some character.
To set the LCD in Instruction mode , you set the 4th pin of the LCD (R/S) to
GND. To put it in character mode , you connect it to Vcc.
The Enable Pin : The enable pin has a very simple function. It is just the clock
input for the LCD. The instruction or the character data at the data pins (D0-D7) is
processed by the LCD on the falling edge of this pin. The Enable pin should be
normally held at Vcc by a pull up resistor. When a momentary button switch is
pressed , the Pin goes low and back to high again when you leave the switch. Your
instruction or character will be executed on the falling edge of the pulse. (ie. The
moment the switch closes)
The RW Pin : Generally , we always use the LCD to show things on the screen.
However , in some cases , we may need to read from the LCD what it is
displaying. In such cases, the R/W pin is used. For all practical purposes , the R/W
pin has to be permanently connected to GND.
Pins 7 to 14 are the Data pins of the LCD. Pin 7 is the Least Significant Bit (LSB)
and pin 14 is the Most Significant Bit (MSB) of the data inputs. If you want to
display some number or letter on the display, you have to input the appropriate
‘codes’ for that character on these pins. These pins are also used for giving certain
commands to the display like clearing the display or moving the cursor to a
different location. Upon giving the correct signals to the 3 control pins, the
character codes or the commands that you have given to the Data pins will be
written to the display or executed by the LCD respectively. To make it easier to
give the appropriate inputs to these pins, I recommend wiring up a DIP switch to
these pins.
Pins 15 and 16: Most LCDs have a backlight. A backlight is a light within the
LCD panel which makes seeing the characters on screen easier. When you leave
your cell phone or mp3 player untouched for some time, the screen goes ‘dark’.
That is the backlight turning off. It is possible to use the LCD without the backlight
as well. Many LCDs come without a backlight. If your LCD has only 14 pins, then
it has no backlight. However, the working of the LCD still remains the same even
if your LCD doesn’t have a backlight. The Backlight is nothing but an LED. So , a
resistor must be connected in series with it to limit the current. This link mentions
that the allowable current is 100ma. Then it is best to have a variable resistor (or a
transistor) and adjust the current till it is around 90 ma.
Now, your LCD is in instruction mode and is ready to accept any instruction
that we issue to it. Now, set the DIP switches as 00001111. This instruction tells it
to turn on the display and show a blinking cursor. Once, you have set the DIP
switch to 00001111, press the Enable momentary Button. You should be seeing a
blinking cursor on the screen now. This means that your LCD is initialized and
ready to accept characters to display.
Ok , once you have got the cursor blinking , the LCD will now accept character
data to display. Now , we have to put the LCD in character mode to make it accept
characters to display. Press the RS switch to make it ‘under pressed ’. Now set the
DIP switches to 01000001 and then press the Enable button. If everything has gone
right , then you should be seeing a capital A on the screen. But what if you want to
display some other letter , like “M”? The procedure is the same , you only replace
the 01000001 with the code for M , which is 01001101. The LCD automatically
increments the cursor position by 1 everytime you write a character.
After you write to the last location of the first line , you would expect the LCD to
automatically jump to the second line. Sadly , it doesnt happen so. Using the
second line is slightly more tricky.
Table- Instruction Set for the LCD
Regulated power supply 5V and 12V :
The power supply section is the important one. It should deliver constant output
regulated power supply for successful working of the project. A 0-12V/500 mA
transformer is used for this purpose. The primary of this transformer is connected
in to main supply through on/off switch& fuse for protecting from overload and
short circuit protection. The secondary is connected to the diodes to convert 12V
AC to 12V DC voltage. And filtered by the capacitors ,Which is further regulated
to +5v, by using IC 7805.This circuit can give +5V output at about 150 mA
current, but it can be increased to 1 A when good cooling is added to 7805
regulator chip. The circuit has over overload and terminal protected. The capacitors
must have enough high voltage rating to safely handle the input voltage feed to
circuit.
CIRCUIT DIAGRAM:
There are two ICs LM7805 and LM7812 used in the power supply.
LM 7805 :
The IC LM7805 is connected through the capacitor in the circuit for giving +5V
supply. Initially 230 V AC supply is reduced to (0-9V) with the help of a step
down transformer having a capacity of 500mA. Since the input voltage to the
regulator IC should be more than its output voltage, transformer secondary voltage
is 9V. This low voltage is rectified with the help of bridge rectifier. The ripples are
minimized with the help of capacitor filter to get a smooth DC supply. The rating
of the chosen capacitor filter is1000µF.
The regulated DC voltage is obtained by using a regulator IC 7805. In the case of
IC 7805, the unregulated DC voltage is applied to Pin 1, and the output is taken at
Pin 3 and Pin 2 is grounded. Another capacitor filter of rating 10µF is connected at
the output of regulator IC to eliminate the voltage oscillations at the output due to
the large voltage oscillations at the input of the regulator.The pin diagram of
LM7805 is shown below-
1. Unregulated voltage in
2. Ground
3. Regulated voltage out
LM 7812:
The IC LM7812 is used as second IC for obtaining a voltage of +12V from the
circuit. The voltage is necessary for the stepper motor operation. Initially 230 V
AC supply is reduced to (15V-0-15V) with the help of a step down transformer
having a capacity of 1A and the center tap of the transformer is grounded. This low
voltage is rectified with the help of bridge rectifier. Since the input voltage to the
regulator IC should be more than its output voltage, transformer secondary voltage
is 15V-0-15V.The ripples are minimized with the help of capacitor filter to get a
smooth DC supply. The rating of the chosen capacitor filter is 1000µF.
The regulated DC output voltage is obtained by using regulator ICs. For regulated
+12V DC supply, IC 7812 is used and for regulated -12V DC supply, IC 7912 is
used.
FUTURE WORK :
REFERENCE :
BOOKS REFERRED
Schade, O. H.: “Analysis of Rectifier Operation”, proc. IRE, vol.31, pp. 341-
361, July, 1943.
WEBSITES
www.8051.com
www.8051microcontroller.com
www.8051faq.com.
www.microchip.com
www.etext.org