You are on page 1of 21

HARDWARE COMPONETS Power supply

The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. A d.c power supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load variations is known as Regulated D.C Power Supply

Transformer: A transformer is an electrical device which is used to convert electrical power from one electrical circuit to another without change in frequency.
Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase in output voltage, step-down transformers decrease in output voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage. The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input)

coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage.

RECTIFIER: A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of conversion a.c to d.c is called rectification TYPES OF RECTIFIERS: Half wave Rectifier Full wave rectifier 1. Centre tap full wave rectifier. 2. Bridge type full bridge rectifier.

Full-wave Rectifier:
From the above comparison we came to know that full wave bridge rectifier as more advantages than the other two rectifiers. So, in our project we are using full wave bridge rectifier circuit. Bridge Rectifier: A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wiredinternally.

Filter: A Filter is a device which removes the a.c component of rectifier output but allows the d.c component to reach the load Capacitor Filter: We have seen that the ripple content in the rectified output of half wave rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is not acceptable for most of the applications. Ripples can be removed by one of the following methods of filtering. (a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage though it due to low impedance. At ripple frequency and leave the d.c.to appears the load. (b) An inductor, in series with the load, prevents the passage of the ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)

(c) various combinations of capacitor and inductor, such as L-section filter

section

filter, multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier.

Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value).

Regulator:

Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the output pin.

78XX: The Bay Linear LM78XX is integrated linear positive regulator with three terminals. The LM78XX offer several fixed output voltages making them useful in wide range of applications. When used as a zener diode/resistor combination replacement, the LM78XX usually results in an effective output impedance improvement of two orders of magnitude, lower quiescent current. The LM78XX is available in the TO-252, TO-220 & TO-263packages, Features: Output Current of 1.5A Output Voltage Tolerance of 5% Internal thermal overload protection Internal Short-Circuit Limited No External Component Output Voltage 5.0V, 6V, 8V, 9V, 10V,12V, 15V, 18V, 24V Offer in plastic TO-252, TO-220 & TO-263 Direct Replacement for LM78XX

MICROCONTROLLER
INTRODUCTION: A Micro controller consists of a powerful CPU tightly coupled with memory RAM, ROM or EPROM), various I / O features such as Serial ports, Parallel Ports, Timer/Counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital Converter (ADC), Digital to Analog Converter (ADC), everything integrated onto a single Silicon Chip. It does not mean that any micro controller should have all the above said features on chip, Depending on the need and area of application for which it is designed, The ONCHIP features present in it may or may not include all the individual section said above. Any microcomputer system requires memory to store a sequence of instructions making up a program, parallel port or serial port for communicating with an external system, timer / counter for control purposes like generating time delays, Baud rate for the serial port, apart from the controlling unit called the Central Processing Unit. INTRODUCTION TO 8051MICROCONTROLLER

In 1981,Intel corporation introduced an 8 bit microcontroller called the 8051.This microcontroller had 128 bytes of RAM,4K bytes of on-chip ROM, two timers, one serial port and 4 ports(each 8-bits wide)all on single chip. At that time it was also referred to as a system on a chip. INTRODUCTION TO ATMEL MICROCONTROLLER The major Features of 8-bit Micro controller ATMEL 89C51: 8 Bit CPU optimized for control applications Extensive Boolean processing (Single - bit Logic) Capabilities. On - Chip Flash Program Memory On - Chip Data RAM Bi-directional and Individually Addressable I/O Lines

Multiple 16-Bit Timer/Counters Full Duplex UART Multiple Source / Vector / Priority Interrupt Structure On - Chip Oscillator and Clock circuitry. On - Chip EEPROM One Serial communication port

Block Diagram
ON-CHIP RAM

EXTERNAL INTERRUPTS
TIMER 1

COUNTER INPUTS

INTERRUPT CONTROL

ON-CHIP FLASH

TIMER 0
ON-CHIP RAM

CPU

OSC

BUS CONTROL

4 I/O PORTS

SERIL PORT

PO P2 P1 P3

TXD

RXD

Fig.1 Oscillator Connection. The P89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt architecture, a full duplex serial port, and on-chip oscillator and clock circuitry. In addition, the P89C51 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 hardware reset.

Memory Organization Program Memory Below Fig shows a map of the lower part of the program memory. After reset, the CPU begins execution from location 0000H. As shown in fig.4, each interrupt is assigned a fixed location in program memory. The interrupt causes the CPU to jump to that location, where it executes the service routine. External Interrupt 0, for example, is assigned to location 0003H. If External Interrupt 0 is used, its service routine must begin at location 0003H. If the interrupt is not used, its service location is available as general purpose.

(0033)H 002BH 0023H INTERRUPT LOCATIONS 001BH 8 bytes 0013H 000BH RESE T 0003H 0000H

Program Memory. Program memory addresses are always 16 bits wide, even though the actual amount o program memory used may be less than 64Kbytes. External program execution sacrifices two of the 8-bit ports, P0 and P2, to the function of addressing the program memory.

Data Memory The right half of Figure 3 shows the internal and external data memory spaces available on Philips Flash microcontrollers. Fig.6 shows a hardware configuration for accessing up to 2K bytes of external RAM. In this case, the CPU executes from internal flash. Port0 serves as a multiplexed address/data bus to the RAM, and 3 lines of Port 2 are used to page the RAM. The CPU generates RD and WR signals as needed during external RAM accesses. You can assign up to 64K bytes of external data memory. External data memory addresses can be either 1 or 2bytes wide. Internal data memory addresses are always 1 byte wide, which implies an address space of only 256bytes. However, the addressing modes for internal RAM can infact accommodate 384 bytes. Direct addresses higher than 7FH access one memory space and indirect addresses higher than 7FH access a different memory space. Thus, Figure.7 shows

the Upper 128 and SFR space occupying the same block of addresses, 80H through FFH, although they are physically separate entities. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7. The next 16 bytes above the register banks form a block of bit-addressable memory space. The microcontroller instruction set includes a wide selection of single-bit instructions, and these instructions can directly address the 128 bits in this area. These bit addresses are 00H through 7FH. All of the bytes in the Lower 128 can be accessed by either direct or indirect addressing.

REGISTERS: In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of 8051 registers are 8bit registers. In the 8051 there is only one data type: 8bits. The 8bits of a register are should in the diagram from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With an 8-bit data type, any data larger than 8bits must be broken into 8-bit chunks before it is processed. D The most 7 6 D 5 D 4 D 3 D 2 D 1 D 0 D

widely used registers of the 8051 are A(accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR(data pointer), and PC(program counter). All of the above registers are 8-bits, except DPTR and the program counter. The accumulator, register A, is used for all arithmetic and logic instructions.

SFRs (Special Function Registers)


Among the registers R0-R7 are part of the 128 bytes of RAM memory . what about registers A,B, PSW, and DPTR? Do they also have addresses? The answer is yes. In the 8051, registers A, B, PSW and DPTR are part of the group of registers commonly referred

to as SFR (special function registers). There are many special function registers and they are widely used. The SFR can be accessed by the names (which is much easier) or by their addresses. For example, register A has address E0h, and register B has been ignited the address F0H.

PIN CONFIGURATION:

Pin Diagram of AT89C51 Pin Description VCC: Pin 40 provides supply voltage to the chip. The voltage source is +5v. GND: Pin 20 is the ground.

Ports 0, 1, 2 and 3 As shown in pin diagram, the four ports P0, P1, P2, and P3 each use of 8 pins, making the 8-bit ports. All the ports upon Reset are configured as input, since P0-P3 have FFH on them.

Port 0
Port 0 occupies a total of 8 pins (pins 32-33). It can be used for input or output. Port0 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=0, it provides data D0-D7, but when ALE=1, it has address A0-A7. Therefore, ALE is used for demultiplexing address address and data with the help of a 74LS373 latch. In the 8051-based systems where there is no external memory connection, the pins of P0 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, P3. Open drain is a term used for Mos chips in the same way that open collector is used for TTL chips. In many systems usig the 8751, 89C51, or DS89C4x0 chips, we normally connect P0 to pull-up resistors. With external pull-up resistors connected to P0, it can be used as a simple I/O port, just like P1 and P2. In contrast to Port 0, ports p1, p2, and p3 do not need any pull-up resistors since they already have pull-up resistors internally. Upon reset, ports p1, p2, ad p3 are configured as input ports.

Port 1 Port 1 occupies a total of 8-pins (pins1-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, port1 is configured as an input port. Port 2
Port 2 occupies a total 8 pins (pins 21-28). It can be used as input or output. However, in 8031-based systems, port2 is also designated as A8-A15, indicating its dual function. Since an 8051/31 is capable of 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 is used for the upper 8 bits of the 16-bit address, and it cannot be used for I/O. Just like P1, port 2 does not need any pull-up resistors since it already has pull-up resistors internally. configured as an input port. Upon reset, port2 is

Port 3 Port 3 occupies a total of 8 pins (pins 10-17). It can be used as input or output. P3 does not need any pull-up resistors, just as P1 and P2 did not. Although Port 3 is configured as an input port upon reset, this is not the way it is most commonly used. Port 3 has the additional function of providing some extremely important signals such as interrupts. The below table provides these alternate functions of P3. This is information applies to both 8051 and 8031 chips.

Alternate Functions of PORT3 Port 3 also receives some control signals for Flash programming and verification. RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG Prior to each reading from external memory, the microcontroller will set the lower address byte (A0-A7) on P0 and immediately after that activates the output ALE. Upon receiving signal from the ALE pin, the external register (74HCT373 or 74HCT375 circuit is usually embedded ) memorizes the state of P0 and uses it as an address for memory chip. In the second part of the microcontrollers machine cycle, a signal on this pin stops being emitted and P0 is used now for data transmission (Data Bus). In this way, by means of only one additional (and cheap) integrated circuit, data multiplexing from the port is performed. This port at the same time used for data and address transmission.

PSEN Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine

cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP 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 12volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP. XTAL1 and XTAL2 The 8051 has an on-chip oscillator but requires an external clock to run it. Most often a quartz crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2 (pin18). The quartz crystal oscillator connected to XTAL1 and XTAL2 also needs two capacitors of 30pf value. One side of each capacitor is connected to the ground as shown in fig1. It must be noted that there are various speeds of the 8051 family. Speed refers to the maximum oscillator frequency connected to XTAL. For example, a 12-MHz chip must be connected to a crystal with 12 MHz frequency of no more than 20 MHz. When the 8051 is connected to a crystal oscillator and is powered up, we can observe the frequency on the XTAL2 pin using the oscilloscope.

TIMERS On-chip timing/counting facility has proved the capabilities of the microcontroller for implementing the real time application. These includes pulse counting, frequency measurement, pulse width measurement, baud rate generation, etc,. Having sufficient number of timer/counters may be a need in a certain design application. The 8051 has two timers/counters. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. Let discuss how these

timers are used to generate time delays and we will also discuss how they are been used as event counters. BASIC RIGISTERS OF THE TIMER Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte. TIMER 0 REGISTERS The 16-bit register of Timer 0 is accessed as low byte and high byte. the low byte register is called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).These register can be accessed like any other register, such as A,B,R0,R1,R2,etc.for example, the instruction MOV TL0, #4Fmoves the value 4FH into TL0,the low byte of Timer 0.These registers can also be read like any other register.

TIMER 1 REGISTERS Timer 1 is also 16-bit register is split into two bytes, referred to as TL1 (Timer 1 low byte) and TH1(Timer 1 high byte).these registers are accessible n the same way as the register of Timer 0.

TMOD (timer mode) REGISTER Both timers 0 and 1 use the same register, called TMOD, to set the various timer operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside for

Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation.

TCON Register: TCON controls the timer/counter operations. The lower four bits of TCON cater to interrupt functions, but the upper four bits are for timer operations. The details of the TCON register are shown below.

MSB

LSB

TF1

TR1

TF0

TR0

IE1

IT1

IE0

IT0

INTERRUPTS: A single microcontroller can serve several devices. There are two ways to do that: INTERRUPTS or POLLING. POLLING: In polling the microcontroller continuously monitors the status of a given device; when the status condition is met, it performs the service .After that, it moves on to monitor the next device until each one is serviced. Although polling can monitor the status of several devices and serve each of them as certain condition are met. INTERRUPTS:

In the interrupts method, whenever any device needs its service, the device notifies the microcontroller by sending it an interrupts signal. Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing and serves the device. The program associated with the interrupts is called the interrupt service routine (ISR).or interrupt handler. Six Interrupts in the 8051: In reality, only five interrupts are available to the user in the 8051, but many manufacturers data sheets state that there are six interrupts since they include reset .the six interrupts in the 8051 are allocated as above. 1. Reset. When the reset pin is activated, the 8051 jumps to address location 0000.this is the power-up reset. 2. Two interrupts are set aside for the timers: one for Timer 0 and one for Timer 1.Memory location 000BH and 001BH in the interrupt vector table belong to Timer 0 and Timer 1, respectively. 3. Two interrupts are set aside for hardware external harder interrupts. Pin number 12(P3.2) and 13(P3.3) in port 3 are for the external hardware interrupts INT0 and INT1,respectively.These external interrupts are also referred to as EX1 and EX2.Memory location 0003H and 0013H in the interrupt vector table are assigned to INT0 and INT1, respectively. 4. Serial communication has a single interrupt that belongs to both receive and transmit. The interrupt vector table location 0023H belongs to this interrupt.

8051/52 Interrupt Priority upon Reset Highest to Lowest Priority

External Interrupt 0 Timer Interrupt 0 External Interrupt 1 Timer Interrupt 1 Serial Communication Timer 2(8052 only)

(INT0) (TF0) (INT1) (TF1) (RI+TI) TF2

SERIAL COMMUNICATION
Computers can transfer data in two ways: parallel and serial. In parallel data transfers, often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet away. An example of parallel transfers a printers and hard disks; each uses cables with many wire strips. Although in such cases a lot of data can be transferred in a short amount of time by using many wires in parallel, the distance cannot be great. To transfer to a device located many meters away, the serial method is used. In serial communication, the data is sent one bit at a time, in contrast to parallel communication, in which the data is sent a byte or more at a time. Serial communication of the 8051 is the topic of this chapter. The 8051 has serial communication capability built into it, there by making possible fast data transfer using only a few wires. If data is to be transferred on the telephone line, it must be converted from 0s and 1s to audio tones, which are sinusoidal-shaped signals. This conversion is performed by a peripheral device called a modem, which stands for modulator/demodulator. Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers a block of data at a time, while the asynchronous method transfers a single byte at a time.

In data transmission if the data can be transmitted and received, it is a duplex transmission. This is in contrast to simplex transmissions such as with printers, in which the computer only sends data. Duplex transmissions can be half or full duplex, depending on whether or not the data transfer can be simultaneous. Asynchronous serial communication and data framing The data coming in at the receiving end of the data line in a serial data transfer is all 0s and 1s; it is difficult to make sense of the data unless the sender and receiver agree on a set of rules, a protocol, on how the data is packed, how many bits constitute a character, and when the data begins and ends. Start and stop bits Asynchronous serial data communication is widely used for character-oriented transmissions, while block-oriented data transfers use the synchronous method. In the asynchronous method, each character is placed between start and stop bits. This is called framing. In the data framing for asynchronous communications, the data, such as ASCII characters, are packed between a start bit and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The start bit is always a 0 (low) and the stop bit (s) is 1 (high). Data transfer rate The rate of data transfer in serial data communication is stated in bps (bits per second). Another widely used terminology for bps is baud rate. The data transfer rate of given computer system depends on communication ports incorporated into that system. For example, the early IBMPC/XT could transfer data at the rate of 100 to 9600 bps. In recent years, however, Pentium based PCS transfer data at rates as high as 56K bps. It must be noted that in asynchronous serial data communication, the baud rate is generally limited to 100,000bps.

Baud rate in the 8051

The 8051 transfers and receives data serially at many different baud rates. The baud rate in the 8051 is programmable. The is done with the help of Timer1. The 8051 divides the crystal frequency by 12 to get the machine cycle frequency. In the case of XTAL=11.0592MHZ, the machine cycle frequency is 921.6 KHz (11.0592MHz/12=921.6KHz). the 8051s serial communication UART circuitry divides the machine cycle frequency of 921.6khz divided by 32 once more before it is used by Timer 1 to set the Baud rate. Therefore, 921.6 kHz divided by 32 gives 28,800 Hz. This is the number well use to find the Timer 1 value to set baud rate. B aud rate 9 600 4 800 2 400 1 200 NOTE: XTAL=11...592MHz SBUF register SBUF is an 8-bit register used solely for serial communication in the 8051. for a byte of data to be transferred via the TXD line, it must be placed in the SBUF register. Similarly, SBUF holds the byte of data when it is received by the 8051s RXD line. SBUF can be accessed like any other register in the 8051. Look at the following the examples of how this register is accessed.
MOV MOV MOV SBUF, #D SBUF, A A, SBUF ; load SBUF=44h, ASCII for D ; copy accumulator into SBUF ; copy SBUF into accumulator

TH1(D ecimal) -3 -6 A -12 -24

T H1(Hex) F D F F4 E8

The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred serially via the TXD pin. Similarly, when the bits are received serially via RXD, the 8051 defames it by eliminating the stop and start bits, making a byte out of the data received, and then placing it in the SBUF.

SCON (serial control) register The SCON register is an 8-bit register used to program the start bit, stop bit, and data bits of data framing, among other things. The following describes various bits of the SCON register.

S M0 M1

S M2

S EN

R B8

T B8

R I

T I

SM0 SM1 SM2 REN TB8 RB8 TI RI software.

SCON.7 SCON.6 SCON.5 SCON.4 SCON.3 SCON.2 SCON.1 SCON.0

Serial port mode specifier Serial port mode specifier Used for multiprocessor communication. (make it 0.) Set/cleared by software to enable/disable reception Not widely used Not widely used Transmit interrupt flag. Set by hardware at the beginning Of the stop bit in mode 1. Must be cleared by software. Receive interrupt flag. Set by hardware halfway through the stop bit time mode 1. Must be cleared by

Note: Make SM2, TB8, and RB8=0.

SM0, SM1
SM0 and SM1 are D7 and D6 of the SCON register, respectively. These two bits determine the framing of data by specifying the number of bits per character and the start and stop bits. They take the following combinations.

SM0 0 0 1 1

SM1 0 1 0 1

FUNCTION Serial Mode 0 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit Serial Mode 2 Serial Mode 3

Of the 4 serial modes, only mode 1 is of interest to us. In the SCON register, when serial mode 1 is chosen, the data framing is 8 bits, 1 stop bit, and 1 start bit, which makes it compatible with the COM port of IBM/compatible PCs. More importantly, serial mode 1 allows the baud rate to be variable and is set by Timer 1 of the 8051. In serial mode 1, for each character a total of 10 bits are transferred, where the first bit is the start bit, followed by 8 bits of data, and finally 1 stop bit.

You might also like