Anda di halaman 1dari 40

SPEED CONTROL OF A.C.

MOTOR BY USING TRIAC CHAPTER 1: INTRODUCTION


In this project we show that how we control the speed of ac motor with the help of thyristor. Here we use one Atmel base microcontroller to provide a automation. We use one seven segment display to display the speed level of Ac load. In this project we provide the output for load variations. The output is connected through Triac control circuit. In this project we use Triac for loads. We provide manual input for this controller to vary the intensity of load. We use increment and decrement switch to vary the speed. Zero cross over signal is provided to the controller via Opto-coupler circuit to pin no 13 of the circuit .

Fig.1. Circuit diagram of Speed Control of A.C. Motor

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


1.1 COMPONENTS USED
Microcontroller = 89S52. MOC 3021= Opto-Coupler For Triac Driver (1) PC 817 Optocoupler For Zero Cross Over Input (1) Seven Segment Display Common Anode (1) npn Transistor (2) pnp Transisitor (3) Diode= In 4007(8) 7805 Regulator Push to on Switches (4) Triac bt 136 (1) Resistor: 16k (4) 1k (2) 470 K (3) 220 K (5) Capacitor 1000 f (2) 10 f (1)

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


1.2 TRIAC
Triac is a power electronic component that conducts in both directions when triggered through gate. .As it can be seen that at time t1, angle of sinusoid is 45' which means that if we triggered Triac at this angle i-e at 45', only shaded blue area will pass through the Triac and hence through the load. Observe that shaded blue are has RMS Voltage less than the pure sinusoid. This is the basic principle by which RMS Voltage control is accomplished. Firing needs a small pulse at gate that can be give through microcontroller also. Similarly at firing angle 90' (firing angle is an angle with reference zero crossing at which the Triac is triggered using gate pulse) , only red part of sinusoid will pass through the Triac giving us the RMS 110V for 220V.

Fig.2. sinusoidal waveform 3

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.3. Basic idea of voltage control Courtesy of Motorola, Inc MOC3021 is an optotriac (product of Motorola) that is used for isolation between power and driving circuitry. Note that when C828 on the base is applied voltage>0.7V, optotriac gets triggered. As the triac gets triggered now, the positive or negative voltage (whatever maybe) get pass through the gate of BT136 (triac) and hence triggered it. It should be noted here that by using above arrangement we can control the RMS voltage in both directions. What needs to be taken care of, is the triggering time or firing angle. There is a need of a zero-crossing detector that will give us the reference for providing delay for desired firing angle. In above example, for firing angle to be 90' for 220V 50Hz AC signal, we need to have a delay of 2.5 ms (t1=2.5ms) right after each zero crossing. Usually MOC3021 is driven through microcontroller, which gives the firing pulse on the basis of interrupt generated by the zero-crossing detector. 4

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.4. circuits used for speed control of a.c. motor 5

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

The above circuit is mainly used as a dimmer and is often used speed controlling of AC motor. There are other versions of the above circuits available that caters for the inductive load which will be discussed later.

1.3 HARDWARE DESCRIPTION


Complete circuit is work on 5 volt regulated power supply. For this purpose we use one step down transformer, two diode and on capacitor circuit. After capacitor we use one 5 volt regulator circuit. Output of the regulator is connected to the 2051 regulator circuit. . One ac signal is also provided to the pin no p3.3 to give zero crossing action. For this purpose we use one full wave rectifier and this pulsating dc is provided to the optocoupler. Optocoupler convert this signal into opposite direction and the same time give a optical isolation to this pin. Output of the phototransistor is connected to the external interrupt no 1. There is a external interrupt in this microcontroller. In this microcontroller is connected to the zero crossing ac voltage. Output pins of the microcontroller is connected to the port p1. Note that output of the microcontroller is active low, P1.1, P1.1, P1.2, P1.3 is connected to the inverter ic 4049. This inverter ic is hex inverter ic. We use two output of the inverter ic to the base of the npn transistor through 470 ohm resistor. Emitter of the NPN transistor is connected to the forward bias. Collector is reverse bias through the Relay coil. One reverse bias diode is connected between relay to protect the transistor when relay off and send a back emf to the transistor. Three more switches are connected to the circuit to on/off and control the speed of the a.c. motor. Firstly we on the switch when the microcontroller send the a.c. motor on signal then p1.6 p1.7 pins and low and output led is also on. Note that led is connected in reverse bias on this pin. P1.4 and P1.5 are connected to two rest pins of the IC 4049. Output available on the p1.5 and p1.6 is inverted by the inverter ic and this output is connected to the pin no 2 of the opto triac. This opto triac is a very special triac. By this triac we control the firing angle of the triac. Pin no 4 and 6 are connected to the triac through load. 6

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


We control the brightness of the triac through the pulse train of the pulse width modulation. As we as we press the up or down key. New pulse width is available on the output. By this output we compare with the zero crossing action and by the result we control the brightness of the lamp or speed of the fan. Pulse width modulation is the most important part of this project to control the speed of the a.c. motor or control the brightness of the lamp.

CHAPTER 2: BASICS OF MOTION CONTROL


Definitions of motion control vary widely in industry today. Depending on the application, motion control can refer to simple on/off control or a sequencing of events, controlling the speed of a motor, moving objects from one point to another or precisely constraining the speed, acceleration, and position of a system throughout a move. Varying interpretations used in the field may confuse engineers working for the first time in some aspect of motion control. Motion control means different things to different sections of industry. As an introduction, this chapter differentiates among motion control techniques. It puts each technique into perspective in terms of where typical applications arise. In many cases, motion control techniques are intimately tied to the controller as well as to the positioning hardware and actuator. No overview of motion control would be complete without a discussion of the various control options that are widely used. These include simple timers and counters, chip level and board level computers, programmable logic controllers, and pneumatic sequencers.

2.1 BASIC TYPES:


Industrial motion control can be divided into three categories:

2.1.1 SEQUENCING:
7

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


Sequencing refers to the control of several operations so that they all occur in a particular order. Perhaps the simplest example of sequential motion is the progression of events that take place through the mechanical linkages of a player piano. When a player piano plays a tune, holes in a paper roll cause piano wires to be struck in a specific sequence. Similarly, opening and closing valves can be sequenced mechanically with camshafts. Sequencing generally becomes too complicated to be handled mechanically in industrial equipment such as conveyor lines, or process machines such as fryers in fast food restaurants. The key factor that defines these as sequencing applications is a need for move and stop on and off control of events that must take place in a certain progression. Soak time or the position of material on an assembly line determine when operations should start and stop. For example, consider a conveyor line that moves parts from one assembly station to another. The controller might position a part at one station until an operator punches an advance button. This might start the part moving to the next station. Here it might enter a cleaning bath for a programmed soak time. At the end of this period, it might move to a new station for final assembly, and so forth. This sort of timing and sequencing is handled through pneumatic, electronic, or electromechanical controllers. Of these, electronic and electromechanical controls are most common. For simple on off control, timers and counters may suffice. These devices contain electrical contacts that can be opened and closed at time intervals that an operator either enters on a keypad or sets with switches. Counters are similar devices that actuate contacts when a count reaches a preset number. The count increments or decrements when sensors such as proximity switches or limit switches sense an object.

2.1.2 SPEED CONTROL:


Speed control refers to applications involving machines run at varying speeds or torques. The source of power for such applications is generally either an internal combustion engine, or an electric, hydraulic, or pneumatic motor. Speed can be controlled either mechanically or, in the case of electric motors electronically.

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


In contrast to mechanical speed control technology, which usually employs gearing or belts to change speed, electronic speed control manipulates applied electrical power to control velocity and torque. Electronic speed control in ac motors employ special amplifiers or drives. These generally vary ac motor speed. Though such electronic controls are more expensive than mechanical speed controls, they provide the advantage of reduced energy costs. Applications for such equipment include fans, blowers, pumps and compressors.

2.1.3 POINT TO POINT CONTROL:


Point to point motion control, in contrast with velocity control, generally refers to applications where something must move from one point to another at a constant speed. An important requirement in such applications is that there are two factors that must be controlled speed and distance. Examples of point to point movement are in x-y tables and in machining, where a tool moves in a straight line while it touches a workplace along one axis. Because such applications demand monitoring and control of both velocity and position, they need a controller to keep track of system operating conditions at any given time. These controllers can be either hardwired electronic logic, and computer or a PLC. In general, the simplest positioning system of this sort might be found on older milling machines. These contain an x-y positioning system for moving the fixture holding the workplace. The positioning system involves ac or dc motors, an adjustable speed drive, clutch, and a position transducer that reads out the position of each table axis. The positioning mechanism for such a system is usually a ball screw.

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

CHAPTER 3: 8051 MICRO CONTROLLER


The 8051 developed and launched in the early 80`s, is one of the most popular micro controller in use today. It has a reasonably large amount of built in ROM and RAM. In addition it has the ability to access external memory. The generic term `8x51` is used to define the device. The value of x defining the kind of ROM, i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates EPROM and x=9 indicates EEPROM or Flash.

3.1 DIFFERENT MICRO CONTROLLERS IN MARKET


PIC One of the famous microcontrollers used in the industries. It is based on RISC Architecture which makes the microcontroller process faster than other microcontroller. INTEL These are the first to manufacture microcontrollers. These are not as sophisticated other microcontrollers but still the easiest one to learn. ATMEL Atmels AVR microcontrollers are one of the most powerful in the embedded industry. This is the only microcontroller having 1kb of ram even the entry stage. But it is unfortunate that in India we are unable to find this kind of microcontroller.

10

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


3.2 HOW TO PROGRAM BLANK CHIP
Intel 8051 is CISC architecture which is easy to program in assembly language and also has a good support for High level languages. The memory of the microcontroller can be extended up to 64k. This microcontroller is one of the easiest microcontrollers to learn. The 8051 microcontroller is in the field for more than 20 years. There are lots of books and study materials are readily available for 8051. First of all we select and open the assembler and wrote a program code in the file. After wrote a software we assemble the software by using internal assembler of the 8051 editor. If there is no error then assembler assemble the software abd 0 error is show the output window.

Fig.5. To Program chip step1

11

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


now assembler generate a ASM file and HEX file. This hex file is useful for us to program the blank chip. Now we transfer the hex code into the blank chip with the help of serial programmer kit. In the programmer we insert a blank chip 0f 89s51 series . these chips are multi time programmable chip. This programming kit is seperatally available in the market and we transfer the hex code into blank chip with the help of the serial programmer kit

Fig.6. To Program Chip step2

12

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.7. To Program Chip step3

13

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.8. To Program Chip step4

14

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC CHAPTER 4: AT 89S52 MICROCONTROLLER


This is a 8-bit Microcontroller with 8K Bytes Flash.

4.1 FEATURES:
Compatible with MCS-51 Products 8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 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 Programmable Serial Channel Low-power Idle and Power-down Modes

4.2 DESCRIPTION:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with 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.

15

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.9. Block Diagram of AT89S52

16

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a six-vector two-level interrupt architecture, 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 hardware reset.

4.3 PIN DESCRIPTION:


VCC: Supply voltage. GND: Ground. PORT 0: Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 can also be configured to be the multiplexed loworder address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull ups are required during program verification. PORT 1: Port 1 is an 8-bit bi-directional I/O port with internal pull ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification.

17

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


Port Pin P1.0 P1.1 Alternate Functions T2(external count input to timer/counter 2), Clock out T2EX(Timer/counter 2 capture/reload trigger and direction control ) Table 1. Alternate functions of port pin1

PORT 2: Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull ups when emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. PORT 3: Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull ups. Port 3 also serves the functions of various special features of the AT89S51, as shown in the following table. Port 3 also receives some control signals for Flash programming and verification.

18

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


Port Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 Alternate functions RXD (serial input port) TXD (serial output port) INTO (external interrupt 0) INT1 (external interrupt 1) TO (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) RD (external data memory read strobe) Table 2. Alternate functions of Port Pin3 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 AT89S52 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.

19

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


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

4.3.1 SPECIAL FUNCTION REGISTERS:


A map of the on-chip memory area called the Special Function Register (SFR) .Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0. TIMER 2 REGISTERS: Control and status bits are contained in registers T2CON 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. INTERRUPT REGISTERS: The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register. DATA MEMORY: The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the special Function Registers. That means the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions that use direct addressing access SFR space. 20

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space. TIMER 0 AND 1: Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in the AT89S51. 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, as shown in Table 3. 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 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 1to-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.

21

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


CAPTURE MODE: In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This bit can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same operation, but a 1- to-0 transition at external input T2EX also causes the current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt. The capture mode is illustrated in Figure 10 AUTO-RELOAD (UP OR DOWN COUNTER): Timer 2 can be programmed to count up or down when configured in its 16-bit auto-reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the SFR T2MOD. Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the T2EX pin.

Fig.10. Timer in Capture Mode Figure 11 shows Timer 2 automatically counting up when DCEN = 0. In this mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at external

22

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


input T2EX. This transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if enabled. Setting the DCEN bit enables Timer 2 to count up or down, as shown in Figure 3. In this mode, the T2EX pin controls the direction of the count. A logic 1 at T2EX makes Timer 2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively. A logic 0 at T2EX makes Timer 2 count down. The timer underflows when TH2 and TL2 equal the values stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be reloaded into the timer registers. The EXF2 bit toggles whenever Timer 2 overflows or underflows and can be used as a 17th bit of resolution. In this operating mode, EXF2 does not flag an interrupt.

23

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.11. Timer 2 auto reload mode (DCEN=0)

24

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.12. Timer 2 auto reload mode (DCEN=1)

Fig.13. Timer 2 in Baud Rate Generator Mode

25

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


4.3.2 BAUD RATE GENERATOR:
Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON (Table 2). Note that the baud rates for transmit and receive can be different if Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other function. Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure 13. The baud rate generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are preset by software. The baud rates in Modes 1 and 3 are determined by Timer 2s overflow rate according to the following equation.

The Timer can be configured for either timer or counter operation. In most applications, it is configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when it is used as a baud rate generator. Normally, as a timer, it increments every machine cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it increments every state time (at 1/2 the oscillator frequency). The baud rate formula is given below.

where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit unsigned integer. Timer 2 as a baud rate generator is shown in Figure 11. This figure is valid only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will not generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus

26

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


when Timer 2 is in use as a baud rate generator, T2EX can be used as an extra external interrupt. Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode, TH2 or TL2 should not be read from or written to. Under these conditions, the Timer is incremented every state time, and the results of a read or write may not be accurate. The RCAP2 registers may be read but should not be written to, because a write might overlap a reload and cause write and/or reload errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.

Fig.14. Timer 2 in clock out mode

4.3.3 PROGRAMMABLE CLOCK OUT


A 50% duty cycle clock can be programmed to come out on P1.0, as shown in Figure 5. This pin, besides being a regular I/O pin, has two alternate functions. It can be programmed to input the external clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz to 4 MHz at a 16 MHz operating frequency. To configure the Timer/Counter 2 as a clock generator, bit C/T2 (T2CON.1) must be cleared and bit T2OE (T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and stops the timer. The clock-out frequency depends on the oscillator frequency and the reload value of Timer 2 capture registers (RCAP2H, RCAP2L), as shown in the following equation. 27

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

In the clock-out mode, Timer 2 roll-overs will not generate an interrupt. This behavior is similar to when Timer 2 is used as a baud-rate generator. It is possible to use Timer 2 as a baud-rate generator and a clock generator simultaneously. Note, however, that the baud-rate and clock-out frequencies cannot be determined independently from one another since they both use RCAP2H and RCAP2L. UART: The UART in the AT89S52 operates the same way as the UART in the AT89C51. 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. These interrupts are all shown in Figure 6. 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. Note that Table shows that bit position IE.6 is unimplemented. In the AT89S51, bit position IE.5 is also unimplemented. 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 TF1, 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.

28

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Table.3. Function of various symbols

Fig.15. interrupt sources

29

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


4.3.4 OSCILLATOR CHARACTERISTICS:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 7. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in Figure 8. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flipflop, but minimum and maximum voltage high and low time specifications must be observed. IDLE MODE: In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. Note that when idle mode is terminated by a hardware reset, the device normally resumes program execution from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory. POWER-DOWN MODE: In the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.

30

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.16 External clock drive configuration

Fig.17. Oscillator connections

Table.4.Status of external Pins during idle & power down modes

31

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


Program Memory Lock Bits The AT89C52 has three lock bits that can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in the following table. When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value and holds that value until reset is activated. The latched value of EA must agree with the current logic level at that pin in order for the device to function properly.

4.4 PROGRAMMING THE FLASH:


The AT89S52 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The Low-voltage programming mode provides a convenient way to program the AT89S52 inside the users system, while the high-voltage programming mode is compatible with conventional third-party Flash or EPROM programmers. The AT89S52 is shipped with either the high-voltage or low-voltage programming mode enabled. The AT89S52 code memory array is programmed byte-bybyte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode. PROGRAMMING ALGORITHM: Before programming the AT89S52, the address, data and control signals should be set up according to the Flash programming mode table and Figure 18 and Figure 19. To program the AT89S52, take the following steps. 1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The bytewrite cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.

32

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


DATA POLLING: The AT89S52 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written data on PO.7. Once the write cycle has been completed, true data is valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. READY/BUSY: The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY. PROGRAM VERIFY: If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled. CHIP ERASE: The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. The chip erase operation must be executed before the code memory can be reprogrammed. READING THE SIGNATURE BYTES: The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows. (030H) = 1EH indicates manufactured by Atmel (031H) = 52H indicates 89C52 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming PROGRAMMING INTERFACE: Every code byte in the Flash array can be written, and the entire array can be erased, by using the appropriate combination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to completion. All major programming vendors offer worldwide support for the Atmel microcontroller series. Please contact your local programming vendor for the appropriate software revision. 33

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Table.5.Flash Programming Modes

Fig. 18 Programming The Flash Memory

34

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.19. Verifying The Flash Memory

Fig.20. Flash Programming And Verification waveform High Voltage Mode Vpp=12V 35

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.21. Flash Programming And Verification waveform Low Voltage Mode Vpp=5V

36

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC CHAPTER 5: LIGHT EMITTING DIODE
Light emitting diode (LED) is basically a P-N junction semiconductor diode particularly designed to emit visible light. There are infrared emitting LEDs which emit invisible light. The LEDs are now available in many colours red, green and yellow. A normal LED emits at 2.4V and consumes MA of current. The LEDs are made in the form of flat tiny P-N junction enclosed in a semi-spherical dome made up of clear coloured epoxy resin. The dome of a LED acts as a lens and diffuser of light. The diameter of the base is less than a quarter of an inch. The actual diameter varies somewhat with different makes. The common circuit symbols for the LED are shown in Fig. It is similar to the conventional rectifier diode symbol with two arrows pointing out. There are two leadsone for anode and the other for cathode. LEDs often have leads of dissimilar length and the shorter one is the cathode. All manufacturers do not strictly adhere this to. Sometimes the cathode side has a flat base. If there is doubt, the polarity of the diode should be identified. A simple bench method is to use the ohmmeter incorporating 3-volt cells for ohmmeter function. When connected with the ohmmeter: one way there will be no deflection and when connected the other way round there will be a large deflection of a pointer. When this occurs the anode lead is connected to the negative of test lead and cathode to the positive test lead of the ohmmeter.

Fig.22.LED and LED symbol

37

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


If low range (Rxl) of the ohmmeter is used the LED would light up in most cases because the low range of ohmmeter can pass sufficient current to light up the LED. Another safe method is to connect the test circuit shown in Fig. 2. Use any two dry cells in series with a current limiting resistor of 68 to 100 ohms. The resistor limits the forward diode current of the LED under test to a safe value. When the LED under test is connected to the test terminals in any way: if it does not light up, reverse the test leads. The LED will now light up. The anode of the LED is that which is connected to the A terminal (positive pole of the battery). This method is safe, as reverse voltage can never exceed 3 volts in this test.

5.1 ELECTRICAL CHARACTERISTICS OF LEDS:


Electrically, a LED is similar to the conventional diode in that it has relatively low forward voltage threshold. Once this is exceeded the junction has a low slope resistance and conducts current readily. An external resistor must limit this current. Forward voltage drew across red LED is nominally 1.6 V but spread with commercial diodes, it may be as high as 2 volts or so, while the Green LED drops 2.4V. This difference accounts for use of lower limiting resistor used with the Green LED. Another important parameter of the LED is its maximum reverse voltage rating. For typical Red device it is of the order of 3 volts. But for Green LED it is somewhat higher5 to 10 volts. The LED produces light only when a d.c. current is passed in the forward direction and the amount of light emitted by a LED is proportional to the forward current over a broad range. It means that light intensity increases in an approximately linear manner with increasing current

38

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC


5.2 SEVEN SEGMENT DISPLAY DECIMAL DISPLAY:
A popular type consists of seven small, bar-shaped LED segment arranged so that depending on which combinations are energized, the numbers 0 to 9 light up. All the LED cathodes (or sometimes anodes) are joined to form a common connection. Current limiting resistors are required (e.g. 270 ohms), preferably one per segment. Common cathode method of connecting an array of display elements. The main requirements for a suitable LED material are: 1) It must have on energy gap of appropriate width. 2) Both P and N types must exist, preferably with low resistivities. 3) Efficient radioactive pathways must be present. 4) Generally, energy gaps greater than or equal to about 2 are required.

5.2.1 SOME COMMERCIAL LED MATERIALS:


Gallium arsenide (Ga As) doped with Si Gallium Phosphide (GaP) doped with N & Bi Gallium arsenide Phosphide (Ga As1-x Px) Gallium aluminium arsenide (Gax Al1-x As)

5.3 LED CONSTRUCTIONS:


To reduce reflection losses in LEDs there are two obvious ways: a) The first is to ensure that most rays strike the surface at less than the critical angle. This may be achieved by shaping the semiconductor /air interface into a hemisphere. b) The second technique is to encapsulate the junction in a transparent medium of high refractive index. This is usually a plastic material with refractive index of about 1.5. Moulding the plastic into an approximately hemispherical shape can minimize the losses at the plastic lair interface.

39

SPEED CONTROL OF A.C. MOTOR BY USING TRIAC

Fig.23. cut view of LED

40

Anda mungkin juga menyukai