4. First of all I would like to thank almighty GOD who has given this wonderful gift of life to
us. He is the one who is guiding us in right direction to follow noble path of humanity. In
my Six weeks industrial training it is a wonderful experience to be a part of Beri Institute
of Technology. Where I got the opportunity to work under brilliant minds. I owe my deep
regards for the supporting and kind staff authorities who are helping me in my lean patches
during these six weeks. The knowledge I am gaining through out my studies have the
practical implementation during this period. I am grateful to all the staff of BIT and for
their timely support and sharing of their experience with me. I would like to express my
heartiest concern for Er. Bikram Beri for his able guidance and for his inspiring attitude,
praiseworthy attitude and honest support. Not to forget the pain staking efforts of our
college training and placement cell and specially my training and placement officer
Mr………….. Last but not the least I would express my utmost regards for the ECE
department of our Institute.
4
5. Beri Institute of Technologies(BIT) is an organization which is established in the
field of Computer hardware sporte, Network training and Embedded systems. We provide
Support and training in the field of networking solutions (LINUX) and embedded
systems (Micro controller based design, Electronics system design).
BIT also provide Technical Research & Development support and consultancy to some
Electronics companies.
THEIR TEAM
Presently they have a strong technical team of certified professionals for catering to these
solutions and have presence in Abohar and Punjab. They have skilled team of engineers
who are experienced in design, programming.
Support Area (network solutions)
a) LINUX / UNIX networks
b) Radio Links
c) Security Solutions
Design Services (Embedded systems)
a) AVR family
b) MCS 51
c) ELECTRONIC SYSTEM DESIGN
5
8. 1) Difference between microprocessors and microcontrollers
2) Disadvantages of processors over controllers
2) Embedded System using microcontrollers
Embedded System
Characteristics
History of 8051
Architecture
Pin configuration
AT89s52
• Block Diagram
• Features
• Pin description
On chip peripherals
• Interrupts
• Serial communication
• Timer and counter
Advantages of C over Assembly language
Off chip peripherals
• LCD (JHD162A)
• RTC(DS12887)
• ADC(ADC 0804)
• 8255PPI
8
9. Interfacing LCD to AT89s52
Serial communication B/W AT89s52 & PC
Interfacing of ADC(0804) with AT89s52 Microcontroller
Interfacing of RTC with AT89s52 Microcontroller
Interfacing of 8255 with AT89s52 Microcontroller
9
10. DIFFERENCE BETWEEN MICROPROCESSORS AND
MICROCONTROLLERS
• A Microprocessor is a general purpose digital computer central
processing unit(C.P.U) popularly known as CPU on the chip.
The Microprocessors contain no RAM, no ROM, and no I/P O/P
ports on the chip itself.
• On the other hand a Microcontroller has a
C.P.U(microprocessor) in addition to a fixed amount of RAM,
ROM, I/O ports and a timer all on a single chip.
• In order to make a Microprocessor functional we must add
RAM, ROM, I/O Ports and timers externally to them,ie any
amount of external memory can be added to it.
• But in controllers there is a fixed amount of memory which
makes them ideal for many applications.
• The Microprocessors have many operational codes(opcodes) for
moving data from external memory to the C.P.U
• Whereas Microcontrollers may have one or two operational
codes.
10
11. DISADVANTAGES OF PROCESSORS OVER
CONTROLLERS
• System designed using Microprocessors are bulky
• They are expensive than Microcontrollers
• We need to add some external devices such as PPI chip,
Memory, Timer/counter chip, Interrupt controller chip,etc. to
make it functional.
11
12. EMBEDDED SYSTEMS
An embedded system:
• Employs a combination of software & hardware to perform a specific function.
• Is a part of a larger system which may not be a “computer”.
• Works in a reactive & time constrained environment.
CHARACTERISTICS:
Single functioned
• Executes a single program, repeatedly.
Tightly-constrained
• Low power, low cost, small, fast etc.
Reactive & real time
• Continually reacts to the changes in the system’s environment.
• Must compute certain result in real-time without delay
Tools Used for Embedded System:
For Assembly Language:-
• 8051 Assembler cum Simulator
12
13. • ISP-Flash Programmer Version 3.0a -Hex File Downloader (Machine code gets
burned in controller) -
For C Language:-
• Programming Environment- Programmers Notepad 2
• Small Device C Compiler
• ISP-Flash Programmer Version 3.0a -Hex File Downloader (Machine code gets
burned in controller)
Embedded System Applications:-
• Consumer electronics, e.g., cameras, cell phones etc.
• Consumer products, e.g. washers, microwave ovens etc.
• Automobiles (anti-lock braking, engine control etc.)
• Industrial process controller & defense applications.
• Computer/Communication products, e.g. printers, FAX machines etc.
• Medical Equipments.
• ATMs
• Aircrafts
• elevators
MICROCONTROLLERS
History of 8051
13
14. Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981 this controller
had 128 bytes of RAM, 4k bytes of on chip ROM, two timers, one serial port, and four
ports all are on single chip. The 8051 is an 8 bit processor, meaning that the CPU can
work on only 8 bit data at a time. Data larger than 8 bits broken into 8 bit pieces to be
processed by CPU. It has for I/O 8 bit wide.
Features of the 8051:-
Feature Quantity
ROM 4K bytes
RAM 128 bytes
Timer 2
I/O pins 32
Serial port 1
Interrupt sources 6
8051 Architecture Overview
The 8051 family is one of the most common microcontroller architectures used
worldwide.8051 based microcontrollers are offered in hundreds of variants from many
different silicon manufacturers.
The 8051 is based on an 8-bit CISC core with Harvard architecture. It's an 8-bit CPU,
optimized for control applications with extensive Boolean processing (single-bit logic
capabilities), 64K program and data memory address space and various on-chip
peripherals.
The 8051 microcontroller family offers developers a wide variety of high-integration and
Cost-effective solutions for virtually every basic embedded control application. From
traffic control equipment to input devices and computer networking products, 8051
microcontrollers deliver high performance together with a choice of configurations and
options matched to the special needs of each application. Whether it's low power
operation, higher frequency performance, expanded on-chip RAM, or an application-
specific requirement, there's a version of the 8051 microcontroller that's right for the job.
When it's time to upgrade product features and functionality, the 8051 architecture puts
14
15. you on the first step of a smooth and cost-effective upgrade path - to the enhanced
performance of the 151 and 251 microcontrollers
15
18. Description of ports
There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the
ports upon RESET are configured as output, ready to be used as output ports. To use any
of these ports as an input port, it must be programmed.
Port 0:- Port 0 occupies a total of 8 pins (pins 32-39) .It can be used for input or output.
To use the pins of port 0 as both input and output ports, each pin must be connected
externally to a 10K ohm pull-up resistor. This is due to the fact that P0 is an open drain,
unlike P1, P2, and P3.Open drain is a term used for MOS chips in the same way that open
collector is used for TTL chips. With external pull-up resistors connected upon reset, port
0 is configured as an output port. For example, the following code will continuously send
out to port 0 the alternating values 55H and AAH.
MOV A, #55H
BACK: MOV P0, A
ACALL DELAY
CAPL A
SJMP BACK
Port 0 as input: - With resistors connected to port 0, in order to make it an input, the port
must be programmed by writing 1 to all the bits. In the following code, port 0 is configured
first as an input port by writing 1's to it, and then data is received from the port and sent to
P1.
18
19. MOV A, #0FFH ; A = FF hex
MOV P0, A ; make P0 an input port
BACK: MOV A, P0 ; get data from P0
MOV P1, A ; send it to port 1
SJMP BACK
Dual Role of Port 0:-Port 0 is also designated as AD0-AD7, allowing it to be used for
both address and data. When connecting an 8051/31 to an external memory, port 0
provides both address and data. The 8051 multiplexes address and data through port 0 to
save pins. ALE indicates if P0 has address or data. When ALE = 0, it provides data D0-D7,
but when ALE =1 it has address and data with the help of a 74LS373 latch.
Port 1:- Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or
output. In contrast to port 0, this port does not need any pull-up resistors since it already
has pull-up resistors internally. Upon reset, Port 1 is configured as an output port. For
example, the following code will continuously send out to port1 the alternating values
19
20. 55h & AAh
MOV A, #55H; A = 55 hex
BACK: MOV P1, A; send it to Port 1
ACALL DELAY ; call delay routine
CPL A; make A=0
SJMP BACK
Port 1 as input:-To make port1 an input port, it must programmed as such by writing 1 to
all its bits. In the following code port1 is configured first as an input port by writing 1’s to
it, then data is received from the port and saved in R7 ,R6 & R5.
MOV A, #0FFH ; A=FF HEX
MOV P1, A ; make P1 an input port by writing all 1’s to it
MOV A, P1 ; get data from P1
MOV R7, A ; save it in register R7
ACALL DELAY ; wait
MOV A, P1 ; get another data from P1
MOV R6, A ; save it in register R6
ACALL DELAY ; wait
MOV A, P1 ; get another data from
20
21. MOV R5, A ; save it in register R5
Port 2:-Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or output.
Just like P1, P2 does not need any pull-up resistors since it already has pull-up resistors
internally. Upon reset, Port 2 is configured as an output port. For example, the following
code will send out continuously to port 2 the alternating values 55h and AAH. That is all
the bits of port 2 toggle continuously.
MOV A, #55H ; A = 55 hex
BACK: MOV P2, A ; send it to Port 2
ACALL DELAY ; call delay routine
CPL A ; make A=0
SJMP BACK
Port 2 as input: - To make port 2 an input, it must programmed as such by writing 1 to all
its bits. In the following code, port 2 is configured first as an input port by writing 1’s to it.
Then data is received from that port and is sent to P1 continuously.
MOV A, #0FFH ; A=FF hex
MOV P2, A ; make P2 an input port by writing all 1’s to it
BACK: MOV A, P2 ; get data from P2
MOV P1, A ; send it to Port1
SJMP BACK ; keep doing that
Dual role of port 2:- In systems based on the 8751, 8951, and DS5000, P2 is used as
simple I/O. However, in 8031-based systems, port 2 must be used along with P0 to provide
the 16-bit address for the external memory. As shown in pin configuration 8051, port 2 is
also designed as A8-A15, indicating the dual function. Since an 8031 is capable of
21
22. accessing 64K bytes of external memory, it needs a path for the 16 bits of the address.
While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of
the address. In other words, when 8031 is connected to external memory, P2 is used for the
upper 8 bits of the 16 bit address, and it cannot be used for I/O.
Port 3:- port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or
output. P3 does not need any pull-up resistors, the same as P1 and P2 did not. Although
port 3 is configured as an output port upon reset. Port 3 has the additional function of
providing some extremely important signals such as interrupts. This information applies
both 8051 and 8031 chips. There functions are as follows:-
P3.0 and P3.1 are used for the RxD and TxD serial communications signals. Bits P3.2
and P3.3 are set aside for external interrupts. Bits P3.4 and P3.5 are used for timers 0 and
1. Finally P3.6 and P3.7 are used to provide the WR and RD signals of external memories
connected in 8031 based systems.
22
23. Single bit addressability of ports:-
There are times that we need to access only 1 or 2 bits of the port instead of the entire 8
bits. A powerful feature of 8051 I/O ports is their capability to access individual bits of the
port without altering the rest of the bits in that port.
For example, the following code toggles the bit p1.2 continuously.
BACK: CPL P1.2 ; complement p1.2 only
ACALL DELAY
SJMP BACK
Notice that P1.2 is the third bit of P1, since the first bit is P1.0, the second bit is P1.1,
and so on. Notices in example of those unused portions of port1 are undisturbed. Table
bellow shows the bits of 8051 I/O ports. This single bit addressability of I/O ports is one of
the features of the 8051 microcontroller.
23
24. AT89s52
AT89S52 is an ATMEL controller with the core of Intel MCS-51. It has same pin
configuration as give above.
The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with
8K bytes of Downloadable Flash programmable and erasable read only memory
and 2K bytes of EEPROM. The device is manufactured using Atmel’s high density
nonvolatile memory technology and is compatible with the industry standard
80C51 instruction set and pin out. The on-chip Downloadable Flash allows the
24
25. program memory to be reprogrammed in-system through an SPI serial interface or
by a conventional nonvolatile memory programmer. By combining a versatile 8-bit
CPU with Downloadable Flash on a monolithic chip, the Atmel AT89S52 is a
powerful microcomputer which provides a highly flexible and cost effective solution
to many embedded control applications. The AT89S52 provides the following
standard features: 8K bytes of Downloadable Flash, 2K bytes of EEPROM, 256
bytes of RAM, 32 I/O lines, programmable watchdog timer, two Data Pointers,
three 16-bit timer/counters, a six-vector two-level interrupt, a full duplex serial port,
on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with
static logic for operation down to zero frequency and supports two software
selectable power saving modes. The Idle Mode stops the CPU while allowing the
RAM, timer/counters, serial port, and interrupt system to continue functioning. The
Power down Mode saves the RAM contents but freezes the oscillator, disabling all
other chip functions until the next interrupt or hardware reset.
The Downloadable Flash can be changed a single byte at a time and is accessible
through the SPI serial interface. Holding RESET active forces the SPI
bus into a serial programming interface and allows the program memory to be
written to or read from unless Lock Bit 2 has been activated.
Features
• Compatible with MCS-51™Products
• 8K bytes of In-System Reprogrammable Downloadable Flash Memory
- SPI Serial Interface for Program Downloading
- Endurance: 1,000 Write/Erase Cycles
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33 MHz
• Three-Level Program Memory Lock
• 256 x 8 bit Internal RAM
• 32 Programmable I/O Lines
• Three 16 bit Timer/Counters
• Eight Interrupt Sources
25
26. • Full Duplex UART Serial Channel
• Low Power Idle and Power Down Modes
• Interrupt Recovery From Power Down Mode
• Watchdog Timer
• Dual Data Pointer
• Power off Flag
RST
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
ALE/PROG
Address Latch Enable is an 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.
PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89S8252 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
26
27. 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 when 12-volt programming is selected
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2
Output from the inverting oscillator amplifier.
Circuit representing external crystal
27
28. Timer and counter description
Timer 0 and 1:
Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer
1 in the AT89C51, AT89C52 and “Timer/Counters.”
Timer 2:
Timer 2 is a 16 bit Timer/Counter that can operate as either a timer or an event
counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown
in Table 2). Timer 2 has three operating modes: capture, auto-reload (up or down
counting), and baud rate generator. The modes are selected by bits in T2CON, as
shown in Table 8. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the
Timer function, the TL2 register is incremented every machine cycle. Since a
machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the
oscillator frequency. In the Counter function, the register is incremented in
28
29. response to a 1-to-0 transition at its corresponding external input pin, T2. In this
function, the external input is sampled during S5P2 of every machine cycle. When
the samples show a high in one cycle and a low in the next cycle, the count is
incremented. The new count value appears in the register during S3P1 of the
cycle following the one in which the transition was detected. Since two machine
cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the
maximum count rate is 1/24 of the oscillator frequency. To ensure that a given
level is sampled at least once before it changes, the level should be held for at
least one full machine cycle
Interrupts:
The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and
INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt.
Each of these interrupt sources can be individually enabled or disabled by setting
or clearing a bit in Special Function Register IE. IE also contains a global disable
bit, EA, which disables all interrupts at once. In the AT89C51, bit position IE.5 is
also unimplemented.
29
30. User software should not write 1s to these bit positions, since they may be used in
future AT89 products. Timer 2 interrupt is generated by the logical OR of bits TF2
and EXF2 in register T2CON. Neither of these flags is cleared by hardware
when the service routine is vectored to. In fact, the service routine may have to
determine whether it was TF2 or EXF2 that generated the interrupt, and that bit
will have to be cleared in software. The Timer 0 and Timer 1 flags, TF0 and TFI,
are set at S5P2 of the cycle in which the timers overflow. The values are then
polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at
S2P2 and is polled in the same cycle in which the timer overflows.
Interrupt Registers:
30
31. The global interrupt enable bit and the individual interrupt enable bits are in the IE
register. In addition, the individual interrupt enable bit for the SPI is in the SPCR
register. Two priorities can be set for each of the six
interrupt sources in the IP register.
CODE FOR INTERRUPTS
#include<at89s8252.h>
void en_int(void);
void delay(unsigned int i);
void main (void)
{
P1=0x00;
INT0=0;
en_int();
}
void en_int(void)
{
EA=1;
EX0=1;
}
void isr_intr (void) interrupt 0
{
if(INT0==0)
{
while(1)
31
32. {
P1_0=1;
delay(1000000);
delay(1000000);
delay(1000000);
delay(1000000);
P1_0=0;
delay(1000000);
delay(1000000);
delay(1000000);
delay(1000000);
}
}
}
void delay(unsigned int i)
{
while(i!=0)
{
i--;
}
}
Advantages of C over Assembly language programming
• Knowledge of the processor instruction set is not required.
• Details like register allocation and addressing of memory and data is
managed by the compiler.
• Programs get a formal structure and can be divided into separate functions.
32
33. • Programming and program test time is drastically reduced, this increases
efficiency.
• Keywords and operational functions can be used that come closer to how
humans think.
• The supplied and supported C libraries contain many standard routines such
as numeric conversions.
• Reusable code: Existing program parts can be more easily included into new
programs, because of the comfortable modular program construction
techniques.
• The C language based on the ANSI standard is very portable. Existing
programs can be quickly adapted to other processors as needed.
Interfacing to LCD Display
On most displays, the pins are numbered on the LCD’s printed circuit board, but if
not, it is quit easy to locate pin1. Since the pin is connected to ground, it often has
a thicker p.c.b. track connected to it, and it is generally connected to the metal
work at some point.
The function of each of the connections is shown in the table below:-
33
34. Pins 1 & 2 are the power supply lines, Vss & Vdd. The Vdd pin should be connected
to the positive supply & Vss to the 0V supply or ground.
Although the LCD module data sheets specify 5V D.C. supply (at only a few
milliamps), supplies of 6V & 4.5V both work well, and even 3V is sufficient for some
modules. Consequently, these modules can be effectively and economically powered
by batteries.
Pin 3 is a control pin, Vee, which is used to alter the contrast of the display. Ideally,
these pin should be connected to a variable voltage supply. A preset potentiometer
connected between the power supply lines, with its wiper connected to the contrast
pin is suitable in many cases, but be aware that some modules may require a
negative potential; as low as 7V in some cases. For absolute simplicity, connecting
this pin to 0V will often suffice.
Pin 4 is register select (RS) line.
PIN NO. NAME FUNCTION
1 Vss Ground
2 Vdd +ve supply
3 Vee contrast
4 RS Register select
5 R/W Read/Write
6 E Enable
7 D0 Data Bit 0
8 D1 Data Bit 1
9 D2 Data Bit 2
10 D3 Data Bit 3
11 D4 Data Bit 4
12 D5 Data Bit 5
13 D6 Data Bit 6
14 D7 Data Bit 7
34
35. Three command control inputs. When this line is low, data bytes transferred to
the display are treated as commands, and data bytes read from the display
indicate its status. By setting the RS line high, character data can be
transferred to and from the module.
Pin 5 is (R/W) line. This line is pulled low in order to write commands or
character data to the module, or pulled high to read character data or status
information from its registers.
Pin 6 is Enable (E) line. This input is used to initiate the actual transfer of
commands or character data between the module and the data lines. When
writing to the display, data is transferred only on the high to low transition of
this signal. However, when reading from the display, data will become
available shortly after the low to high transition and remain available until the
signal falls low again.
Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to
and from the display, either as a single 8-bit byte or as two 4-bit “nibbles”. In
the latter case, only the upper four data lines (D4 to D7) are used. This $-bit
mode is beneficial when using a microcontroller, as fewer I/O lines are
required.
35
36. CODE FOR INTERFACING OF LCD WITH AT89S52 MICROCONTROLLER
#include<at89s8252.h>
#define lcdprt P0
#define rs P1_2
#define en P1_3
void delay(unsigned int i);
36
41. display('o');
delay(0xffff);}
}
CODE FOR SERIAL PORT COMMUNICATION IN TRANSMIT MODE
#include<at89s8252.h>
void init_sit(void)
{TMOD=0x00;
TMOD=0x20;
41
42. SCON=0x40;
TR1=1;
TH1=0xfd;
}
void transmit_serial(unsigned int a)
{int i;
TI=0;
for(i=0xffff;i>=0;i--);
SBUF=a;
}
void main(void)
{init_sit();
transmit_serial(0x01);}
CODE FOR SERIAL PORT COMMUNICATION IN RECEIVE MODE
#include<at89s8252.h>
void init_sit(void)
{TMOD=0x00;
TMOD=0x20;
42
43. SCON=0x50;
TR1=1;
TH1=0xfd;
}
unsigned int receive(void)
{int i;
RI=0;
for(i=0xffff;i>=0;i--);
return SBUF;
}
void main(void)
{int e;
init_lcd();
clear_lcd();
init_sit();
e=receive();
display(e);
}
82C55A FUNCTIONAL DESCRIPTION
The 82C55A is a programmable peripheral interface device designed for use in Intel
microcomputer systems.
Its function is that of a general purpose I/O component to interface peripheral equipment to
the microcomputer system bus. The functional configuration of the 82C55A is
43
44. programmed by the system software so that normally no external logic is necessary to
interface peripheral devices or structures
Pin Diagram
Data Bus Buffer
This 3-state bidirectional 8-bit buffer is used to interface the 82C55A to the system data
bus. Data is transmitted or received by the buffer upon execution of input or output
instructions by the CPU. Control words and status information are also transferred through
the data bus buffer.
Read/Write and Control Logic
The function of this block is to manage all of the internal and external transfers of both
Data and Control or Status words. It accepts inputs from the CPU Address and Control
busses and in turn, issues commands to both of the Control Groups.
44
45. Ports A, B, and C
The 82C55A contains three 8-bit ports (A, B, and C). All can be configured in a wide
variety of functional characteristics by the system software but each has its
Port A:
One 8-bit data output latch/buffer and one 8-bit input latch buffer. Both “pull-up'' and “pull
down'' buses hold devices are present on Port A.
Port B:
One 8-bit data input/output latch/buffer. Only “pull-up'' bus hold devices are present on
Port B.
Port C:
One 8-bit data output latch/buffer and one 8-bit data input buffer (no latch for input). This
port can be divided into two 4-bit ports under the mode control. Each 4-bit port contains a
4-bit latch and it can be used for the control signal outputs and status signal inputs in
conjunction with ports A and B. Only ``pull-up'' bus hold devices are present
45
46. RESET is kept low to make all the ports the output ports. To do this, the pin is
connected to the pin of controller as shown and the pin is then made to 1 and then
to 0.
PA, PB, PC become output ports.
It has four registers Pa, Pb, Pc, CW
00, 01, 10, 11
46
47. ADC0804
8-Bit μP Compatible D/A Converters with 8-
Channel
The ADC0804 family is CMOS 8-Bit, successive-approximation A/D converters
which use a modified potentiometric ladder and are designed to operate with the
8080A control bus via three-state outputs. These converters appear to the
processor as memory locations or I/O ports, and hence no interfacing logic is
required. The differential analog voltage input has good common mode- rejection
47
48. and permits offsetting the analog zero-input voltage value. In addition, the voltage
reference input can be adjusted to allow encoding any smaller analog voltage
span to the full 8 bits of resolution.
Features
• 80C48 and 80C80/85 Bus Compatible - No Interfacing Logic Required
• Conversion Time < 100s
• Easy Interface to Most Microprocessors
• Differential Analog Voltage Inputs
• TTL Compatible Inputs and Outputs
• On-Chip Clock Generator
• 0V to 5V Analog Voltage Input Range (Single + 5V Supply)
• No Zero-Adjust Required
PIN DIAGRAM
48
50. When interfacing is being done then gets lowered then only it allows the
controller to read the data, otherwise controller can not read the data.
is always grounded.
is software controlled.
CODE FOR INTERFACING OF ADC(0804) WITH AT89S52
MICROCONTROLLER
#include<at89s8252.h>
#define lcdprt P0
#define rs P1_2
#define en P1_3
unsigned char read_adc(void);
unsigned char display_dec(unsigned char i);
void init_sit(void);
void transmit_serial(unsigned int a);
void delay(unsigned int i);
void lcd_cmd(unsigned char a);
void display(unsigned char b);
void wait(void);
void init_lcd(void);
void clear_lcd(void);
void cursor_position(unsigned char c);
void disp_hex(unsigned char digit);
void disp_dec(unsigned int digit);
void shift(void);
code unsigned char
lkup_tb101[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
//LCD ROUTINES//
void lcd_cmd(unsigned char a)
{
wait();
50
56. Real Time Clock
The DS12887 is real-time clocks (RTCs). The devices provide a real-time
clock/calendar, one time-of-day alarm, three maskable interrupts with a common
interrupt output, a programmable square wave, and 114 bytes of battery backed
static. The DS12887 integrates a quartz crystal and lithium energy source into a
24-pin encapsulated DIP package. The DS12C887 adds a century byte at
address 32h. For all devices, the date at the end of the month is automatically
adjusted for months with fewer than 31 days, including correction for leap years.
The devices also operate in either 24-hour or 12-hour format with an AM/PM
indicator. A precision temperature-compensated circuit monitors the status of
Vcc. If a primary power failure is detected, the device automatically switches to a
backup supply. A lithium coin-cell battery can be connected to the VBAT input pin
on the DS12885 to maintain time and date operation when primary power is
absent. The device is accessed through a multiplexed byte-wide interface, which
supports both Intel and Motorola mode
56
57. Pin diagram
Features
♦ RTC Counts Seconds, Minutes, Hours, Day, Date, Month, and Year with Leap
Year Compensation Through 2099
♦ Binary or BCD Time Representation
♦ 12-Hour or 24-Hour Clock with AM and PM in 12-Hour Mode
♦ Daylight Saving Time Option
♦ Interfaced with Software as 128 RAM Locations
♦ 14 Bytes of Clock and Control Registers
57
58. ♦ 114 Bytes of General-Purpose, Battery-Backed RAM (113 Bytes in the
DS12C887 and DS12C887A)
♦ Time-of-Day Alarm Once Per Second to Once Per Day
♦ Periodic Rates from 122μs to 500ms
♦ Programmable Square-Wave Output
♦ Automatic Power-Fail Detect and Switch Circuitry
♦ Optional 28-Pin PLCC Surface Mount Package or 32-Pin TQFP (DS12885
♦ Optional Encapsulated DIP (EDIP) Package with Integrated Crystal and Battery
(DS12887, DS12887A, DS12C887, DS12C887A)
♦ Optional Industrial Temperature Range Available
♦ Underwriters Laboratory (UL) Recognized
FOR REGISTER ra (To control RTC functions for some settings)
UIP DV2 DV1 DV0 RS3 RS2 RS1 RS0
0 0 1 0 0 0 0 0
To initially start the oscillator.
ra=0x20
FOR REGISTER rb (To control RTC functions for some settings)
SET PIE AIE UIE SQWE DM 24/12 DSE
1 0 0 0 0 0 0 0
DM=0(BCD)
=1(HEXADECIMAL)
Square Wave
Alarm Interrupt Enable
Periodic Interrupt Enab
58
65. Detailed description of training project:
For easy understanding I have divide my project into four sections:
Regulated
power
supply
Microcontroller DC Motor drive
AT89S52
LCD display Conveyor belt
application
(I) POWER SUPPLY SECTION:
Initial stage of every electronic circuit is power supply system which provides required
power to drive the whole system. The specification of power supply depends on the power
requirement and this requirement is determined by its rating. The main components used in
supply system are:
(i) transformer
(ii) rectifier
65
66. (iii) input filter
(iv) regulator
(v) output filter
(vi) output indication
(i) Transformer:
The main source of power supply is a transformer. The maximum output
power of power supply is dependent on maximum output power of transformer .We
determine power from its current and voltage rating. e.g.: if there is a transformer of 12V,
500mA then maximum power delivered by transformer is 6Watt.
It means we can drive a load from this transformer up to 6w. In our project our maximum
power requirement is 1watt. So to provide this power we use 12V/250mA transformer. The
maximum output power of this transformer is 4watt.it means it can easily drive load up to
4 watt.
(ii) Rectifier:
Rectifier is a circuit which is used to convert ac to dc. Every electronic
circuit requires a dc power supply for rectification. We have used four diodes.
(iii) Input filter:
After rectification we obtain dc supply from ac but it is not pure dc it may
have some ac ripples .To reduce these ripples we use filters. It comprises of two filters –
low frequency ripple filter and high frequency ripple filter. To reduce low frequency
ripples we use electrolytic capacitor. The voltage rating of capacitor must be double from
incoming dc supply. It blocks dc and passes ripples to ground.
(iv) Regulator:
Regulator is a device which provides constant output voltage with
varying input voltage. There are two types of regulators-
(a) Fixed voltage regulator
(b) Adjustable regulator
We have used fixed voltage regulator LM78XX last two digits signify output voltage. The
voltage for our system is 5V that is why we have used 7805 regulator which provides 5V
from 12V dc.
(v) Output filter:
It is used to filter out output ripple if any.
(vi) Output indication:
We use LED to observe the functioning of our system. If the LED
glows it confirms proper functioning of our supply.
(III) MICROCONTROLLER AND DISPLAY SECTION:
We are all familiar with the term microcontroller and even have
studied it as part of our curriculum but the question is why we use microcontroller?
66
67. Well, we use microcontroller to control our hardware using programs which we make
according to our requirement. We have used MCS51 family microcontroller AT89S52. We
have interfaced LCD with microcontroller to display the working action of our drive. We
have connected LCD on port1 and we control the drive action of motor from port2. RS
(P3.3) and EN (P3.4) pin of LCD are connected to port 3. Detailed description of
interfacing of LCD with microcontroller has been explained in earlier section in detail.
(IV) DC MOTOR DRIVE SECTION:
We use dc motor drive to control direction of dc motor. it means at
particular time it will move in forward motion and at another particular time it will move
in backward direction. The timing of this circuit is controlled by microcontroller. To
operate dc motor we require dc voltage. When we give positive voltage to positive
terminal and negative voltage to negative terminal it moves clockwise i.e. forward
direction and when we give positive voltage to negative terminal and negative voltage to
positive terminal the motor moves in anticlockwise direction i.e. backward/reverse
direction. This voltage is provided to the motor through drive section which comprises of
transistors. The switching action of these transistors is controlled by microcontroller. We
have used four NPN transistors (BC547). Since the out put power of BC547 that is the
transistor is not sufficient to drive motor that is why we use a Darlington pair package
TIP127 (PNP) and TIP122 (NPN) with BC547 to increase the incoming power from the
emitter of BC547. Hence sufficient power from TIP122 and TIP127 is easily provided to
motor. in our circuit transistor Q1,Q2,Q3,Q4 provide Vcc to motor and Q5,Q6,Q7,Q8
provide ground to motor.
WORKIN ACTION OF TRANSISTOR:
When we give a base voltage to Q1 and Q8 they are set to on
position. Q1 provide Vcc and Q8 provide ground to DC motor and in this case motor
moves clock wise. Q4 and Q7 are in off position. Similarly when we set Q4 and Q7 in on
position Q4 provide Vcc to motor and Q7 provide ground to motor. This configuration is
opposite to previous configuration and in this case motor moves anti clock wise. since we
have used silicon transistor the need minimum .7 volt dc to get on and we are providing
5volt as base voltage from microcontroller.
(IV) CONVEYOR BELT APPLICATION USING DC MOTOR:
Our project is a small model which depicts the transportation of
goods from one place to another in production plant in industry.
C CODING FOR CONTROLLING DRIVE ACCORDING TO APPLICATION
# include<at89s8252.h>
#define LCDPRT P1
#define RS P3_3
#define EN P3_4
void lcd_cmd(unsigned char a);
code unsigned char name_arry[]={"forward$"};
code unsigned char name_arry1[]={"backward$"};
67