SlideShare una empresa de Scribd logo
1 de 71
Descargar para leer sin conexión
RADIANT INSTITUTE OF ENGINEERING AND
            TECHNOLOGY
              ABOHAR


                          SUBMITTED BY:
                          NAME: Gurwinder Singh
                          Branch : ECE
                     Roll No.: 100930420230




                 1
2
3
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
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
6
7
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
 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
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
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
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
•   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
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
you on the first step of a smooth and cost-effective upgrade path - to the enhanced
performance of the 151 and 251 microcontrollers




                                            15
16
Pin configuration of 8051




           17
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
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
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
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
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
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
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
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
• 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
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
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
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
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
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
{
    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
•    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
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
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
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
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);
    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();
    lcdprt=a;
    rs=0;
    en=1; en=0;
    }
    void init_lcd(void)
    {
         lcd_cmd(0x3c);
    lcd_cmd(0x0c);
    lcd_cmd(0x06);
    lcd_cmd(0x01);
}
        void clear_lcd(void)
{
lcd_cmd(0x01);
}
void display(unsigned char b)
{
                                                              37
wait();
lcdprt=b;
rs=1;
en=1;
en=0;
}
void wait(void)
{unsigned int count=300;
while(count!=0)
{count--;
}
}
void cursor_position(unsigned char c)
{lcd_cmd(c+0x80);
}
void disp_hex(unsigned char digit)
{unsigned char temp;
temp=digit>>4;
display(lkup_tb101[temp])
temp=(digit&0x0f);
display(lkup_tb101[temp]);
}
void disp_dec(unsigned int digit)
{unsigned int temp;
if (digit<100)
{temp=digit/10;
display(lkup_tb101[temp]);
temp=digit-temp*10;
display(lkup_tb101[temp]);
}
if(digit>99&&digit<1000)
                                        38
{temp=digit/100;
display(lkup_tb101[temp]);
digit=digit-(temp*100);
temp=digit/10;
display(lkup_tb101[temp]);
digit=digit-(temp*10);
temp=digit;
display(lkup_tb101[temp]);
}
if(digit>99&&digit<10000)
{temp=digit/100;
display(lkup_tb101[temp]);
digit=digit-(temp*1000);
temp=digit/100;
display(lkup_tb101[temp]);
digit=digit-(temp*100);
temp=digit/10;
display(lkup_tb101[temp]);
digit=digit-(temp*10);
temp=digit;
display(lkup_tb101[temp]);
}
if(digit>10000)
{temp=digit/10000;
display(lkup_tb101[temp]);
digit=digit-(temp*10000);
temp=digit/1000;
display(lkup_tb101[temp]);
digit=digit-(temp*1000);
temp=digit/100;
display(lkup_tb101[temp]);
                             39
digit=digit-(temp*100);
temp=digit/10;
display(lkup_tb101[temp]);
digit=digit-(temp*10);
temp=digit;
display(lkup_tb101[temp]);
        }}
void delay(unsigned int i)
{
while(i!=0)
{
i--;
}
                      }
void main(void)
{
while(1)
{init_lcd();
cursor_position(0x00);
display('h');
delay(0xffff);
cursor_position(0x01);
display('e');
delay(0xffff);
        cursor_position(0x02);
display('l');
delay(0xffff);
                 cursor_position(0x03);
display('l');
delay(0xffff);
                 cursor_position(0x04);
                                          40
display('o');
                delay(0xffff);}
                }




       CODE FOR SERIAL PORT COMMUNICATION IN TRANSMIT MODE


       #include<at89s8252.h>
       void init_sit(void)
       {TMOD=0x00;
       TMOD=0x20;
                                   41
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
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
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
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
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
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
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 < 100s
• 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
49
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
lcdprt=a;
      rs=0;
      en=1; en=0;
      }
      void init_lcd(void)
{
    lcd_cmd(0x3c);
                lcd_cmd(0x0c);
                lcd_cmd(0x06);
                lcd_cmd(0x01);
     }
          void clear_lcd(void)
            {
            lcd_cmd(0x01);
            }


            void display(unsigned char b)
            {
             wait();
             lcdprt=b;
             rs=1;
             en=1;
             en=0;
             }
             void wait(void)
             {unsigned int count=300;
             while(count!=0)
             {count--;




                                        51
}


    }
                  void shift(void)
                  {
                  lcd_cmd(0x1c);
                  }
                  void cursor_position(unsigned char c)
                  {lcd_cmd(c+0x80);
                   }
                   void disp_hex(unsigned char digit)
                   {unsigned char temp;
                   temp=digit>>4;
                   display(lkup_tb101[temp]);
                   temp=(digit&0x0f);
                   display(lkup_tb101[temp]);
                   }
                   void disp_dec(unsigned int digit)
                   {unsigned int temp,temp1,temp2;
                   if (digit<100)
                   {temp1=digit/10;
                   display(lkup_tb101[temp1]);


                  temp2=digit-temp1*10;
                   display(lkup_tb101[temp2]);
                   transmit_serial(temp1*10+temp2);}
                   if(digit>99&&digit<1000)
                   {temp=digit/100;


display(lkup_tb101[temp]);
        digit=digit-(temp*100);
                                              52
temp=digit/10;
display(lkup_tb101[temp]);
digit=digit-(temp*10);
temp=digit;
display(lkup_tb101[temp]);
}


if(digit>99&&digit<10000)
{temp=digit/100;
display(lkup_tb101[temp]);
digit=digit-(temp*1000);
temp=digit/100;
display(lkup_tb101[temp]);
digit=digit-(temp*100);
temp=digit/10;
display(lkup_tb101[temp]);
digit=digit-(temp*10);
temp=digit;
display(lkup_tb101[temp]);
}




if(digit>10000)
{temp=digit/10000;
display(lkup_tb101[temp]);


digit=digit-(temp*10000);
temp=digit/1000;
display(lkup_tb101[temp]);
digit=digit-(temp*1000);
temp=digit/100;
                            53
display(lkup_tb101[temp]);
                    digit=digit-(temp*100);
                    temp=digit/10;
                    display(lkup_tb101[temp]);
                    digit=digit-(temp*10);
                    temp=digit;
                    display(lkup_tb101[temp]);


                    }}
                    void delay(unsigned int i)
                    {
                    while(i!=0)
                    {
                    i--;
                    }
                    }
    void init_sit(void)
        {TMOD=0x00;
        TMOD=0x20;
        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)
                                                 54
{
unsigned int e;
P2=0xff;
init_lcd();
init_sit();
while(1)
{
e=read_adc();
cursor_position(0x00);
delay(0xffff);
disp_dec(e);
}
}
unsigned char read_adc(void)
{unsigned char n;
P1_0=0;                        // SOC=0
P1_0=1;                        // SOC=1
while(P1_1==1)                 //while( EOC==1)
{n=P2;
}
return(n);
}




                                          55
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
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
♦ 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
To Update Set Bit is 1

                         rb=0x80




                                   59
CODE FOR INTERFACING OF RTC (DS12887) WITH ATs52
MICROCONTROLLER
#include<at89s8252.h>
#define LCDPRT P2
#define RS P1_2
#define EN P1_3
void bcdconv(unsigned int mb);
void T0M2delay_rtc(void);
void init_rtc(void);
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);

struct rtc
{
 unsigned char second;
 unsigned char sa;
 unsigned char minute;
 unsigned char ma;
 unsigned char hours;
 unsigned char ha;
 unsigned char dow;
 unsigned char dom;
 unsigned char month;
 unsigned char years;
 unsigned char ra;
 unsigned char rb;
 unsigned char rc;
 unsigned char rd;

};
xdata at 0x0000 struct rtc ds12887;
void main(void)
{
                                      60
unsigned int x;
unsigned char sec;
unsigned char hr;
unsigned char min
Init_lcd();
for(x=0;x<10000;x++)
T0M2delay_rtc();
ds12887.ra=0x20;
ds12887.rb=0x81;
ds12887.second=0x55;
ds12887.minute=0x25;
ds12887.hours=0x09;
ds12887.dom=0x19;
ds12887.month=0x10;
ds12887.years=0x06;
ds12887.rb=0x03;


while(1)
{
 sec=ds12887.second;
cursor_position(0x00);
bcdconv(sec);
cursor_position(0x02);
display(':');
min=ds12887.minute;
cursor_position(0x03);
bcdconv(min);
cursor_position(0x05);
display(':');
 hr=ds12887.hours;
 cursor_position(0x06);
  bcdconv(hr);
cursor_position(0x40);
display('s');
cursor_position(0x42);
display(':');
cursor_position(0x43);
display('m');
cursor_position(0x45);
display(':');
cursor_position(0x46);
display('h');

}
}
                          61
void bcdconv(unsigned int mb)

{
unsigned int x;
unsigned int y;
x=mb&0x0f;
x=x|0x30;
y=mb&0xf0;
y=y>>4;
y=y|0x30;
display(y);
display(x);
}
void T0M2delay_rtc(void)
{
TMOD=TMOD&0xf0;
TMOD=TMOD|0x02;
TH0=0xEC; // 236 decimal value load in THO
TR0=1;
if(TF0==1)
{
 TR0=0;
 TF0=0;
 }
}
void lcd_cmd(unsigned char a)
 {
 wait ();
 LCDPRT=a;
 RS=0;
 EN=1;
 EN=0;
 }
  void display(unsigned char b)
  {
  wait ();
  LCDPRT=b;
  RS=1;
  EN=1;
  EN=0;
  }

 void wait(void)
  {
   unsigned int count=300;
   while(count!=0)
                                     62
{
    count--;
    }

}


 void Init_lcd(void)
 {
 lcd_cmd(0x3c);
 lcd_cmd(0x0c);
 lcd_cmd(0x06);
 lcd_cmd(0x01);
 }
 void clear_lcd(void)
{
   lcd_cmd(0x01);
 }



    void cursor_position(unsigned char c)
    {
    lcd_cmd(c+0x80);
    }




                                            63
64
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
(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
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
code unsigned char name_arry2[]={"stop     $"};

bit flag;
unsigned char sec;

void drive(void);
void display_string(unsigned char *sp);
void display_string1(unsigned char *pp);
void display_string2(unsigned char *tp);
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 main(void)
{
P2=0x00;
Init_lcd();
 drive();

 }
 void drive(void)
 {
 while(1)
{


 P2=0x00;
   cursor_position(0x00);
 display_string2(&name_arry2);
  delay(0xffff);
  delay(0xffff);
  delay(0xffff);
  delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);

 P2=0x05;

 cursor_position(0x00);
 display_string(&name_arry);
 delay(0xffff);
                                           68
P2=0x00;

 cursor_position(0x00);
 display_string2(&name_arry2);
 delay(0xffff);
 delay(0xffff);
 delay(0xffff);
 delay(0xffff);
  delay(0xffff);
 delay(0xffff);
 delay(0xffff);

 P2=0x0a;

 cursor_position(0x00);
 display_string1(&name_arry1);
 delay(0xffff);


 }
 }

void display_string(unsigned char *sp)

      {
       while(*sp!='$')
     {

         display(*sp);

          sp=sp+1;
         }
     }


void display_string1(unsigned char *pp)

      {
       while(*pp!='$')
     {

         display(*pp);

         pp=pp+1;
         }
                                          69
}


          void display_string2(unsigned char *tp)

    {
     while(*tp!='$')
   {

       display(*tp);

       tp=tp+1;
       }
   }

void lcd_cmd(unsigned char a)
 {
 wait ();
 LCDPRT=a;
 RS=0;
 EN=1;
 EN=0;
 }
  void display(unsigned char b)
  {
  wait ();
  LCDPRT=b;
  RS=1;
  EN=1;
  EN=0;
  }
   void wait(void)
   {
    unsigned int count=300;
    while(count!=0)
    {
    count--;
    }

 }
 void Init_lcd(void)
 {
 lcd_cmd(0x3c);
 lcd_cmd(0x0c);
 lcd_cmd(0x06);
 lcd_cmd(0x01);
                                             70
}
 void clear_lcd(void)
{
   lcd_cmd(0x01);
 }

void delay (unsigned int i)
  {
  while (i!=0)
  {
   i--;
   }
}
    void cursor_position(unsigned char c)
    {
    lcd_cmd(c+0x80);
    }




                                            71

Más contenido relacionado

La actualidad más candente

8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller featuresTech_MX
 
8051 microcontroller introduction
8051 microcontroller introduction8051 microcontroller introduction
8051 microcontroller introductionANJUSHA R
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller NotesDr.YNM
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051Anil Maurya
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontrollermuneer.k
 
Microcontroller from basic_to_advanced
Microcontroller from basic_to_advancedMicrocontroller from basic_to_advanced
Microcontroller from basic_to_advancedImran Sheikh
 
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )Tarun Khaneja
 
Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11gajani121
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller pptRahul Kumar
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller Gaurav Verma
 
Atmel and pic microcontroller
Atmel and pic microcontrollerAtmel and pic microcontroller
Atmel and pic microcontrollerTearsome Llantada
 

La actualidad más candente (20)

At89s52
At89s52At89s52
At89s52
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
8051 microcontrollers
8051 microcontrollers8051 microcontrollers
8051 microcontrollers
 
Question Bank microcontroller 8051
Question Bank microcontroller 8051Question Bank microcontroller 8051
Question Bank microcontroller 8051
 
8051 microcontroller introduction
8051 microcontroller introduction8051 microcontroller introduction
8051 microcontroller introduction
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
89s52 2
89s52 289s52 2
89s52 2
 
PIC_ARM_AVR
PIC_ARM_AVRPIC_ARM_AVR
PIC_ARM_AVR
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
Microcontroller from basic_to_advanced
Microcontroller from basic_to_advancedMicrocontroller from basic_to_advanced
Microcontroller from basic_to_advanced
 
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
 
Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
1 8051 microcontroller intr
1 8051 microcontroller intr1 8051 microcontroller intr
1 8051 microcontroller intr
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
Atmel and pic microcontroller
Atmel and pic microcontrollerAtmel and pic microcontroller
Atmel and pic microcontroller
 

Similar a Embedded training report(mcs 51)

INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxMeghdeepSingh
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf818Farida
 
Embedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerEmbedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerAmandeep Alag
 
Embeded system by Mitesh Kumar
Embeded system by Mitesh KumarEmbeded system by Mitesh Kumar
Embeded system by Mitesh KumarMitesh Kumar
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)Sahil Gupta
 
embedded system and microcontroller
 embedded system and microcontroller embedded system and microcontroller
embedded system and microcontrollerSHILPA Sillobhargav
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERAnkita Jaiswal
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
PRESENTATION OF MICROCONTROLLER
PRESENTATION OF MICROCONTROLLERPRESENTATION OF MICROCONTROLLER
PRESENTATION OF MICROCONTROLLERAviSharma63
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...Arti Parab Academics
 
btech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxbtech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxSKWriters
 

Similar a Embedded training report(mcs 51) (20)

INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
 
Embedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerEmbedded systems, 8051 microcontroller
Embedded systems, 8051 microcontroller
 
Embeded system by Mitesh Kumar
Embeded system by Mitesh KumarEmbeded system by Mitesh Kumar
Embeded system by Mitesh Kumar
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)
 
002079
002079002079
002079
 
embedded system
embedded systemembedded system
embedded system
 
embedded system and microcontroller
 embedded system and microcontroller embedded system and microcontroller
embedded system and microcontroller
 
Module 1.pdf
Module 1.pdfModule 1.pdf
Module 1.pdf
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
 
embedded system bye Sj
embedded system bye Sjembedded system bye Sj
embedded system bye Sj
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLER
 
Uc1(vii sem)
Uc1(vii sem)Uc1(vii sem)
Uc1(vii sem)
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
unit-2.pptx
unit-2.pptxunit-2.pptx
unit-2.pptx
 
PRESENTATION OF MICROCONTROLLER
PRESENTATION OF MICROCONTROLLERPRESENTATION OF MICROCONTROLLER
PRESENTATION OF MICROCONTROLLER
 
Ppt embedded
Ppt embeddedPpt embedded
Ppt embedded
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
 
btech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxbtech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptx
 

Último

Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 

Último (20)

Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 

Embedded training report(mcs 51)

  • 1. RADIANT INSTITUTE OF ENGINEERING AND TECHNOLOGY ABOHAR SUBMITTED BY: NAME: Gurwinder Singh Branch : ECE Roll No.: 100930420230 1
  • 2. 2
  • 3. 3
  • 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
  • 6. 6
  • 7. 7
  • 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
  • 16. 16
  • 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
  • 37. 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); 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(); lcdprt=a; rs=0; en=1; en=0; } void init_lcd(void) { lcd_cmd(0x3c); lcd_cmd(0x0c); lcd_cmd(0x06); lcd_cmd(0x01); } void clear_lcd(void) { lcd_cmd(0x01); } void display(unsigned char b) { 37
  • 38. wait(); lcdprt=b; rs=1; en=1; en=0; } void wait(void) {unsigned int count=300; while(count!=0) {count--; } } void cursor_position(unsigned char c) {lcd_cmd(c+0x80); } void disp_hex(unsigned char digit) {unsigned char temp; temp=digit>>4; display(lkup_tb101[temp]) temp=(digit&0x0f); display(lkup_tb101[temp]); } void disp_dec(unsigned int digit) {unsigned int temp; if (digit<100) {temp=digit/10; display(lkup_tb101[temp]); temp=digit-temp*10; display(lkup_tb101[temp]); } if(digit>99&&digit<1000) 38
  • 40. digit=digit-(temp*100); temp=digit/10; display(lkup_tb101[temp]); digit=digit-(temp*10); temp=digit; display(lkup_tb101[temp]); }} void delay(unsigned int i) { while(i!=0) { i--; } } void main(void) { while(1) {init_lcd(); cursor_position(0x00); display('h'); delay(0xffff); cursor_position(0x01); display('e'); delay(0xffff); cursor_position(0x02); display('l'); delay(0xffff); cursor_position(0x03); display('l'); delay(0xffff); cursor_position(0x04); 40
  • 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 < 100s • 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
  • 49. 49
  • 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
  • 51. lcdprt=a; rs=0; en=1; en=0; } void init_lcd(void) { lcd_cmd(0x3c); lcd_cmd(0x0c); lcd_cmd(0x06); lcd_cmd(0x01); } void clear_lcd(void) { lcd_cmd(0x01); } void display(unsigned char b) { wait(); lcdprt=b; rs=1; en=1; en=0; } void wait(void) {unsigned int count=300; while(count!=0) {count--; 51
  • 52. } } void shift(void) { lcd_cmd(0x1c); } void cursor_position(unsigned char c) {lcd_cmd(c+0x80); } void disp_hex(unsigned char digit) {unsigned char temp; temp=digit>>4; display(lkup_tb101[temp]); temp=(digit&0x0f); display(lkup_tb101[temp]); } void disp_dec(unsigned int digit) {unsigned int temp,temp1,temp2; if (digit<100) {temp1=digit/10; display(lkup_tb101[temp1]); temp2=digit-temp1*10; display(lkup_tb101[temp2]); transmit_serial(temp1*10+temp2);} if(digit>99&&digit<1000) {temp=digit/100; display(lkup_tb101[temp]); digit=digit-(temp*100); 52
  • 54. display(lkup_tb101[temp]); digit=digit-(temp*100); temp=digit/10; display(lkup_tb101[temp]); digit=digit-(temp*10); temp=digit; display(lkup_tb101[temp]); }} void delay(unsigned int i) { while(i!=0) { i--; } } void init_sit(void) {TMOD=0x00; TMOD=0x20; 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) 54
  • 55. { unsigned int e; P2=0xff; init_lcd(); init_sit(); while(1) { e=read_adc(); cursor_position(0x00); delay(0xffff); disp_dec(e); } } unsigned char read_adc(void) {unsigned char n; P1_0=0; // SOC=0 P1_0=1; // SOC=1 while(P1_1==1) //while( EOC==1) {n=P2; } return(n); } 55
  • 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
  • 59. To Update Set Bit is 1 rb=0x80 59
  • 60. CODE FOR INTERFACING OF RTC (DS12887) WITH ATs52 MICROCONTROLLER #include<at89s8252.h> #define LCDPRT P2 #define RS P1_2 #define EN P1_3 void bcdconv(unsigned int mb); void T0M2delay_rtc(void); void init_rtc(void); 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); struct rtc { unsigned char second; unsigned char sa; unsigned char minute; unsigned char ma; unsigned char hours; unsigned char ha; unsigned char dow; unsigned char dom; unsigned char month; unsigned char years; unsigned char ra; unsigned char rb; unsigned char rc; unsigned char rd; }; xdata at 0x0000 struct rtc ds12887; void main(void) { 60
  • 61. unsigned int x; unsigned char sec; unsigned char hr; unsigned char min Init_lcd(); for(x=0;x<10000;x++) T0M2delay_rtc(); ds12887.ra=0x20; ds12887.rb=0x81; ds12887.second=0x55; ds12887.minute=0x25; ds12887.hours=0x09; ds12887.dom=0x19; ds12887.month=0x10; ds12887.years=0x06; ds12887.rb=0x03; while(1) { sec=ds12887.second; cursor_position(0x00); bcdconv(sec); cursor_position(0x02); display(':'); min=ds12887.minute; cursor_position(0x03); bcdconv(min); cursor_position(0x05); display(':'); hr=ds12887.hours; cursor_position(0x06); bcdconv(hr); cursor_position(0x40); display('s'); cursor_position(0x42); display(':'); cursor_position(0x43); display('m'); cursor_position(0x45); display(':'); cursor_position(0x46); display('h'); } } 61
  • 62. void bcdconv(unsigned int mb) { unsigned int x; unsigned int y; x=mb&0x0f; x=x|0x30; y=mb&0xf0; y=y>>4; y=y|0x30; display(y); display(x); } void T0M2delay_rtc(void) { TMOD=TMOD&0xf0; TMOD=TMOD|0x02; TH0=0xEC; // 236 decimal value load in THO TR0=1; if(TF0==1) { TR0=0; TF0=0; } } void lcd_cmd(unsigned char a) { wait (); LCDPRT=a; RS=0; EN=1; EN=0; } void display(unsigned char b) { wait (); LCDPRT=b; RS=1; EN=1; EN=0; } void wait(void) { unsigned int count=300; while(count!=0) 62
  • 63. { count--; } } void Init_lcd(void) { lcd_cmd(0x3c); lcd_cmd(0x0c); lcd_cmd(0x06); lcd_cmd(0x01); } void clear_lcd(void) { lcd_cmd(0x01); } void cursor_position(unsigned char c) { lcd_cmd(c+0x80); } 63
  • 64. 64
  • 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
  • 68. code unsigned char name_arry2[]={"stop $"}; bit flag; unsigned char sec; void drive(void); void display_string(unsigned char *sp); void display_string1(unsigned char *pp); void display_string2(unsigned char *tp); 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 main(void) { P2=0x00; Init_lcd(); drive(); } void drive(void) { while(1) { P2=0x00; cursor_position(0x00); display_string2(&name_arry2); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); P2=0x05; cursor_position(0x00); display_string(&name_arry); delay(0xffff); 68
  • 69. P2=0x00; cursor_position(0x00); display_string2(&name_arry2); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); delay(0xffff); P2=0x0a; cursor_position(0x00); display_string1(&name_arry1); delay(0xffff); } } void display_string(unsigned char *sp) { while(*sp!='$') { display(*sp); sp=sp+1; } } void display_string1(unsigned char *pp) { while(*pp!='$') { display(*pp); pp=pp+1; } 69
  • 70. } void display_string2(unsigned char *tp) { while(*tp!='$') { display(*tp); tp=tp+1; } } void lcd_cmd(unsigned char a) { wait (); LCDPRT=a; RS=0; EN=1; EN=0; } void display(unsigned char b) { wait (); LCDPRT=b; RS=1; EN=1; EN=0; } void wait(void) { unsigned int count=300; while(count!=0) { count--; } } void Init_lcd(void) { lcd_cmd(0x3c); lcd_cmd(0x0c); lcd_cmd(0x06); lcd_cmd(0x01); 70
  • 71. } void clear_lcd(void) { lcd_cmd(0x01); } void delay (unsigned int i) { while (i!=0) { i--; } } void cursor_position(unsigned char c) { lcd_cmd(c+0x80); } 71