Free Essay

Phase Angle Control

In:

Submitted By yamame
Words 11939
Pages 48
TECHNICAL UNIVERSITY OF KENYA SCHOOL OF ENGINEERING SCIENCE AND TECHNOLOGY ELECTRICAL AND ELECTRONICS DEPARTMENT P.O Box 52428-00200 NAIROBI FINAL YEAR PROJECT PROJECT TITLE: PHASE-ANGLE CONTROL OF SCR USING AT89C51

BY Yamame Gerrishom Kennedy

ADMISSION NO: 109/01670

SUPERVISOR: MR. BONIFACE CHOMBA
`

May 20th, 2014,

TABLE OF CONTENTS.
DECLARATION.......................................................................................................................................i ACKNOWLEDGEMENT………………………………..….……………………………………………………………………………………ii DEDICATION………………………………..……………………………………………………………………………..………………..……iii ABSTRACT………………………………..………………………………………………………………………………………………………..iv CHAPTER ONE………………………………………………………………………………………………………………………….…………1 INTRODUCTION…………………………………………………………………………………………………………………..………1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 PROJECT BACKGROUND………………………………………………………………………..…………..1

PROBLEM STATEMENT……………………………………………………………………………………………………3 PROPOSED SOLUTION…………………………………………………………………………………………………….3 SYSTEM OBJECTIVES……………………………………………………………………………………………………….5 SCOPE OF THE PROJECT/SPECIFICATIONS……………………………………………………………………….6 BLOCK DIAGRAM……………………………………………………………………………………..…………………….6 DESCRIPTION OF THE BLOCK DIAGRAM………....………………………………………………………………7

CHAPTER TWO………………………………………………………………………………………………………………….…………………8 2.1 2.2 2.3 EXISTING SOLUTIONS……………………………………………………………………………………………………..8 LITERATURE REVIEW………………………………………………………………………………………………………9 CONCLUSION……………………………………………………………………………………………………………….10

CHAPTER THREE……………………………………………………………………………………………………………………….……….11 HARDWARE IMPLEMENTATION………………………………………………………………..…………………….………..11 3.0 3.1 COMPLETE CIRCUIT DIAGRAM………………………………………………………………………………………11 POWER SUPPLY AND ZERO CROSS DETECTION UNIT CIRCUIT……………………………….………11 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2 ZERO CROSS DETECTING UNI……………………………………………………………..13

OPTOCOUPLER THEORY………………………………………………………………………………….16 TRIAC THEORY…………………………………………………………………………………………………17 LM7805 VOLTAGE REGULATOR……………………………………………………………………….19 BC 547 TRANSISTOR………………………………………………………………………………………..20

LCD 16X2 (LM016L)………….…………………………………………………………………………………..………22

3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.2.10 3.2.11 3.2.12 3.2.13

PIN DESCRIPTION…………………………………………………………………………………….………22 DDRAM-DISPLAY DATA RAM…………………………………………………………………….……..25 CGROM-CHARACTER GENERATOR ROM…………………………………………………………..25 CGRAM………………………………………………………………………………………………..………….27 BF-BUSY FLAG………………………………………………………………………………………………….27 INSTRUCTION REGISTER (IR) AND DATA REGISTER (DR)…………………………………..27 COMMANDS AND INSTRUCTION SET……………………………………………………………….27 INITIALIZATION BY INSTRUCTIONS……………………………….…………………………….…….27 LCD ENTRY MODE……………………………….…………………………………….……………….…….30 READING THE BUSY FLAG……………….…………………………………….………………….…….30 SENDING COMMANDS TO LCD……………….…………………………………….………….…….30 CGRAM AND CHARACTER BUILDING……………….………………………………….………….30 INTRODUCTION 4 BIT LCD INTERFACING……………….……………………………………….30

3.2.14 SENDING DATA/COMMAND IN 4-BIT MODE……………….………………………………….30 3.3 MICROCONTROLLER (AT89C51)……………………………………………………………………………………36 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 FEATURES………………………………………………………………………………………………………..36 PIN DIAGRAM…………………………………………………………………………………….……………37 PIN DESCRIPTION…………………….………………………………………………………....…………..38 PROGRAM CODING……………………………………………………………………………….…………44 C SOURCE CODE………………………………………………………………………………………………48

CHAPTER FOUR…………………………………………………………………………………………………………………………………57 4.0 4.1 PROJECT SCHEDULE……………………………………………………………...……………………………………..57 GANTT CHART…………………………….………………………………………………………………………………..58

CHAPTER FIVE…………………………………………………………………………………………………………………………………..59 5.1 PROJECT BUDGET…………………………………………………………………………………………………………59

CHAPTE SIX……………………………………………………………………………………………………………………………………….60 REFERENCES……………………………………………………………………………………….………………………….…………60 APPENDIX…………………………………………………………………………………………….…………..................................61

DECLARATION: I hereby declare that this business plan is my original work and has not been presented for the examination or any academic award.

SIGNATURE: DATE:

The project has been submitted for the examination to the Technical University College with the approval of the supervisor. SIGNATURE:

Mr. Boniface Chomba

ACKNOWLEDGEMENT. I wish to express my sincere gratitude and appreciation to my supervisor Mr. Chomba, who has guided me through this project. I also extend my special thanks to my fellow colleagues B Eng. 2014 for their academic and brotherly support. Exceptional thanks go to my family at large who have been there through my life and offered financial, moral, encouragement and physical support in my education.

DEDICATION. I dedicate this project to my sincere and passionate parents Mr. Moses Yamame and Mrs. Truphena Mukite for financial support, also to the world of technology where my passion solely lies. May God bless them.

ABSTRACT: Since the development of SCR power controllers in the late 1950’s, the power handling capabilities of the devices has steadily increased from a few hundred watts to many megawatts. Due to the ever increasing reliability and decreasing costs of the devices, the use of the power controllers in industrial applications has increased dramatically and they are now used in almost every major industry. A Silicon Controlled Rectifier (SCR) is a semiconductor rectifier that has the added feature of controllability. The SCR is capable of conducting OR blocking current in the forward direction, depending upon the gate signal. The SCR, like the diode, will always block current flow in the negative or reverse direction. The act of controlling or turning on an SCR, (i.e. telling it to conduct current) is also known as gating or firing the SCR. If only one SCR in an AC circuit is fired, only one – half of the AC current waveform is conducted. Phase control (PFC), also called phase cutting, is a method of pulse-width modulation (PWM) for power limiting, applied to AC voltages. It works by modulating a thyristor, SCR, triac, thyratron, or other such gated diode-like devices into and out of conduction at a predetermined phase of the applied waveform. In order to deliver maximum power to the load, both halves of the AC waveform must be conducted. To achieve full wave conduction, two SCR’s must be used. They must be connected in parallel but opposite directions.

Figure i: Diagram of a silicon controlled rectifier. Current flows when the device is gated. The device will only turn off when the gate is turned off and the voltage reaches zero. The device will only conduct current in the positive, forward direction, if it is gated. Phase fired control is often used to control the amount of voltage, current or power that a power supply feeds to its load. It does this in much the same way that a pulse-width modulated (PWM) supply would pulse on and off to create an average value at its output. If the supply has a DC output, its time base is of no importance in deciding when to pulse the supply on or off, as the value that will be pulsed on and off is continuous. PFC differs from PWM in that it addresses supplies that output a modulated waveform, such as the sinusoidal AC waveform that the national grid outputs. Here, it becomes important for the supply to pulse on and off at the correct position in the modulation cycle for a known value to be achieved; for example, the controller could turn on at the peak of a waveform or at its base if the cycle's time base were not taken into consideration. Phase-fired controllers take their name from that fact that they trigger a pulse of output at a certain phase of the input's modulation cycle. In essence, a PFC is a PWM controller that can synchronize itself with the modulation present at the input.

Most phase fired controllers use thyristors or other solid state switching devices as their control elements. Thyristor-based controllers may utilize gate turn-off (GTO) thyristors, allowing the controller to not only decide when to switch the output on but when to turn it off, rather than having to wait for the waveform to return to zero.

CHAPTER ONE INTRODUCTION
1.1 PROJECT BACKGROUND. The SCR stand for Silicon Control Rectifier, it is used in industries because it can handle high values of current and voltage.

Figure 1.1: the SCR symbol Silicon-controlled rectifiers (SCR) are solid-state semiconductor devices that are usually used in power switching circuits. SCR controls the output signal by switching it ‘on’ or ‘off’, thereby controlling the power to the load in context. The two primary modes of SCR control are phaseangle fired-where a partial waveform is passed to regulate the power. There are several ways to control the firing angle of SCR. The power delivered to a load may be regulated or proportioned by SCR power controllers using either the phase-angle or the integral cycle (zero-cross voltage switching) control mode. Each control mode has its own specific advantages and disadvantages and each application should be reviewed to determine the most compatible mode of control. Phase-angle control provides a very fine resolution of power and is used to control fast responding loads such as tungsten-filament lamps or loads in which the resistance changes as a

function of temperature. Phase angle control is required if the load is transformer coupled or inductive. Phase-angle controllers are typically more expensive than zero-cross controllers because the phase-angle circuit requires more sophistication than does a zero cross circuit. Phase-angle control of three-phase power requires SCR’s in all three legs and is appreciably more expensive than zero-cross control which only requires SCR’s in two of the three legs. Zero-cross: The term zero-cross or synchronous operation of SCR.s is derived from the fact that the SCR.s are turned on only when the instantaneous value of the sinusoidal waveform is zero. In zero-cross operation, power is applied for a number of continuous half-cycles and then removed for a number of half-cycles to achieve the desired load power in the same manner as power would be controlled with a mechanical switching device. The difference is that the SCR controllers always switch power when the instantaneous value of the applied voltage is zero. Also, the frequency of the on-off cycles can be extremely fast because there is no limit to the number of switching operations the SCR can perform. Zero-cross controllers can provide two rather distinctively different types of control. Time proportioning control is sometimes used when switching large amounts of current can cause voltage variations which affect ambient lighting or other equipment. The disadvantage is that power is applied in longer bursts which can in turn cause control problems and shorten heater life. Distributive control is typically somewhat less expensive, provides a much faster cycle rate giving better controllability and longer heater life. It can also be used with much faster responding loads than can time proportioning. In the phase-angle controller, the firing pulse is delayed to turn on the SCR in middle of every half cycle. This means that every time a part of an AC cycle is cut, the power to the load also gets cut. To deliver more or less power to the load, the power to the load also gets cut. To deliver more or less power to the load. The phase angle is increased or decreased, thereby controlling the throughput power.

1.2.

Problem statement

This project is developed to improve the efficiency of silicon controlled rectifiers by making use of the microcontroller AT89C51. This article describes a microcontroller AT 89C51-based-angle controller. A microcontroller can be programmed to fire SCR over the full range of half cycles from 0 to 180º - to get a good linear relationship between the phase angle and the delivered output power. Phase-angle control provides a very fine resolution of power and is used to control fast responding loads such as tungsten-filament lamps or loads in which the resistance changes as a function of temperature. Phase-angle control is required if the load is transformer-coupled or inductive 1.3. Proposed solution

This project will utilize the microcontroller to improve the firing efficiency of the SCR in switching power systems. The Silicon Control Rectifier SCR start conduction when it is forward biased.
For this purpose the cathode is kept at negative and anode at positive. When positive clock pulse is applied at the gate the SCR turns ON.

When forward bias voltage is applied to the Silicon Control Rectifier SCR, the junction J1 and J3 become forward bias while the junction J2 become reverse bias. When we apply a clock pulse at the gate terminal, the junction J2 become forward bias and the Silicon Control Rectifier SCR start conduction. The Silicon Control Rectifier SCR turn ON and OFF very quickly, At the OFF state the Silicon Control Rectifier SCR provide infinity resistance and in ON state, it offers very low resistance, which is in the range of 0.01O to 1O. SCR Firing & Triggering The Silicon Control Rectifier SCR is normally operated below the forward break over voltage (VBO). To turn ON the Silicon Control Rectifier SCR we apply clock pulse at the gate terminal

which called triggering of Silicon Control Rectifier, but when the Silicon Control Rectifier SCR turned ON, now if we remove the triggering voltage, the Silicon Control Rectifier SCR will remain in ON state. This voltage is called Firing voltage. MAJOR ADVANTAGES SCR power controllers provide a relatively economical means of power control. SCR power controllers cost less and are more efficient than saturable core reactors and variable transformers. Compared to contactors, SCR power controllers offer a much finer degree of control and do not suffer from the maintenance problems of mechanical devices. Features and benefits of SCR power controllers over other forms of control include: High reliability Because the SCR power controller is a solid-state device, there are no inherent wear-out modes. Thus, they provide virtually limitless and trouble free operation. Infinite resolution Power, current or voltage can be controlled from zero to 100% with infinite resolution. This capability allows extremely accurate, step less control of the process. Extremely fast response The SCR controller can switch load power on and off extremely fast providing the means to respond rapidly to command changes, load changes and power supply changes. This feature allows the control of fast responding loads and eliminates the negative effects of variations in load or supply voltages that can occur with other types of control. Selectable control parameters The SCR power controller can control the average load voltage, the RMS value of the load voltage, the RMS or the average load current or load power. It can also provide useful features such as current and voltage limiting. The ability to control the desired parameter as a function

of a command signal and to incorporate limiting features is not normally available with other types of control. Minimum maintenance Because they are solid state there are no moving parts to wear out or replace. Therefore, the routine replacement required in some forms of control is eliminated.

1.4.

System objectives.

The goal of this project is to produce an accurate phase angle correction of an AC firing signal to the load as possible. The electronic circuit controls the operation of the SCR.s such that the desired energy applied to the load is proportional to the command signal. Important tasks of the circuit include: Timing: It is imperative, particularly in applications involving inductive loads such as transformers, that no DC be applied to the load, DC components can also cause supply transformers to overheat. This requires that the ON time of the back-to-back SCR.s be exactly equal. Modern circuits use sophisticated digital phase lock loop techniques which are immune to the electrical noise and varying voltages that are often found in industrial environments. Electrical Isolation: The command signal must be isolated from the supply and load voltage. Plus, excellent isolation is required between the circuits controlling the signals to the gates of the SCR.s to prevent false turn-on of the SCR.s.

1.5.

Scope of the project/specifications.

In order to achieve the project objective, the following scopes will be covered: i. ii. Operation of an SCR This project will utilize a microcontroller AT89C51 using programming language C and a few discreet components. 1.6. BLOCK DIAGRAM

AC SOURCE 50Hz

RECTIFIER AND REGULATORS

MICROCONTROLLER OPTOOSCILLATORS AC IN 240V

ZERO CROSS DETECTOR LOAD SCR’S

Figure 1.2: Block diagram

1.7. DECRIPTION OF THE BLOCK DIAGRAM. The block diagram mainly consists of a microcontroller AT89C51 for controlling the SCR,a zero cross detector circuit, opto oscillators, voltage and current measurement units and a load, in this case a lamp.  Current transformer used to reduce voltages and currents to levels handled by the zero cross detection unit.  Zero cross detector is used for detecting the point where the voltages crosses zero in either direction.  Basically, the zero-crossing detector circuit interrupts the microcontroller after every 10 ms. this interrupt commands the microcontroller to generate some delay (in the range of 1 ms to 9ms). The user can increase or decrease the delay in intervals of 1 ms using switches. The SCR is then fired through the opto-coupler. This repeats after every 10 ms.  Port 0 (P0.0 though P0.7) of AT89C51 is used for interfacing data input pins D0 through D7 of the LCD module. Port pins P2.6, P2.5 and P2.7 of the microcontroller control the registers select (RS), read/write (R/W) and enable (E) input pin of the LED module, respectively.

CHAPTER 2

LITERATURE REVIEW
2.1 Existing solutions In this chapter, literature review that related to this study case will be identify and study. The power delivered to a load may be regulated or proportioned by SCR power controllers using either the phase-angle or the integral cycle (zero-cross voltage switching) control mode. Each control mode has its own specific advantages and disadvantages and each application should be reviewed to determine the most compatible mode of control. Phase-angle: In phase-angle control each SCR of the back-to-back pair is turned on for a variable portion of the half-cycle that it conducts. Power is regulated by advancing or delaying the point at which the SCR is turned ON within each half cycle. Light dimmers are an example of phase-angle control.

Figure 2.1: Variable portions of half cycles that conduct

2.2. Literature review

In this thesis, a hardware configuration and software specification for two prototypes that was developed and able to control voltage, firing time of the SCR and generally the ability of the SCR to control power to the load with precision. Zero-cross: The term zero-cross or synchronous operation of SCR’s is derived from the fact that the SCR’s are turned on only when the instantaneous value of the sinusoidal waveform is zero. In zero-cross operation, power is applied for a number of continuous half-cycles and then removed for a number of half-cycles to achieve the desired load power in the same manner as power would be controlled with a mechanical switching device. The difference is that the SCR controllers always switch power when the instantaneous value of the applied voltage is zero. Also, the frequency of the on-off cycles can be extremely fast because there is no limit to the number of switching operations the SCR can perform. Zero-cross controllers can provide two rather distinctively different types of control. Time proportioning control is sometimes used when switching large amounts of current can cause voltage variations which affect ambient lighting or other equipment. The disadvantage is that power is applied in longer bursts which can in turn cause control problems and shorten heater life. Distributive control is typically somewhat less expensive, provides a much faster cycle rate giving better controllability and longer heater life. It can also be used with much faster responding loads than can time proportioning. Zero-cross time proportioning: Zero-cross time proportion control is accomplished with a fixed or constant time base, therefore the total of power “ON” time and power “OFF” time is always equal to a fixed value. For example, if the time base is ten seconds and the desired power is 50%, then power is applied for 5 seconds and removed for 5 seconds. If the desired power were 25% then power is applied for 2.5 seconds and removed for the remaining period of 7.5 seconds. The disadvantage of time proportioning particularly as the time base is increased is that the load temperature varies considerably between the on-off cycles. This can shorten the life of heater elements and decrease the ability to obtain precise process control. Distributive zero-cross: Distributive zero-cross does not use a fixed or constant time base as is used in time proportioning. The technique used by Control Concepts applies load power for 3 electrical cycles and removes load power for 3 electrical cycles at 50% power. At lower power requirements the controller will apply power for 3 electrical cycles and is then off for the appropriate number of electrical cycles. For example, at 25% power the controller is on for 3 electrical cycles and off for 9 electrical cycles, or on for 3 electrical cycles out of 12.

At higher power levels the controller is off for three electrical cycles and on for the appropriate number of electrical cycles. For example at 75% power the controller is on for 9 electrical cycles and off for 3 electrical cycles. 2.3. Conclusion. The silicon controlled rectifier SCR, is one of several power semiconductor devices along with Triacs (Triode AC), Diacs (Diode AC) and UJT’s (Unijunction Transistor) that are all capable of acting like very fast solid state AC switches for controlling large AC voltages and currents, and for the Electronics student are very handy devices for controlling AC motors, lamps and phase control. The thyristor is a three-terminal device labelled: “Anode”, “Cathode” and “Gate” and consisting of three PN junctions which can be switched “ON” and “OFF” at an extremely fast rate, or it can be switched “ON” for variable lengths of time during half cycles to deliver a selected amount of power to a load. The operation of the thyristor can be best explained by assuming it to be made up of two transistors connected back-to-back as a pair of complementary regenerative switches as shown.

CHAPTER 3(THREE) HARDWARE IMPLEMENTATION
3.0 COMPLETE CIRCUIT DIAGRAM

Figure 3.0: complete circuit diagram of phase angle control of SCR using AT89C51

3.1

POWER SUPPLY AND ZERO CROSS DETECTION CIRCUIT

In this power supply we are using step-down transformer, IC regulators, Diodes, Capacitors and resistors. Explanation: - The input supply i.e., 230V AC is given to the primary of the transformer (Transformer is an electromechanical static device which transform one coil to the other without changing its frequency) due to the magnetic effect of the coil the flux is induced in the primary is transfer to the secondary coil. The output of the secondary coil is given to the diodes.

Here the diodes are connected in bridge type. Diodes are used for rectification purposes. The output of the bridge circuit is not pure dc, somewhat rippled ac is also present. For that capacitor is connected at the output of the diodes to remove the unwanted ac, capacitor are also used for filtering purpose. Both negative terminal of the diode (D2 & D3) is connected to the positive terminal of the capacitor and thus the input of the IC Regulator (7805 & 7812). Here we are using Voltage regulators to get the fixed voltage to our requirements.” Voltage regulator is a CKT that supplies a constant voltage regardless of changes in load currents. These IC’s are designed as fixed voltage regulators and with adequate heat sinking can deliver o/p currents in excess of 1A. The o/p of the IC regulator is given to the LED through resistors, When the o/p of the IC i.e. The voltage is given to the LED, it makes its forward bias and thus LED gloves on state and thus the positive voltage is obtained. Similarly, for negative voltage, here the both positive terminals of the diodes (D1 & D4) is connected to the negative terminals of the capacitors and thus to the input of the IC regulator with respect to ground. The o/p of the IC regulator (7912) which is a negative voltage is given to the terminal of LED, through resistor, which makes it forward bias, LED conducts and thus LED gloves in ON state and thus the negative voltage is obtained. The mathematical relation for ac input and dc output is

Vdc=Vm ¤3.141 (before capacitor) Vd=Vm (after capacitor)

Figure 3.1: power supply

3.1.1

ZERO CROSSING DETECTING UNIT

As the name indicates the zero crossing detector is a device for detecting the point where the voltage crosses zero in either direction. As shown in the circuit diagram the first section is a bridge rectifier, which provides full wave rectified output. This is applied to the base of the transistor through a base resistor, R2. The capacitor charges to maximum of the bridge rectified output through the diode, D2. This charge is available to the transistor as VCC. The capacitance value is kept large in order to minimize ripple and get perfect dc. The transistor remains OFF until the Cut-in voltage VBE is reached. During the OFF period of the transistor the output will be high and approximately equal to VCC. Once the transistor is ON and IB increases according to the input wave, the transistor moves slowly towards saturation where the output reduces to the saturation voltage of the transistor which is nearly equal to zero Initially VBE = Cut-in voltage of diode, the capacitor will charge

through the diode Vm where Vm is the maximum amplitude of the rectified wave. Now the diode is reverse biased and hence does not provide a discharging path for the capacitor, which in turn has two effects. Variation in VCC. It will provide base current to the transistor in the region where both diode and transistor are OFF. Thus an output square wave is produced whenever the input voltage crosses zero thereby acting as a zero crossing detector. The zero-cross detector section. Fig1.6 shows the circuit diagram of the zero-crossing detector and the power supply. The main section of the circuit are a rectifier, regulated power supply and zero-crossing detector. The 230V AC mains is stepped down by transformer X1 to deliver the secondary output of 9V, 500mA. The transformer output of 9v, 300mA. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D1 through D4 And then regulated by IC 7805 (ic3). Capacitors C2 and C3 are used for passing the ripples present in the regulated 5V power supply. A capacitor above 10µF is connected across the output of the regulator IC, while diode D6 protects the regulator IC in case their input is short to ground. LED5 acts as the Power-on indicator and resistor R5 limits the current through LED5. This regulated 5V is also used as biasing voltage for both transistors (T1and T2) and the control section. A pulsating DC voltage is applied to the base of transistor T1 through diode D5 and resistors R1 and R2. When the pulsating voltage goes to zero, the collector of transistor T1 goes high. This is used for detecting the pulse when the voltage is zero. Finally, the detected pulse from ‘C’ is fed to the microcontroller of the control section.

Figure 3.2: Zero cross detection circuit

Figure 3.3: Output waveform of a zero crossing detector

A zero crossing detector literally detects the transition of a signal waveform from positive and negative, ideally providing a narrow pulse that coincides exactly with the zero voltage condition. At first glance, this would appear to be an easy enough task, but in fact it is quite complex, especially where high frequencies are involved. In this instance, even 1 kHz starts to present a real challenge if extreme accuracy is needed. 3.1.2 OPTOCOUPLER THEORY:

INTRODUCTION This application note discusses the common mode transient immunity (CMTI) properties of optocouplers. It covers phototransistor output and optically coupled logic gates. Common mode transient immunity, (CMTI), common mode transient rejection (CMTR), or common mode rejection (CMR), are a measure of ability of an optocoupler‘s output amplifier to reject fast transient noise signals that are present between the input (LED) and the output side of the optocoupler. To characterize the CMTI behavior of an optocoupler it is necessary to describe it with two values: • VCM • dV/dt - rate of rise or fall of the common mode voltage(dV/dt = VCM/tr or dV/dt = VCM/tf) Only when both values are specified can the CMTI be evaluated properly. The ability of the optocoupler to withstand a given common mode transient is called common mode transient immunity at logic low level or logic high level; the abbreviation is CML or CMH. The optocoupler fails if its output ‘high‘ voltage drops below 2.0 V or its output ‘low‘ voltage rises above 0.8 V, in the presence of the common mode transient noise signal.

Figure 3.4: images of optocoupler

3.1.3

TRIAC THORY:

TRIAC is a bidirectional conducting device .it can conduct in both directions from mt2 to mt1 and also from mt1 to mt2.it has three terminals namely MT1, MT2, GATE.

It has four quadrant operations

Figure 3.5: four quadrant operation LATCH AND HOLD CHARACTERISTICS In order for the thyristor to remain in the on state when the trigger signal is removed, it is necessary to have sufficient principal current flowing to raise the loop gain to unity. The principal current level required is the latching current, IL. Although triacs show some dependency on the gate current in quadrant II, the latching current is primarily affected by the temperature on shorted emitter structures In order to allow turn off, the principal current must be reduced below the level of the latching current. The current level where turn off occurs is called the holding current, IH. Like the latching current, the holding current is affected by temperature and also depends on the gate impedance.

Figure 3.6: TRIAC voltage characteristics

3.1.4

LM7805 Voltage regulator

7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear voltage regulator ICs. The voltage source in a circuit may have fluctuations and would not give the fixed voltage output. The voltage regulator IC maintains the output voltage at a constant value. The xx in 78xx indicates the fixed output voltage it is designed to provide. 7805 provides +5V regulated power supply. Capacitors of suitable values can be connected at input and output pins depending upon the respective voltage levels. Advantages


78xx series ICs do not require additional components to provide a constant, regulated source of power, making them easy to use, as well as economical and efficient uses of space. Other voltage regulators may require additional components to set the output voltage level, or to assist in the regulation process. Some other designs (such as a switched-mode power supply) may need substantial engineering expertise to implement. 78xx series ICs have built-in protection against a circuit drawing too much power. They have protection against overheating and short-circuits, making them quite robust in most applications. In some cases, the current-limiting features of the 78xx devices can provide protection not only for the 78xx itself, but also for other parts of the circuit.



Disadvantages


The input voltage must always be higher than the output voltage by some minimum amount (typically 2.5 volts). This can make these devices unsuitable for powering some devices from certain types of power sources (for example, powering a circuit that requires 5 volts using 6-volt batteries will not work using a 7805). As they are based on a linear regulator design, the input current required is always the same as the output current. As the input voltage must always be higher than the output voltage, this means that the total power (voltage multiplied by current) going into the 78xx will be more than the output power provided. The extra input power is dissipated as heat. This means both that for some applications an adequate heat sink must be provided, and also that a (often substantial) portion of the input power is wasted during the process, rendering them less efficient than some other types of power supplies. When the input voltage is significantly higher than the regulated output voltage (for example, powering a 7805 using a 24 volt power source), this inefficiency can be a significant issue



Figure 3.7: LM7805 series packaging image 3.1.5 BC 547 NPN epitaxial silicon transistor

BC547 is an NPN bi-polar junction transistor. A transistor, stands for transfer of resistance, is commonly used to amplify current. A small current at its base controls a larger current at collector & emitter terminals. BC547 is mainly used for amplification and switching purposes. It has a maximum current gain of 800. Its equivalent transistors are BC548 and BC549. The transistor terminals require a fixed DC voltage to operate in the desired region of its characteristic curves. This is known as the biasing. For amplification applications, the transistor is biased such that it is

partly on for all input conditions. The input signal at base is amplified and taken at the emitter. BC547 is used in common emitter configuration for amplifiers. The voltage divider is the commonly used biasing mode. For switching applications, transistor is biased so that it remains fully on if there is a signal at its base. In the absence of base signal, it gets completely off.

Figure 3.8: Image of a BC547 Transistor Features.

   

Switching and amplifier High-voltage:BC546,VCEO=65v Low noise Compliment to BC556, BC557, BC558 and BC560

3.2

LCD 16×2 (LM016L)

3.2.1 PIN Description The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters, whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers. Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are extra in both for back-light LED connections). Pin description is shown in the table below.

Figure 3.9: Image of a LM016L LCD display

Pin No. Pin no. 1 Pin no. 2 Pin no. 3

Name VSS VCC VEE

Description Power supply (GND) Power supply (+5V) Contrast adjust 0 = Instruction input 1 = Data input 0 = Write to LCD Module 1 = Read from LCD module

Pin no. 4

RS

Pin no. 5

R/W

Pin no. 6 Pin no. 7 Pin no. 8 Pin no. 9 Pin no. 10 Pin no. 11 Pin no. 12 Pin no. 13 Pin no. 14

EN D0 D1 D2 D3 D4 D5 D6 D7

Enable signal Data bus line 0 (LSB) Data bus line 1 Data bus line 2 Data bus line 3 Data bus line 4 Data bus line 5 Data bus line 6 Data bus line 7 (MSB) Table 1: Character LCD pins with 1 Controller

Pin No. Pin no. 1 Pin no. 2 Pin no. 3 Pin no. 4 Pin no. 5

Name D7 D6 D5 D4 D3

Description Data bus line 7 (MSB) Data bus line 6 Data bus line 5 Data bus line 4 Data bus line 3

Pin no. 6 Pin no. 7 Pin no. 8 Pin no. 9 Pin no. 10 Pin no. 11 Pin no. 12 Pin no. 13 Pin no. 14 Pin no. 15 Pin no. 16

D2 D1 D0 EN1

Data bus line 2 Data bus line 1 Data bus line 0 (LSB) Enable signal for row 0 and 1 (1stcontroller) 0 = Write to LCD module 1 = Read from LCD module 0 = Instruction input 1 = Data input

R/W

RS

VEE

Contrast adjust

VSS

Power supply (GND)

VCC

Power supply (+5V)

EN2

Enable signal for row 2 and 3 (2ndcontroller)

NC

Not Connected

Table 1: Character LCD pins with 2 Controller

3.2.2

DDRAM – Display Data RAM

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. So whatever you send on the DDRAM is actually displayed on the LCD. For LCDs like 1×16, only 16 characters are visible, so whatever you write after 16 chars is written in DDRAM but is not visible to the user.

Figures below will show you the DDRAM addresses of 1 Line, 2 Line and 4 Line LCDs.

Figure 3.10: DDRAM addresses of LCD lines 3.2.3 CGROM – Character Generator ROM

The character generator ROM generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes (see Figure 5 and Figure 6 for more details). It can generate 208 5 x 8 dot character patterns and 32 5 x 10 dot character patterns. User defined character patterns are also available by mask-programmed ROM.

Fig 3.11: LCD characters code map for 5×8 dots

Fig 3.12: LCD characters code map for 5×10 dots

3.2.4 CGRAM – Character Generator RAM As clear from the name, CGRAM area is used to create custom characters in LCD. In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight character patterns can be written, and for 5 x 10 dots, four character patterns can be written. Later in this tutorial i will explain how to use CGRAM area to make custom character and also making animations to give nice effects to your application. 3.2.5 BF – Busy Flag

Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of delay. For the LCD processing. To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process.

3.2.6

Instruction Register (IR) and Data Register (DR)

There are two 8-bit registers in HD44780 controller Instruction and Data register. Instruction register corresponds to the register where you send commands to LCD e.g. LCD shift command, LCD clear, LCD address etc. and Data register is used for storing data which is to be displayed on LCD. When send the enable signal of the LCD is asserted, the data on the pins is latched in to the data register and data is then moved automatically to the DDRAM and hence is displayed on the LCD. Data Register is not only used for sending data to DDRAM but also for CGRAM, the address where you want to send the data, is decided by the instruction you send to LCD. We will discuss more on LCD instruction set further in this tutorial. 3.2.7 Commands and Instruction set

Only the instruction register (IR) and the data register (DR) of the LCD can be controlled by the MCU. Before starting the internal operation of the LCD, control information is temporarily stored into these registers to allow interfacing with various MCUs, which operate at different speeds, or various peripheral control devices. The internal operation of the LCD is determined by signals sent from the MCU. These signals, which include register selection signal (RS), read/write signal (R/W), and the data bus (DB0 to DB7), make up the LCD instructions (Table 3). There are four categories of instructions that:

   

Designate LCD functions, such as display format, data length, etc. Set internal RAM addresses Perform data transfer with internal RAM Perform miscellaneous functions

LCD Initialization Before using the LCD for display purpose, LCD has to be initialized either by the internal reset circuit or sending set of commands to initialize the LCD. It is the user who has to decide whether an LCD has to be initialized by instructions or by internal reset circuit. We will discuss both ways of initialization one by one. Initialization by internal Reset Circuit An internal reset circuit automatically initializes the HD44780U when the power is turned on. The following instructions are executed during the initialization. The busy flag (BF) is kept in the busy state until the initialization ends (BF = 1). The busy state lasts for 10 ms after VCC rises to 4.5 V. Display clear Function set: DL = 1; 8-bit interface data N = 0; 1-line display F = 0; 5 x 8 dot character font Display on/off control: D = 0; Display off C = 0; Cursor off B = 0; Blinking off Entry mode set: I/D = 1; Increment by 1 S = 0; No shift Note: If the electrical characteristics conditions listed under the table Power Supply Conditions Using Internal Reset Circuit are not met, the internal reset circuit will not operate normally and will fail to initialize the HD44780U. For such a case, initialization must be performed by the MCU as explained in the section, Initializing by Instruction. There are certain conditions that has to be met, if user want to use initialization by internal reset circuit. These conditions are shown in the Table 5 below.

Table 2: Power Supply condition for Internal Reset circuit The figure below shows the test condition which are to be met for internal reset circuit to be active.

Fig 3.13: Internal Power Supply reset Now the problem with the internal reset circuit is, it is highly dependent on power supply, to meet this critical power supply conditions is not hard but are difficult to achieve when you are making a simple application. So usually the second method i.e. Initialization by instruction is used and is recommended most of the time. 3.2.8 Initialization by instructions Initializing LCD with instructions is really simple. Given below is a flowchart that describes the step to follow, to initialize the LCD.

Fig 3.14: Flow chart for LCD initialization As you can see from the flow chart, the LCD is initialized in the following sequence… 1) Send command 0×30 – Using 8-bit interface 2) Delay 20ms 3) Send command 0×30 – 8-bit interface 4) Delay 20ms 5) Send command 0×30 – 8-bit interface 6) Delay 20ms 7) Send Function set – see Table 4 for more information 8) Display Clear command 9) Set entry mode command – explained below The first 3 commands are usually not required but are recommended when you are using 4-bit interface. So you can program the LCD starting from step 7 when working with 8-bit interface. Function set command depends on what kind of LCD you are using and what kind of interface you are using (see Table 4 in LCD Command section). 3.2.9 LCD Entry mode From Table 3 in command section, you can see that the two bits decide the entry mode for LCD, these bits are: a) I/D – Increment/Decrement bit b) S – Display shift. With these two bits we get four combinations of entry mode which are 0×04,0×05,0×06,0×07 (see table 3 in LCD Command section). So we get different results with these different entry modes. Normally

entry mode 0×06 is used which is No shift and auto increment. I recommend you to try all the possible entry modes and see the results, I am sure you will be surprised. 3.2.10 Reading the busy Flag

As discussed in the previous section, there must be some delay which is needed to be there for LCD to successfully process the command or data. So this delay can be made either with a delay loop of specified time more than that of LCD process time or we can read the busy flag, which is recommended. The reason to use busy flag is that delay produced is almost for the exact amount of time for which LCD need to process the time. So is best suited for every application. Steps to read busy flag When we send the command, the BF or D7th bit of the LCD becomes 1 and as soon as the command is processed the BF = 0. Following are the steps to be kept in mind while reading the busy flag.
   

Select command register Select read operation Send enable signal Read the flag Sending Commands to LCD

3.2.11

To send commands we simply need to select the command register. Everything is same as we have done in the initialization routine. But we will summarize the common steps and put them in a single subroutine. Following are the steps:
    

Move data to LCD port select command register select write operation send enable signal wait for LCD to process the command CGRAM and Character Building

3.2.12

As already explained, all character based LCD of type HD44780 has CGRAM area to create user defined patterns. For making custom patterns we need to write values to the CGRAM area defining which pixel to glow. These values are to be written in the CGRAM address starting from 0×40. If you are wondering why it starts from 0×40? Then the answer is given below.

Table 3; CGRAM and character building Bit 7 is 0 and Bit 6 is 1, due to which the CGRAM address command starts from 0×40, where the address of CGRAM (Acg) starts from 0×00. CGRAM has a total of 64 Bytes. When you are using LCD as 5×8 dots in function set then you can define a total of 8 user defined patterns (1 Byte for each row and 8 rows for each pattern), whereas when LCD is working in 5×10 dots, you can define 4 user defined patterns. Let’s take an off building a custom pattern. All we have to do is make a pixel-map of 7×5 and get the hex or decimal value or hex value for each row, bit value is 1 if pixel is glowing and bit value is 0 if pixel is off. The final 7 values are loaded to the CGRAM one by one. As i said there are 8 rows for each pattern, so last row is usually left blank (0×00) for the cursor. If you are not using cursor then you can make use of that 8th row also. So you get a bigger pattern. To explain the above explanation in a better way. I am going to take an example. Let’s make a “Bell” pattern as shown below.

Figure 3.15: Bell pattern Now we get the values for each row as shown. Bit: 4 3 2 1 0 – Hex Row1: 0 0 1 0 0 – 0×04 Row2: 0 1 1 1 0 – 0x0E Row3: 0 1 1 1 0 – 0x0E Row4: 0 1 1 1 0 – 0x0E Row5: 1 1 1 1 1 – 0x1F Row6: 0 0 0 0 0 – 0×00 Row7: 0 0 1 0 0 – 0×04 Row8: 0 0 0 0 0 – 0×00

We are not using row 8 as in our pattern it is not required. If you are using cursor then it is recommended not to use the 8th row. Now as we have got the values. We just need to put these values in the CGRAM. You can decided which place you want to store in. Following is the memory map for custom patterns in CGRAM. Memory Map Pattern No. 1 2 3 4 5 6 7 8 CGRAM Address (Acg) 0×00 – 0×07 0×08 – 0x0F 0×10 – 0×17 0×18 – 0x1F 0×20 – 0×27 0×28 – 0x2F 0×30 – 0×37 0×38 – 0x3F

Table 4: Memory map for custom patterns We can point the cursor to CGRAM address by sending command, which is 0×40 + CGRAM address (For more information please see Table 4 in commands section). Let’s say we want to write the Bell pattern at second pattern location. So we send the command as 0×48 (0×40 + 0×08), and then we send the pattern data. Below is a small programming example to do this. 3.2.13 Introduction 4 bit LCD Interfacing

Till now whatever we discussed in the previous part of this LCD tutorial, we were dealing with 8-bit mode. Now we are going to learn how to use LCD in 4-bit mode. There are many reasons why sometime we prefer to use LCD in 4-bit mode instead of 8-bit. One basic reason is lesser number of pin are needed to interface LCD.

In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of LCD.
        

Wait for about 20mS Send the first init value (0×30) Wait for about 10mS Send second init value (0×30) Wait for about 1mS Send third init value (0×30) Wait for 1mS Select bus width (0×30 – for 8-bit and 0×20 for 4-bit) Wait for 1mS

The busy flag will only be valid after the above reset sequence. Usually we do not use busy flag in 4-bit mode as we have to write code for reading two nibbles from the LCD. Instead we simply put a certain amount of delay usually 300 to 600uS. This delay might vary depending on the LCD you are using, as you might have a different crystal frequency on which LCD controller is running. So it actually depends on the LCD Module you are using. So if you feel any problem running the LCD, simply try to increase the delay. This usually works. For me about 400uS works perfect. LCD connections in 4-bit Mode

Figure 3.16: LCD connections in 4-bit mode

Above is the connection diagram of LCD in 4-bit mode, where we only need 6 pins to interface an LCD. D4-D7 are the data pins connection and Enable and Register select are for LCD control pins. We are not using Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so we have made it grounded permanently. If you want to use it then you may connect it on your controller but that will only increase another pin and does not make any big difference. Potentiometer RV1 is used to control the LCD contrast. The unwanted data pins of LCD i.e. D0-D3 are No connection.

3.2.14 Sending data/command in 4-bit Mode We will now look into the common steps to send data/command to LCD when working in 4-bit mode. As i already explained in 4-bit mode data is sent nibble by nibble, first we send higher nibble and then lower nibble. This means in both command and data sending function we need to separate the higher 4bits and lower 4-bits. The common steps are:
     

Mask lower 4-bits Send to the LCD port Send enable signal Mask higher 4-bits Send to LCD port Send enable signal

3.3

MICROCONTROLLER AT89C51

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times. In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bidirectional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually. Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts. 3.3.1 Ø Ø Ø Ø Ø Ø Ø Ø Ø Ø Features

Compatible with MCS-51 Products 4 Kbytes 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 128 x 8-Bit Internal RAM 32 Programmable I/O Lines Two 16-Bit Timer/Counters Six Interrupt Sources Programmable Serial Channel Low Power Idle and Power down Modes

3.3.2

Pin Diagram:

Figure 3.17: Pin configuration

3.3.3

Pin Description:

Port 0; is a dual-purpose port on pins 32-39 of the 8051 1C. In minimum – component designs, it is used as a general purpose I/O Port. For larger designs with external memory, it becomes a multiplexed address and data bus. Port 1; is a dedicated I/O port on pins 1-8. The pins, designated as P1.0. P1.1. P1.2 etc. are available for interfacing to external devices as required. No alternate functions are as signed for Port 1 pins; thus they are used solely for interfacing to external devices. Exceptions are the 8032/8052 ICs. Which use P1.0 and P1.1 either as I/O lines or as external in outs to the third timer. Port 2; (pints 21-28) is a dual – purpose port serving as general purpose I/O, or as the high byte of the address bus for designs with external code memory or more than 256 bytes of external data memory. Port 3; is a dual – purpose port on pins 10-17. As well as general – purpose I/O, these pins are multifunctional with each having an alternate purpose related to special features of the 8051). Now coming to the other pin functions. PSEN; this is an output pin. PSEN stands for “program store enable.” In an 8031-based system in which an external ROM holds the program code, this pin is connected to the OE pin of the ROM. VCC; Pin 40 provides supply voltage to the chip. The voltage source is +5V. GND; Pin 20 is the Ground pin. 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 XTALI (pin 19) and XTAL2 (pin 18). The quartz crystal oscillator connected to XTAL1 AND XTAL2 also needs two capacitors of 30 pF value. One side of each capacitor is connected to the ground as shown in this figure;

Figure 3.18: Quartz crystal oscillator connection EA; the 8051 family members, such as the 8751, 89C51, or DS5000. All come with on-chip ROM to store programs. In such cases, the EA pin is connected to VCC for giving power to save and erase program from the memory.

RST (RESET); The RST input on pin 9 is the master rest for the 8051. When this signal is brought high for a least two machine cycles, the 8051 internal registers are loaded with appropriate values for an orderly system start-up. For normal operation, RST is low. Figure shows permanent connections of Reset Pin.

Figure 3.19: permanent connections of the reset pins ALE; (address latch enable) is an output pin and is active high. When connecting an 8031 to external memory, port 0 provides both address and data. In other words, the 8031 multiplexes address and data through port 0 to save pins. The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 chip. Now we will talk about what other things are inside an AT89C51 MCU; 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 89C51 register an address pointing to the data to be fetched. The vast majority of 89C51 registers are 8bit registers. In the 8051 there is only one data type: 8 bits. The 8 bits of a register are shown 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 8 bits must be broken into 8-bit chunks before it is processed. The most widely used registers of the 89C51 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.

All the registers of 89C51 are;

Table 5: Registers of AT89C51 Timers; Both timer 0 and timer 1 are 16 bits wide. Since the 89C51 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte. Each timer is discussed separately. Timer 0 Register; The 16-bit register of time 0 is accesses 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 registers can be accessed like any other register, such as A,B, R0, R1, R2 etc. For example, the instruction “TLO= 20” moves the value 500 into TL0, the low byte of timer 0. These registers can also be read like any other register.

Timer 1 Register; Timer 1 is also 16 bits, and its 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 in the same way as the registers of timer 0.

TMOD (Timer Mode) Register; both timers 0 and 1 uses 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 are set aside 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. Mode 2 Programming; the following are the characteristics and operations of mode 2. 1-It is an 8-bit timer; therefore, it allows only values of 00 to FFH to be loaded into the timer’s register TH. 2-After TH is loaded with the 8-bit value, the 8051 gives a copy of it to TL. Then the timer must be started. This is done by the instruction “SETB TR0” for timer 0 and “SETB TR1” for timer 1. This is just like mode 1. 3-After the timer is started, it starts to count up by incrementing the TL register. It counts up until it reaches its limit of FFH. When it rolls over from FFH to 00, it sets high the TF (timer flag). If we are using timer 0, TF0 goes high; if we are using timer 1, TF1 is raised. 4-When the TL registers rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the original value kept by the TH register. To repeat the process, we must simply clear TF and let it go

without any need by the programmer to reload the original value. This makes mode 2 and auto-reload, in contrast with mode 1 in which the programmer has to reload TH and TL. It must be emphasized that mode 2 is an 8-bit timer. However, it has an auto-reloading capability in auto reload. TH is loaded with the initial count and a copy of it is given to TL. This reloading leaves TH unchanged, still holding a copy of original value. This mode has many applications, including setting the baud rate in serial communication. SBUF (Serial Buffer) Register; SBUF is an 8-bit register used solely for serial communication in the 89C51. 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 89C51 RxD line. SBUF can be accessed like any other register in the 89C51.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 89C51 deframes it by eliminating the stop and start bits, making a byte out of the data received, and then placing it in the SBUF. Some baud rates are shown below: Baud Rate= 9600 TH1(Decimal)=-3 TH1(HEX)=FD Baud Rate= 4800 TH1(Decimal)=-6 TH1(HEX)=FA Baud Rate= 2400 TH1(Decimal)=-12 TH1(HEX)=F4 Baud Rate= 1200 TH1(Decimal)=-24 TH1(HEX)=E8

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. Following SCON bits are explained; SMO SCON.7 Serial port mode specifier SM1/ SCON.6= Serial port mode specifier SM2/ SCON.5= Used for multiprocessor communication (Make it 0) REN/ SCON.4= Set / cleared by software to enable / disable reception. TB8/ SCON.3= Not widely used. RB8/ SCON.2= Not widely used. T1/ SCON.1= Transmit interrupt flag. Set by hardware at the beginning of the stop bit in mode1. Must by cleared by software. R1/ SCON.0= Receive interrupt flag. Set by hardware halfway through the stop bit time in mode1. Must be cleared by software. Bit-Addressable RAM; of the 128-byts internal RAM of the 8051, only 16 bytes of it are bit addressable. The rest must be accessed in byte format. The bit – addressable RAM locations are 20H to 2FH. These 16 bytes provide 128 bits of RAM bit – address ability since 16 x 8 = 128. They are addressed as 0 to 127 (in decimal) or 00 to 7FH. Therefore, the bit addresses 0 to 7 are for the first byte of internal RAM location 20H, and 8 to 0FH are the bit addresses of the second byte, RAM location 21H, and so on. The last byte of 2FH has bit address byte of 2FH has bit addresses of 78H to 7FH. Note that internal RAM locations 20-

2FH are both byte-addressable and bit addressable. Notice from figure that bit addresses 00 – 7FH belong to RAM byte addresses 20 – 2FH, and bit addresses 80 – F7H belong to SFR P0, P1 etc.

Table 6: Bit addressable RAM

3.3.4

PROGRAM CODING

The programming of the microcontroller was done in C language using Keil Uvision 4 Software. This is the brief description of how to program using keil uvision 4. a. First, the software is launched and click on new project, then select the appropriate location to save it.

Figure a. Initiating Keil uvision 4

b. A new window pops up prompting the selection of the device/microcontroller to be used. In this case I select, Atmel-drop down select AT89C51 and click OK as shown:

Figure b. Selection of the desired controller c. Click on new text document. This is where the code will be typed and then save as a .c file.

Figure c. Notepad from within Keil uvision 4 d. The next phase is adding the .c file, which contains the program code to the source group within the software interface. This is done by right clicking on the source group then selecting “add files to source group 1”

e. Finally, click on the build function to compile the code. If the code runs with no errors, as shown below, go ahead and create the hex file, which is to be loaded to the microcontroller.

f.

Figure d. compiling the code Creating the hex file is as shown:

Figure e. creation of the HEX file

Figure f. creation of the HEX file (continued)

3.3.5 The Code:

#include #include sbit rs = P2^7; sbit en = P2^5; sbit rw = P2^6; sbit b = P0^7; sbit led1 = P2^1; sbit led2 = P2^2; sbit led3 = P2^3; sbit led4 = P2^4; sbit op = P2^0; // rs pin of LCD // en pin of LCD // rw pin of LCD // busy flag

unsigned int d1=0; unsigned int d2=0; unsigned int c=0;

void writecmd(unsigned char a); void writedata(unsigned char b); void busy(void); void writestr(unsigned char *s); void dely(void); void incangle(void); void decangle(void); void delay(int d); void display(unsigned int z);

// function initializations

void keydly(void) reentrant { unsigned int x,y; for(x=0;x

Similar Documents

Free Essay

New Method of Power Quality Improvement in Classical Ac/Ac Controllers Using Pwm

...LEKHASRI.M KARTHIKA DEVI.G ERODE SENGUNTHAR ENGINEERING COLLEGE, Erode-57. Mail id: eseclekha.eee@gmail.com karthierd.g@gmail.com Contact no: 9791758935 8012178062 Abstract: A lot of topologies of pulse-width modulated (PWM)-AC voltage controllers for single-phase and threephasesystems are proposed up to date. PWM-AC controllers have important advantages comparedwith the phase-controlled AC voltage controllers using thyristors and triacs. This article presents anovel control technique for application to PWM-AC controllers with ability of generating smallerharmonics. In the proposed control method, both the traditional AC voltage controllers and the PWMAC. controllers are combined, smaller THD values are obtained and switching losses are minimized.Thus, the harmonic pollution in the power system will be reduced and the power quality will beincreased. In order to investigate the proposed controller performance, computer simulations andexperimental studies are performed. Obtained results are compared with those of the conventionalPWM-AC controller. Key words: Power quality, AC choppers, PWM-AC controllers, AC sector-control voltage converters INTRODUCTION There are three basic types of AC to AC converters. Thesimplest ones, the AC voltage controllers, allow controllingthe output voltage only, while the output frequency is the same as the input frequency. The second one is the cycloconverter. In cycloconverters, the...

Words: 2640 - Pages: 11

Free Essay

Radar

... the receiver input is short-circuited or decoupled by a circulator. Figure 1 shows a typical, simple pulse Radar system. To produce the pulses either magnetrons or switched amplifiers are employed. There is no reference from the transmission oscillator to the receiver, therefore non-coherent pulse Radar cannot measure Doppler and thus only the distance and not the speed of a target can be determined. Figure 1: Simple, non-coherent Radar. Coherent Pulse Radar/Pulse Doppler radar Coherent pulse Radar is in the position to deliver information regarding the range as well as Doppler information, i.e. the velocity and/or speed of an object. Here a coherent oscillator (COHO) is introduced on the transmission side, which also delivers the phase reference for the receiving signal. The transmitting oscillator (LO for Local Oscillator) is added on the transmitting end and is again taken out at the receiving end. In comparison to the Doppler frequency, which can be measured, both oscillators must be sufficiently stable for the entire time. In Figure 2, an example of coherent pulse Radar, a quadrature modulator is employed to additionally determine the direction of the target movement. Figure 2: Coherent pulse Radar. Two various fundamental methods of Doppler analysis are known and will be subsequently and shortly introduced. The transmitting signal for pulse Radar is: Us=Assinω0t The reference signal: Uref=Arefsinω0t+φref φref= constant, φref=0. The receiving signal from a...

Words: 2173 - Pages: 9

Free Essay

Phase Locked Loop

...Xiao-Qiang GUO, Wei-Yang WU, He-Rong GU Yanshan University Phase locked loop and synchronization methods for gridinterfaced converters: a review Abstract. Phase locked loop and synchronization techniques are one of the most important issues for operating grid-interfaced converters in practical applications, which involve Distributed Power Generation Systems, Flexible AC Transmission Systems (FACTS), and High Voltage Direct Current (HVDC) Transmission, and so on. This paper presents a comprehensive review of the recently developed phase locked loop and synchronization methods, then a comparison and selection guide are provided. Finally, a list of more than 40 technical papers is also appended for a quick reference. Streszczenie. Techniki PLL i synchronizacji są ważnymi elementami przetworników w systemach sieciowych, takich jak: rozproszonych systemach mocy, FACTs czy HVDC. Artykuł przedstawia przegląd tego typu metod a następnie porównanie tych metod. Na końcu ponad 40 podstawowych artykułów z tej tematyki jest przedstawionych.(Metody synchronizacji i PLL w przetwornikach sieciowych – przegląd). Keywords: Grid-interfaced converters, phase locked loop, synchronization Słowa kluczowe: uchłady PLL, synchronizacja. Introduction The basic phase locked loop (PLL) concept was originally published by Appleton in 1923 and Bellescize in 1932, which was mainly used for synchronous reception of radio signals [1-2]. After that, PLL techniques were widely used in various industrial...

Words: 5211 - Pages: 21

Premium Essay

Mr Chan Ur

...the armature currents rotates at the same speed as that created by the field current on the rotor, which is rotating at the synchronous speed, and a steady torque results. Synchronous machines are commonly used as generators especially for large power systems, such as turbine generators and hydroelectric generators in the grid power supply. Because the rotor speed is proportional to the frequency of excitation, synchronous motors can be used in situations where constant speed drive is required. Since the reactive power generated by a synchronous machine can be adjusted by controlling the magnitude of the rotor field current, unloaded synchronous machines are also often installed in power systems solely for power factor correction or for control of reactive kVA flow. Such machines, known as synchronous condensers, may be more economical in the large sizes than static capacitors. With power electronic variable voltage variable frequency (VVVF) power supplies, synchronous motors, especially those with permanent magnet rotors, are widely used for variable speed drives. If the stator excitation of a permanent magnet motor is controlled by its rotor position such that the stator field is always 90o (electrical) ahead of the rotor, the motor performance can be very close to the conventional brushed dc motors, which is very much favored for variable speed drives. The rotor position can be either detected by using rotor position...

Words: 6536 - Pages: 27

Free Essay

Power Electronics

...University 20.1 20.2 20.3 20.4 20.5 20.6 20.7 Introduction Power Flow on a Transmission Line UPFC Description and Operation Series Converter: Four Modes of Operation • Automatic Power Control Karl Schoder West Virginia University UPFC Modeling UPFC Steady-State or Load Flow Model • UPFC Dynamic Model • Interfacing the UPFC with the Power Network Control Design UPFC Basic Control Design • Power System Damping Control through UPFC Using Fuzzy Control Case Study Test System • Tracking Real and Reactive Power Flows • Operation under Fault Conditions Conclusion 20.1 Introduction An electric power system is an interconnection of generating units to load centers through high-voltage electric transmission lines. It consists of generation, transmission, and distribution subsystems, which used to belong to the same electric utility in a given geographical area. But, currently, the electric power industry is in transition from large, vertically integrated utilities providing power at regulated rates to an industry that will incorporate competitive companies selling unbundled power at possibly lower rates. With this new structure, which will include separate generation, distribution, and transmission companies with an open-access policy, comes the need for tighter control strategies. The strategies must maintain the level of reliability that consumers not only have taken for granted but expect even in the event of considerable structural changes, such as a loss...

Words: 7922 - Pages: 32

Premium Essay

Stepper Motor Working

...Stepper Motor Theory of Operation Stepper motors provide a means for precise positioning and speed control without the use of feedback sensors. The basic operation of a stepper motor allows the shaft to move a precise number of degrees each time a pulse of electricity is sent to the motor. Since the shaft of the motor moves only the number of degrees that it was designed for when each pulse is delivered, you can control the pulses that are sent and control the positioning and speed. The rotor of the motor produces torque from the interaction between the magnetic field in the stator and rotor. The strength of the magnetic fields is proportional to the amount of current sent to the stator and the number of turns in the windings. The stepper motor uses the theory of operation for magnets to make the motor shaft turn a precise distance when a pulse of electricity is provided. You learned previously that like poles of a magnet repel and unlike poles attract. Figure 1 shows a typical cross-sectional view of the rotor and stator of a stepper motor. From this diagram you can see that the stator (stationary winding) has eight poles, and the rotor has six poles (three complete magnets). The rotor will require 24 pulses of electricity to move the 24 steps to make one complete revolution. Another way to say this is that the rotor will move precisely 15° for each pulse of electricity that the motor receives. The number of degrees the rotor will turn when a pulse of electricity is delivered...

Words: 3808 - Pages: 16

Free Essay

Frequency Response

...amplitude and phase angles. This is due to a time lag between input and output generated. These differences are functions of frequency. In this experiment, the frequency response test is used to identify the (linear) dynamics of a plant. It is performed by inputting a sinusoidal signal and comparing it with the sinusoidal output. Objective of Experiment 1. To perform a frequency response test on an aircraft electro-hydraulic servo-actuator, hence determining the phase and gain margins of the servo-actuator. 2. To verify that increasing the gain by the gain margin causes instability. Equipment and Apparatus 1. Electro-hydraulic servo-actuator 2. Amplifier unit 3. Oscilloscope (CRO) 4. Function generator (FG) 5. Hydraulic power supply (outside laboratory) Background of Experiment This experiment utilizes a servo mechanism which is an automatic device that takes advantage of error-sensing feedback to correct and amplify the signal. The servo system comprises of a servo-actuator and an amplifier unit. In aircrafts, a similar system is used to convert electrical autopilot voltage outputs into a proportional mechanical movement. The mechanical movement is linked to the control rods, which controls the equipment the pilot uses to move the plane parts. When the output position is changed, the time delay should be minimal, but the response should not oscillate. These specifications usually determine the gain (or attenuation) and phase angle at some frequency...

Words: 3296 - Pages: 14

Free Essay

Fourier Analysis of Control System

...[Fourier analysis of Control System] [Fourier analysis of Control System] Submitted to: Dr. S. K. Raghuwanshi Submitted By: Rishi Kant Sharan Semester: V Branch: Electronics & Communication Engineering Submitted to: Dr. S. K. Raghuwanshi Submitted By: Rishi Kant Sharan Adm. No: 2010JE1117 Semester: V Branch: Electronics & Communication Engineering Abstract The assignment focuses on the Fourier analysis of Control System. Which leads to frequency domain analysis of control system. The scope of estimation and controlling the behavior a system by means of Fourier transformation of its transfer function and analyzing its frequency response. Abstract The assignment focuses on the Fourier analysis of Control System. Which leads to frequency domain analysis of control system. The scope of estimation and controlling the behavior a system by means of Fourier transformation of its transfer function and analyzing its frequency response. ACKNOWLEDGEMENT There is an old adage that says that you never really learn a subject until you teach it. I now know that you learn a subject even better when you write about it. Preparing this term paper has provided me with a wonderful opportunity to unite my love of concept in CONTROL SYSTEM. This term paper is made possible through the help and support from everyone, including: professor, friends, parents, family, and in essence, all sentient beings. Especially, please allow me to dedicate...

Words: 5034 - Pages: 21

Free Essay

Inverted Pendulem

.................................................................................... David L. Trumper Associate Professor of Mechanical Engineering Thesis Supervisor Accepted by: ........................................................................................................................ Ernest G. Cravalho Chairman, Undergraduate Thesis Committee Department of Mechanical Engineering Standup and Stabilization of the Inverted Pendulum by Andrew K. Stimac Submitted to the Department of Mechanical Engineering on May 5, 1999, in Partial Fulfillment of the Requirements for the Degree of Bachelor of Science in Mechanical Engineering. Abstract The inverted pendulum is a common, interesting control problem that involves many basic elements of control theory. This thesis investigates the standup routine and stabilization at the inverted position of a pendulum-cart system. The standup routine uses strategic cart movements to add energy to the system. Stabilization at the inverted position is accomplished through linear state feedback. Methods are implemented using the Matlab Simulink environment, with a dSPACE DSP controller board for...

Words: 6866 - Pages: 28

Premium Essay

Static Shunt Compensator Case Study

...From the d.c. side capacitor, a three phase voltage is generated by the inverter. This is synchronized with the a.c supply. The link inductor links this voltage to the a.c supply side. This is the basic principle of operation of STATCOM. Fig 3.2 STATCOM is nothing but static shunt compensator which is connected in parallel at the point of common coupling and consists of static power devices like IGBT, MOSFET. The advantage of these devices is the voltage can be easily varied by changing their firing angle. The converter used here is a full bridge converter having six power devices like MOSFET we are using here. As wind speed is always variable, the connection of wind turbine to the grid causes stability problems and which will reduce power quality. In case of any fault there may be voltage sag, swell, or sometimes blackout. STATCOM is connected at PCC as shown in fig...

Words: 1194 - Pages: 5

Free Essay

Vibration

...energy and normally is undesirable is most cases. It generates noise, instability and will consequently lead to system break down which is a disastrous effect. This project studies a model vibration of a four-cylinder engine which is mounted on a cantilever. This system can be modeled as a mass spring system so that the vibration of the system can be studied. These vibrations are mainly due to the unbalance of primary or secondary forces and couples. 1. Background The model engine consists of four cylinders mounted of a crank shaft with different crank phase angles. A DC motor with a variable speed control drives the shaft and makes the four-cylinder to rotate. The shaft is rotating at a constant angular speed, however, producing an acceleration on the pistons. Hence there are some inertia forces acting on the crank shaft due to these accelerations. The relative crank phase angles of the four cylinders can be adjusted by loosen three Allan screws to each point of the adjustment. Each crank shaft is to be dynamically balanced with the usual conventional allowance for the effect of its connecting rod. This helps the assembled crank shaft to remains substantially balanced for rotating effects. The mass center G of the assembly is on the cantilever. There are two units of Linear Variable Displacement Transducer which are equipped...

Words: 3330 - Pages: 14

Premium Essay

Renewable Energ

...Arab Academy for Science, Technology and Maritime Transport College of Engineering and Technology Department: Electrical and Computer Control Engineering B. Sc. Final Year Project WIND ENERGY Presented By: Ahmed Magdy Ahmed Mokhtar Latifa Ahmed Supervised By: Dr.Amr Magdy DECLARATION I hereby certify that this material, which I now submit for assessment on the programme of study leading to the award of Bachelor of Science in (insert title of degree for which registered) is entirely my own work, that I have exercised reasonable care to ensure that the work is original, and does not to the best of my knowledge breach any law of copyright, and has not been taken from the work of others save and to the extent that such work has been cited and acknowledged within the text of my work. Signed: _____________________________ Registration No.: ___________ Date: 6/7/2013 2 ACKNOWLEDGMENT To my honourable Dr.AMR MAGDY We were honoured and pleased at the same time to work under the supervision of you, you spent a lot of time with us, at the time you definitely had lots of other important occupations. This work would have never been done without your assistance.Very thanking prof.Dr. Yasser Galal on his effort with us the past five years.Thanking engineers Noha Magdy and Ashraf Brdwyli to help us in the project. 3 ABSTRACT Wind energy is fast becoming the most preferable alternative to conventional sources of electric power. wind turbines...

Words: 13966 - Pages: 56

Premium Essay

Remote Monitoring System

...3. Current UTC Systems in South Africa 3.1 Remote Monitoring Systems Remote Monitoring Systems (RMS) are traffic control systems that connect a roadside controller to a central computer to provide a remote monitoring facility at the traffic signal equipment. RMS offers functionality that allows it to monitor digital inputs and outputs, phase outputs and phase lamp monitoring. In the occurrence of any faults, the system connects to the in-station, alerts the operator and lodges the fault simultaneously (Imtech Traffic and Infrastructure UIC Ltd). In addition, these systems offer a range of other features such as traffic data collection, remote clock setting and loading of signal plan configurations. Communication between the roadside controller...

Words: 1337 - Pages: 6

Free Essay

Bio-Mechanics

...same time. Biomechanics, which is our main focal point, is mostly concerned with the basic laws that govern the effects that different forces have on the state of rest or motion of any living system, whereas the applied area of biomechanics deals with solving practical problems (Hamilton, Weimar & Luttgens, 2012). Biomechanics also helps us breakdown skills and exercises down to their points of origin, as well as solve problems regarding specific exercises. Motor learning is the final section that will be discussed on performing the dips exercise. Within this portion there will be several areas covered to fully expand on full exercising a dip and developing the muscles use to complete a successful dip. Areas covered will include three phases of motor learning, learning cues, common errors, general feedback to use, the stages of learning, types of motor skills, information for use within a curriculum, and useful information for lesson plans to include one example lesson plan. When the average person looks at the body they would probably only consider the basics to the body such as; the arms, legs, head and the basic parts that help it operate such as the heart, lungs, blood, etc. This could all be called the anatomy of the body. Anatomy can be defined as the study of the structure and the relationship between body parts (Rodgers, 2009). But, does the average person ever think about the biomechanical aspects of the body parts? Biomechanics is the science of movement of a living...

Words: 7640 - Pages: 31

Premium Essay

Unit 3 Assignment 1: Frequency Modulation

...Unit 3 Assignment 1: Frequency Modulation Ch. 5 (pp 253-255 1, 2, 6, 7, 8, 12, 14, 16, 17, 20, 26, 28, 33, 35, 48 Section 5-1 1. Define angle modulation and list its subcategories. Answer: Angle modulation is defined as modulation where the angle of a sine-wave carrier is varied from its reference value. The subcategories are Phase modulation and Frequency modulation. 2. What is the difference between frequency and phase modulation? Answer: The difference between frequency and phase modulation is; Frequency modulation is where the instantaneous frequency of a carrier is caused to vary by an amount proportional to the modulating signal amplitude, Phase modulation is the same but it is where the phase angle of a carrier is caused to depart from its reference value. Section 5-2 6. Define deviation constant. Answer: Deviation Constant is defined as in units of kHz/V. and it’s how much the carrier frequency will deviate for a given modulating input voltage level. 7. A 50-mV sinusoid, at a frequency of 1 kHz, is applied to a capacitor microphone FM generator. If the deviation constant for the capacitor microphone FM generator is 500 Hz/20 mV, determine: (a) The total frequency deviation. (±1.25 kHz) Answer: 50mV x (500 Hz)/(20 mV)= ±1.25 kHz (b) The rate at which the carrier frequency is being deviated. (1 kHz) Answer: The rate at which the carrier frequency is being deviated is ±1.25 kHz at a rate of 1 kHz. 8. Explain how the intelligence signal modulates...

Words: 1325 - Pages: 6