Anda di halaman 1dari 28

APPENDICES a. MICROCONTROLLER a.

1 DESCRIPTION OF 8051 The AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of In-System Programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the indus-trystandard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory pro-grammer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a five-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S51 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 Powerdown mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next external interrupt or hardware reset.

Fig a.1 Pin diagram of 8051

ii

a.2 8051 PIN FUNCTION: PORT 0 Port 0 is dual-function in that it in some designs port 0s I/O lines are available to the developer to access external devices while in other designs it is used to access external memory. If the circuit requires external RAM or ROM, the microcontroller will automatically use port 0 to clock in/out the 8-bit data word as well as the low 8 bits of the address in response to a MOVX instruction and port 0 I/O lines may be used for other functions as long as external RAM isnt being accessed at the same time. If the circuit requires external code memory, the microcontroller will automatically use the port 0 I/O lines to access each instruction that is to be executed. In this case, port 0 cannot be utilized for other purposes since the state of the I/O lines are constantly being modified to access external code memory. PORT 1 Port 1 consists of 8 I/O lines that you may use exclusively to interface to external parts. Unlike port 0, typical derivatives do not use port 1 for any functions themselves. Port 1 is commonly used to interface to external hardware such as LCDs, keypads, and other devices. With 8052 derivatives, two bits of port 1 are optionally used as described for extended timer 2 functions. These two lines are not assigned these special functions on 8051s since 8051s dont have a timer 2. Further, these lines can still be used for your own purposes if you dont need these features of timer 2. P1.0 (T2): If T2CON.1 is set (C/T2), then timer 2 will be incremented whenever there is a 1-0 transition on this line. With C/T2 set, P1.0 is the clock source for timer 2. P1.1 (T2EX): If timer 2 is in auto-reload mode and T2CON.3 (EXEN2) is set, a 1-0 transition on this line will cause
iii

timer 2 to be reloaded with the auto-reload value. This will also cause the T2CON.6 (EXF2) external flag to be set, which may cause an interrupt if so enable PORT 2 Like port 0, port 2 is dual-function. In some circuit designs it is available for accessing devices while in others it is used to address external RAM or external code memory. When the MOVX @DPTR instruction is used, port 2 is used to output the high byte of the memory address that is to be accessed. In these cases, port 2 may be used to access other devices as long as the devices are not being accessed at the same time a MOVX instruction is using port 2 to address external RAM. If the circuit requires external code memory, the microcontroller will automatically use the port 2 I/O lines to access each instruction that is to be executed. In this case, port 2 cannot be utilized for other purposes since the state of the I/O lines are constantly being modified to access external code memory. PORT 3 Port 3 consists entirely of dual-function I/O lines. While the developer may access all these lines from their software by reading/writing to the P3 SFR, each pin has a pre-defined function that the microcontroller handles automatically when configured to do so and/or when necessary. P3.0 (RXD): The UART/serial port uses P3.0 as the receive line. In circuit designs that will be using the microcontrollers internal serial port, this is the line into which serial data will be clocked. Note that when interfacing an 8052 to an RS-232 port that you may not connect this line directly to the RS-232 pin; rather, you must pass it through a part such as the MAX232 to obtain the correct voltage levels. This pin is

iv

available for any use the developer may assign it if the circuit has no need to receive data via the integrated serial port. P3.1 (TXD): The UART/serial port uses P3.1 as the transmit line. In circuit designs that will be using the microcontrollers internal serial port, this is the line that the microcontroller will clock out all data which is written to the SBUF SFR. Note that when interfacing an 8052 to an RS-232 port that you may not connect this line directly to the RS-232 pin; rather, you must pass it through a part such as the MAX232 to obtain the correct voltage levels. This pin is available for any use the developer may assign it if the circuit has no need to transmit data via the integrated serial port. P3.2 (-INT0): When so configured, this line is used to trigger an External 0 Interrupt. This may either be low-level triggered or may be triggered on a 1-0 transition. Please see the chapter on interrupts for details. This pin is available for any use the developer may assign it if the circuit does not need to trigger an external 0 interrupt. P3.3 (-INT1): When so configured, this line is used to trigger an External 1 Interrupt. This may either be low-level triggered or may be triggered on a 1-0 transition. Please see the chapter on interrupts for details. This pin is available for any use the developer may assign it if the circuit does not need to trigger an external 1 interrupt. P3.4 (T0): When so configured, this line is used as the clock source for timer 0. Timer 0 will be incremented either every instruction cycle that T0 is high or every time there is a 1-0 transition on this line, depending on how the timer is configured. Please see the chapter on timers for details. This pin is available for any use the developer may assign it if the circuit does not to control timer 0 externally.

P3.5 (T1): When so configured, this line is used as the clock source for timer 1. Timer 1 will be incremented either every instruction cycle that T1 is high or every time there is a 1-0 transition on this line, depending on how the timer is configured. Please see the chapter on timers for details. This pin is available for any use the developer may assign it if the circuit does not to control timer 1 externally. P3.6 (-WR): This is external memory write strobe line. This line will be asserted low by the microcontroller whenever a MOVX instruction writes to external RAM. This line should be connected to the RAMs write (-W) line. This pin is available for any use the developer may assign it if the circuit does not write to external RAM using MOVX. P3.7 (-RD): This is external memory write strobe line. This line will be asserted low by the microcontroller whenever a MOVX instruction writes to external RAM. This line should be connected to the RAMs write (-W) line. This pin is available for any use the developer may assign it if the circuit does not read from external RAM using MOVX. OSCILLATOR INPUTS (XTAL1, XTAL2) The 8052 is typically driven by a crystal connected to pins 18 (XTAL2) and 19 (XTAL1). Common crystal frequencies are 11.0592Mhz as well as 12Mhz, although many newer derivatives are capable of accepting frequencies as high as 40Mhz. While a crystal is the normal clock source, this isnt necessarily the case. A TTL clock source may also be attached to XTAL1 and XTAL2 to provide the microcontrollers clock. RESET LINE (RST) Pin 9 is the master reset line for the microcontroller. When this pin is brought high for two instruction cycles, the microcontroller is effectively reset. SFRs, including the I/O ports, are restored to their default
vi

conditions and the program counter will be reset to 0000h. Keep in mind that Internal RAM is not affected by a reset. The microcontroller will begin executing code at 0000h when pin 9 returns to a low state. The reset line is often connected to a reset button/switch that the user may press to reset the circuit. It is also common to connect the reset line to a watchdog IC or a supervisor IC (such as MAX707). The latter is highly recommended for commercial and professional designs since traditional resistor-capacitor networks attached to the reset line, while often sufficient for students or hobbyists, are not terribly reliable. ADDRESS LATCH ENABLE (ALE) The ALE at pin 30 is an output-only pin that is controlled entirely by the microcontroller and allows the microcontroller to multiplex the lowbyte of a memory address and the 8-bit data itself on port 0. This is because, while the high-byte of the memory address is sent on port 2, port 0 is used both to send the lowbyte of the memory address and the data itself. This is accomplished by placing the low-byte of the address on port 0, exerting ALE high to latch the low-byte of the address into a latch IC (such as the 74HC573), and then placing the 8 data-bits on port 0. In this way the 8052 is able to output a 16-bit address and an 8-bit data word with 16 I/O lines instead of 24. The ALE line is used in this fashion both for accessing external RAM with MOVX @DPTR as well as for accessing instructions in external code memory. When your program is executed from external code memory, ALE will pulse at a rate of 1/6th that of the oscillator frequency. Thus if the oscillator is operating at 11.0592Mhz, ALE will pulse at a rate of 1,843,200 times per second. The only exception is when the MOVX instruction is executed one ALE pulse is missed in lieu of a pulse on WR or RD
vii

PROGRAM STORE ENABLE (-PSEN) The Program Store Enable (PSEN) line at pin 29 is exerted low automatically by the microcontroller whenever it accesses external code memory. This line should be attached to the Output Enable (-OE) pin of the EPROM that contains your code memory. PSEN will not be exerted by the microcontroller and will remain in a high state if your program is being executed from internal code memory. EXTERNAL ACCESS (-EA) The External Access (-EA) line at pin 31 is used to determine whether the 8052 will execute your program from external code memory or from internal code memory. If EA is tied high (connected to +5V) then the microcontroller will execute the program it finds in internal/onchip code memory. If EA is tied low (to ground) then it will attempt to execute the program it finds in the attached external code memory EPROM. Of course, your EPROM must be properly connected for the microcontroller to be able to access your program in external code memory. 4.11 XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. 4.12 XTAL2 Output from the inverting oscillator amplifier TIMER/COUNTER REGISTERS All timers /counters is accessed as high byte or low byte which are 16 bits wide. The low byte register is called TL0 (for T0) and the high byte register is called TH0 (for T0), ordinary registers can access them. TMOD (TIMER MODE REGISTER) All timers/counters used this register for various operation modes. TMOD is an 8-bit register in which lower 4 bits are set aside for timer/counters 0 and higher 4 bits for timer/counter 1.
viii

GATE

C/T

M1 TIMER 1

M0

GATE

C/T

M1 TIMER 0

MO

BIT GATE

DESCRIPTION Gating control and set.

Timers/counters is enabled only while INTx pin is high and TRx control pin is set C/T M1 M0 M1 0 M0 0 MODE 0 Set the counter or timer operation. Mode bit 1 Mode bit 0 OPERATION 13 bit timer 8 bit timer/counter 0 1 1 1 0 1 1 2 3 16 bit timer/counter 8 bit auto reload timer/counter Split timer mode

Table a.1 TMOD Register Functions

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. 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.

ix

T2CON REGISTER Control and status bits are contained in registers T2CON and T2MOD for Timer 2. The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.

TCON REGISTER This register is an 8-bit register in which upper four bits are used to store timer flags (TF) and timer run bits (TR). Lower four bits are set aside for the control of interrupts. BIT 7 6 5 4 3 2 1 0 SYMBOL TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 FUNCTION Timer 1 over flow flag Timer 1 run control bit Timer 0 over flow flag Timer 0 run control bit External interrupt 1 edge flag External interrupt 1 signal type External interrupt 0 edge flag External interrupt 0 signal type

Table a.2 TCON Register Function

TIMER MODES OF OPERATION

1. MODE 0 Setting timer X mode bits to 00h in the TMOD register results in using the TH X as an 8-bit counter/timer and TL X as a 5-bit counter. 2. MODE 1 It is similar to mode 0 except that TL X is configured as a full 8-bit counter. 3. MODE 2 Setting the mode bits to 10 h in TMOD configures the timer to use TL X as 8-bit counter. It exhibits auto reload feature: TL

X will count up from the number in THX till the timer flag is set and TL X is loaded again with THX. 4. MODE 3 Timer 0 in this mode becomes two completely separate 8 bit counters.

b. Hardware Module Description

Fig.b.1 Receiver Module

Fig.b.2 Transmitter Module

xi

b.1. TRANSMITTER The TWS-434 extremely small, and are excellent for applications requiring short-range RF remote controls. The transmitter module is only 1/3 the size of a standard postage stamp, and can easily be placed inside a small plastic enclosure. TWS-434: The transmitter output is up to 8mW at 433.92MHz with a range of approximately 400 foot (open area) outdoors. Indoors, the range is approximately 200 foot, and will go through most walls. The TWS-434 transmitter accepts both linear and digital inputs, can operate from 1.5 to 12 Volts-DC, and makes building a miniature handheld RF transmitter very easy. The TWS-434 is approximately 1/3 the size of a standard postage stamp.

Figure b.3 TWS-434 Pin Diagram

xii

Figure b.4 - Transmitter Application Circuit

b.2 RECEIVER RWS-434: The receiver also operates at 433.92MHz, and has a sensitivity of 3uV. The TWS-434 receiver operates from 4.5 to 5.5 volts-DC, and has both linear and digital outputs.

xiii

Figure b.5- Receiver Pin Out Diagram

c. HT12E-212 SERIES OF ENCODERS GENERAL DESCRIPTION The 212 encoders are a series of CMOS LSIs for remote control system applications. They are capable of encoding information which consists of N address bits and 12_N data bits.the programmed addresses/data are together with the header bits via an RF or an infrared transmission medium upon receipt of a trigger signal.

xiv

Fig c.1 Block Diagram Of Encoder

Fig c.2 Pin Diagram of Encoder


xv

Table c.1 Pin Description of Encoder

d. HT 12D-212 SERIES OF DECODER GENERAL DESCRIPTION The 212 decoders are a series of CMOS LSIs for remote control system applications. They are paired with Holteks 212 series of encoders (refer to the encoder/decoder cross reference table. For proper operation, a pair of encoder/decoder with the same number of addresses and data format should be chosen. The decoders receive serial addresses and data from a programmed 212 series of encoders that are transmitted by a carrier using an RF or an IR transmission medium. They compare the serial input data three times continuously with their local addresses. If no error or unmatched codes are found, the input data codes are decoded and then transferred to the output pins. The VT pin also goes high to indicate a valid transmission. The 212 series of decoders are capable of decoding information that consists of N bits of address and 12_N bits of data. Of this series, the HT12D is arranged to provide 8 address bits and 4 data bits, and HT12F is used to decode 12 bits of address information.

xvi

Fig d.1 Block Diagram of Decoder

Fig d.2 Pin Diagram of Decoder

xvii

PIN DESCRIPTION A0-A7-> Input pins for address setting. D8-D11->Output data pins, power on status low. DIN->Serial data input pin. OSC1->Oscillator input pin. OSC2->Oscillator output pin. VSS->Negative power supply, ground. VDD->Positive power supply.

e. POWER SUPPLY The ac voltage, typically 220V rms, is connected to a transformer, which steps that ac voltage down to the level of the desired dc output. A diode rectifier then provides a full-wave rectified voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage variation. A regulator circuit removes the ripples and also remains the same dc value even if the input dc voltage varies, or the load connected to the output dc voltage changes. This voltage regulation is usually obtained using one of the popular voltage regulator IC units.

TRANSFORMER

RECTIFIER

FILTER

IC REGULATOR

LOAD

Fig e.1 Block Diagram of Power supply

xviii

e.1Working principle

Transformer The potential transformer will step down the power supply voltage (0-230V) to (0-6V) level. Then the secondary of the potential transformer will be connected to the precision rectifier, which is constructed with the help of opamp. The advantages of using precision rectifier are it will give peak voltage output as DC, rest of the circuits will give only RMS output. Bridge rectifier When four diodes are connected as shown in figure, the circuit is called as bridge rectifier. The input to the circuit is applied to the diagonally opposite corners of the network, and the output is taken from the remaining two corners. Let us assume that the transformer is working properly and there is a positive potential, at point A and a negative potential at point B. the positive potential at point A will forward bias D3 and reverse bias D4. The negative potential at point B will forward bias D1 and reverse D2. At this time D3 and D1 are forward biased and will allow current flow to pass through them; D4 and D2 are reverse biased and will block current flow. The path for current flow is from point B through D1, up through RL, through D3, through the secondary of the transformer back to point B. this path is indicated by the solid arrows. Waveforms (1) and (2) can be observed across D1 and D3. One-half cycle later the polarity across the secondary of the transformer reverse, forward biasing D2 and D4 and reverse biasing D1 and D3. Current flow will now be from point A through D4, up through RL, through D2, through the secondary of T1, and back to point A. This
xix

path is indicated by the broken arrows. Waveforms (3) and (4) can be observed across D2 and D4. The current flow through RL is always in the same direction. In flowing through RL this current develops a voltage corresponding to that shown waveform (5). Since current flows through the load (RL) during both half cycles of the applied voltage, this bridge rectifier is a full-wave rectifier. One advantage of a bridge rectifier over a conventional full-wave rectifier is that with a given transformer the bridge rectifier produces voltage output that is nearly twice that of the conventional full-wave circuit.

IC voltage regulators Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC. IC units provide regulation of either a fixed positive voltage, a fixed negative voltage, or an adjustably set voltage. The regulators can be selected for operation with load currents from hundreds of milli amperes to tens of amperes, corresponding to power ratings from milli watts to tens of watts.

xx

Fig e.2 Circuit Diagram Of Power Supply

A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated dc output voltage, Vo, from a second terminal, with the third terminal connected to ground. The series 78 regulators provide fixed positive regulated voltages from 5 to 24 volts. Similarly, the series 79 regulators provide fixed negative regulated voltages from 5 to 24 volts.

f. ASYNCHRONOUS SERIAL COMMUNICATION Serial communication is basically the transmission or reception of data one bit at a time. Today's computers generally address data in bytes or some multiple thereof. A byte contains 8 bits. A bit is basically either a logical 1 or zero. Every character on this page is actually expressed internally as one byte. The serial port is used to convert each byte to a
xxi

stream of ones and zeroes as well as to convert a streams of ones and zeroes to bytes. The serial port contains a electronic chip called a Universal Asynchronous Receiver/Transmitter (UART) that actually does the conversion . Original use of RS232 When we look at the connector pinout of the RS232 port, we see two pins which are certainly used for flow control. These two pins are RTS, request to send and CTS, clear to send. With DTE/DCE communication (i.e. a computer communicating with a modem device) RTS is an output on the DTE and input on the DCE. CTS is the answering signal coming from the DCE. Before sending a character, the DTE asks permission by setting its RTS output. No information will be sent until the DCE grants permission by using the CTS line. If the DCE cannot handle new requests, the CTS signal will go low. A simple but useful mechanism allowing flow control in one direction. The assumption is, that the DTE can always handle incoming information faster than the DCE can send it. In the past, this was true. Modem speeds of 300 baud were common and 1200 baud was seen as a high speed connection. For further control of the information flow, both devices have the ability to signal their status to the other side. For this purpose, the DTR data terminal ready and DSR data set ready signals are present. The DTE uses the DTR signal to signal that it is ready to accept information, whereas the DCE uses the DSR signal for the same purpose. Using these signals involves not a small protocol of requesting and answering as with the RTS/CTS handshaking. These signals are in one direction only.

xxii

Fig f.1 DB-9 Pin Connector

Table f.2 Pin Description Of DB-9 Connector

xxiii

Fig f.3 Null Modem Connection

Connector 1 Connector 2 2 3 3 2 5

Function Rx Tx Tx Rx

Signal ground

Table f.4 Null Modem Connection

g.MAX232 Description: The Max 232 is a dual driver/receiver that includes a capacitive voltage generator to supply TIA/EIA-232-F voltage levels from a single 5V supply. Each receiver converts TIA/EIA-232-F to 5V TTL/CMOS levels. These receivers have a typical threshold of 1.3V, a typical hysteresis of 0.5V and can accept 30V inputs. Each driver converts TTL/CMOS to TIA/EIA-232-F levels. The 89C52 has a built in serial port that makes it very easy to communicate with the PC's serial port but the 89C52 outputs are 0 and 5 volts and we need +10 and -10 volts to meet the RS232 serial port standard. The easiest way to get these values is to use the MAX232. The MAX232 acts as a buffer driver for the
xxiv

processor. It accepts the standard digital logic values of 0 and 5 volts and converts them to the RS232 standard of +10 and -10 volts. It also helps protect the processor from possible damage from static that may come from people handling the serial port connectors. The MAX232 requires 5 external 1uF capacitors. These are used by the internal charge pump to create +10 volts and -10 volts. It includes 2 receivers and 2 transmitters so two serial ports can be used with a single chip.

Fig g.1 Pin Diagram Of Max 232 In this circuit the max 232 IC used as level logic converter. The max232 is a dual driver/receiver that includes a capacitive voltage generator to supply EIA 232 voltage from a single 5v supply. Each receiver converts EIA-232 to 5v TTl/CMOS levels. Each driver converts TLL/CMOS input levels into EIA-232 levels. In this circuit the microcontroller transmitter pin is connected in the MAX232 T2IN pin which converts input 5v TTL/CMOS level to RS232 level. Then T2OUT pin is connected to receiver pin of 9 pin d type serial connector which is directly connected to pc. In PC the transmitting data to R2IN of MAX232 through transmitting pin of 9D type connector which converts the RS232 level to 5v TTL/CMOS level. The R2OUT pin is connected to receiver pin of the

xxv

microcontroller. Likewise the data is transmitted and received between the microcontroller and PC or other device vice versa.

h. RELAY A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches. Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification. Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays with 4 sets of changeover contacts are readily available. For further information about switch contacts and the terms used to describe them please see the page on switches.

xxvi

Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay. The supplier's catalogue should show you the relay's connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil The relay's switch connections are usually labeled COM, NC, NO:
1.

COM = Common, always connect to this, it is the moving part of the switch.

2.

NC = Normally Closed, COM is connected to this when the relay coil is off.

3.

NO = Normally Open, COM is connected to this when the relay coil is on.

4.

Connect to COM and NO if you want the switched circuit to be on when the relay coil is on.

5.

Connect to COM and NC if you want the switched circuit to be on when the relay coil is off.

xxvii

REFERENCES

1. R. M. Iiiigo, Application of machine vision to traffic monitoring and control, IEEE Trans. Veh. Technol., vol. 38, no. 3, pp. 112122,1989. 2. A. Rosenfeld and C. A. Kak, Digital Picture Processing. 2nd ed. London: Academic Press, 1982. 3. R. Duda and P. E. Hart, Pattern Classification and Scene Analysis. New York Wiley, 1973. 4. A. Perez and R. C. Gonzalez, An iterative thresholding algorithm for image processing, IEEE Trans. Pattern Anal. Machine Intel. Vol. PAMI-9, no. pp. 742-751, 1987. 5. http://www.holtek.com.tw. 6. www.atmel.com 7. Ballany, Antenna Theory ,John Wiley & sons ,second edition,2003. 8. www.ieee.org 9. Kenneth J Ayala,The and 8051 Microcontroller edition,Penram Architecture International

Programming

application,2nd

Publishers(India),New Delhi,1996

xxviii

Anda mungkin juga menyukai