88043168 16 doc of automatic load sharing of transformers
TRANSCRIPT
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
1/137
1
AUTOMATIC LOAD SHARING OF TRANSFORMERS
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
2/137
2
CONTENTS
S.No. Contents Page
1. Abbreviations
2. Abstract
3. Introduction
5. Block diagram
6. Block diagram Description
7. Schematic
8. Schematic Description (pin to pin connectivity)
9.
10.
Hardware components
a. Microcontroller (max 50 pages)b. MAX 232c. Power supplyd. ADCe. Current sensorf. LCDg. Relay
Circuit description
11. Software components
a. About Keilb. Embedded C
12. Source Code OUT SIDE
12. Conclusion or Synopsis
13. Bibliography
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
3/137
3
ABBREVIATIONS
Symbol Name
ACC AccumulatorB B register
PSW Program status word
SP Stack pointer
DPTR Data pointer 2 bytes
DPL Low byte
DPH High byte
P0 Port0
P1 Port1
P2 Port2
P3 Port3
IP Interrupt priority control
IE Interrupt enable control
TMOD Timer/counter mode control
TCON Timer/counter control
T2CON Timer/counter 2 control
T2MOD Timer/counter mode2 control
TH0 Timer/counter 0high byte
TL0 Timer/counter 0 low byte
TH1 Timer/counter 1 high byte
TL1 Timer/counter 1 low byte
TH2 Timer/counter 2 high byte
TL2 Timer/counter 2 low byte
SCON Serial control
SBUF Serial data buffer
PCON Power control
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
4/137
4
Figure Locations
S.No. Figure Page No.
1Components of Typical Linear PowerSupply
2 An Electrical Transformer
3 Bridge Rectifier
4 Bridge Rectifier Positive Cycle
5 Bridge Rectifier Negative Cycle
6 Three terminal voltage Regulator
7 Functional Diagram of Microcontroller
8 Pin Diagram of Microcontroller
9 Oscillator connections
10 External clock drive connections
11 A register12 B register
13 RAM
14 RAM Allocation
15 Register Banks
16 PSW
17 DPTR
18 SP
19 PORT 0
20 TL0 and TH0
21 DB9
22 Connecting Microcontroller to PC
23
Types of SIM Structures
24Smart Card Pin-out
25Smart Card Reader
26LCD
27MAX 232 Pin-out
28 MAX 232 Operating circuit
29MAX 232 Logic output
30Relay
31Project
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
5/137
5
32New Project
33Select Target device
34Select device for Target
35Copy 8051 startup code
36Source group 1
37New file
38Opened new file
39File Save
40Add files to the source group
41 Adding files to the source group
42Compilation
43After Compilation
44Build
45Selecting the Ports to be visualized
46Start Debugging
47
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
6/137
6
CHAPTER 1
1. INTRODUCTION
1.1 EMBEDDED SYSTEMS:
Embedded systems are designed to do some specific task, rather than be a
general-purpose computer for multiple tasks. Some also have real time performance
constraints that must be met, for reason such as safety and usability; others may have low
or no performance requirements, allowing the system hardware to be simplified to reduce
costs.
An embedded system is not always a separate block - very often it is physically
built-in to the device it is controlling. The software written for embedded systems is often
called firmware, and is stored in read-only memory or flash convector chips rather than a
disk drive. It often runs with limited computer hardware resources: small or no keyboard,
screen, and little memory.
Wireless communication has become an important feature for commercial productsand a popular research topic within the last ten years. There are now more mobile phone
subscriptions than wired-line subscriptions. Lately, one area of commercial interest has
been low-cost, low-power, and short-distance wireless communication used for \personal
wireless networks." Technology advancements are providing smaller and more cost
effective devices for integrating computational processing, wireless communication, and
a host of other functionalities. These embedded communications devices will be
integrated into applications ranging from homeland security to industry automation and
monitoring. They will also enable custom tailored engineering solutions, creating a
revolutionary way of disseminating and processing information. With new technologies
and devices come new business activities, and the need for employees in these
technological areas. Engineers who have knowledge of embedded systems and wireless
communications will be in high demand. Unfortunately, there are few adorable
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
7/137
7
environments available for development and classroom use, so students often do not learn
about these technologies during hands-on lab exercises. The communication mediums
were twisted pair, optical fiber, infrared, and generally wireless radio.
INTRODUCTION TO THE PROJECT:
In this project AUTOMATIC LOAD SHARING OF TRANSFORMERS we
are using two transformers, one is main transformer (TF1) and the next is backup
transformer (TF2). Here the load is directly connected to the secondary of the main
transformer as well as backup transformer; here two transformers are connected through
the relay.
The transfers switch senses when utility power is interrupted, and starts up the
transformer TF2 which acts as a backup transformer. If the utility power remains absent,
the transfer switch disconnects the load from the utility and connects it to the
Transformer TF2, restoring electricity to the load. The transfer switch continues to
monitor utility power, and when it is restored, switches the load from the Transformer
TF2 back to the Main transformer TF1. Once the Transformer TF2 is disconnected, it
goes through a cool-down routine and is automatically shut down.
The objective of the present project is to satisfy the above needs with an extent.
The present system is designed around two transformers. One transformer (TF1) is used
as the main supply and the other transformer (TF2) is used in the place of the generator
(for demo purpose). These two transformers are connected with the relay which is
controlled by the embedded controller. The loads are connected to the main line (TF1)
and as well as to the TF2.
Initially TF1 is connected to the load, the loads run with this power. Due to any
reason this power is interrupted, then it is identified by the controller and it immediately
switches ON to the TF2 through the relay. The controller continuously monitors the TF1
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
8/137
8
(main line). When it finds the power on it again switches the loads connection to the main
line. All the status of the transformers will be displayed on LCD.
BLOCK DIAGRAM:
BLOCK DIAGRAM EXPLANATION:
The above block diagramgives the overview of the project in the pictorial form
with the help of the block diagram we will create pre model of the project and the analyze
AT
89C51MICRO
CONTROLLER
POWER SUPPLY LCD DISPLAY
MainTransformer
(TF1)
Sharingtransformer
(TF2)LOAD
RELAYADC
CURRENT
SENSOR
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
9/137
9
the function of the project the explanation of the project with block diagram over view is
given as follows.
Power Supply Section:
This section is meant for supplying Power to all the sections mentioned above.It
basically consists of a Transformer to step down the 230V ac to 18V ac followed by
diodes. Here diodes are used to rectify the ac to dc. After rectification the obtained
rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to
regulate the obtained dc voltage.
Microcontroller Section:
This section forms the control unit of the whole project. This section basically
consists of a Microcontroller with its associated circuitry like Crystal with capacitors,
Reset circuitry, Pull up resistors (if needed) and so on. The Microcontroller forms the
heart of the project because it controls the devices being interfaced and communicates
with the devices according to the program being written.
Transformers:
In general, the ac line voltage present in your house wiring is not suitable for
electronic circuits. Most circuits require a considerably lower voltage, while a few require
higher voltages. The transformer serves to convert the ac line voltage to a voltage level
more appropriate to the needs of the circuit to be powered. At the same time, the
transformer provides electrical isolation between the ac line and the circuit being
powered, which is an important safety consideration. However, a line transformer is
generally large and heavy, and is rather expensive. Therefore, some power supplies
(notably for PCs) are deliberately designed to operate directly from the ac line without a
line transformer. The output of the transformer is still an ac voltage, but now of an
appropriate magnitude for the circuit to be powered.
ADC:
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
10/137
10
Analog to digital (A/D, ADC) converters are electrical circuit devices that convert
continuous signals, such as voltages or currents, from the analog domain to the digital
domain where the signals are represented by numbers.
LCD Display Section:
This section is basically meant to show up the status of the project. This
project makes use of Liquid Crystal Display to display / prompt for necessary
information.
Sensors:
This part of the system consists of current sensor. These sensor sense various
parameters of load- current and are then sent to the Analog to Digital Converter.
Relay:
In this project Relays are used to the Trip the transformer. A relay is an
electrical switch that opens and closes under control of another electrical circuit. In the
original form, the switch is operated by an electromagnet to open or close one or many
sets of contacts.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
11/137
11
SCHEMATIC:
SCHEMATIC EXPLANATION:
Firstly, the required operating voltage for Microcontroller 89C51 is 5V.
Hence the 5V D.C. power supply is needed by the same. This regulated 5V is generated
by first stepping down the 230V to 18V and 12 V operating voltage for relays. Hence
another supply is required to generate 12V.
The step downed a.c voltage is being rectified by the Bridge Rectifier. The
diodes used are 1N4007. The rectified a.c voltage is now filtered using a C filter. Now
the rectified, filtered D.C. voltage is fed to the Voltage Regulator. This voltage regulator
allows us to have a Regulated Voltage which is +5V. We are using two voltage regulators
i.e., 7805 and 7812. These voltage regulators regulate 5v for microcontroller and 12v for
relays. The rectified; filtered and regulated voltage is again filtered for ripples using an
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
12/137
12
electrolytic capacitor 100F. Now the output from this section is fed to 40th
pin of 89c51
microcontroller to supply operating voltage.
The microcontroller 89C51 with Pull up resistors at Port0 and crystal
oscillator of 11.0592 MHz crystal in conjunction with couple of capacitors of is placed at
18th
& 19th
pins of 89c51 to make it work (execute) properly.
The LCD is interfaced to Microcontroller. The data pins of LCD are connected to
Port 0. The control pins of LCD are connected to Port 2 as shown in schematic.
One of the port 3 pin is connected to the secondary side of transformer one
through bridge rectifier and regulator to check the status of the transformer one i.e
whether the power supply is on or off to the transformer one through relay. Relay is used
to on & off the transformer occurred it is connected to P2.0 microcontroller.
The data pins of ADC are connected to the port 1 of microcontroller. What ever
the data in ADC from C.T (current transformer) will be converted from analog to digital
and fed it to the microcontroller.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
13/137
13
CHAPTER III
HARDWARE Components
The Hardware components used in this project are
Regulated Power Supply MicrocontrollerTransformers Relay ADC Current sensor LCD
3.1 MICROCONTROLLER 89C51
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
14/137
14
INTRODUCTION:
A Micro controller consists of a powerful CPU tightly coupled with memory
RAM, ROM or EPROM), various I / O features such as Serial ports, Parallel Ports,
Timer/Counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital
Converter (ADC), Digital to Analog Converter (ADC), everything integrated onto a
single Silicon Chip.
It does not mean that any micro controller should have all the above said features
on chip, Depending on the need and area of application for which it is designed, The ON-CHIP features present in it may or may not include all the individual section said above.
Any microcomputer system requires memory to store a sequence of instructions
making up a program, parallel port or serial port for communicating with an external
system, timer / counter for control purposes like generating time delays, Baud rate for
the serial port, apart from the controlling unit called the Central Processing Unit.
Advantages of microcontrollers:
1. If a system is developed with a microprocessor, the designer has to go for externalmemory such as RAM, ROM or EPROM and peripherals and hence the size of the PCB
will be large enough to hold all the required peripherals. But, the micro controller has
got all these peripheral facilities on a single chip so development of a similar system with
a micro controller reduces PCB size and cost of the design.
One of the major differences between a micro controller and a microprocessor is
that a controller often deals with bits , not bytes as in the real world application, for
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
15/137
15
example switch contacts can only be open or close, indicators should be lit or dark and
motors can be either turned on or off and so forth.
COMPARISON
What is the difference between a microprocessor and microcontroller?
By microprocessor is meant the general-purpose microprocessors such as Intels
x86 Family(8086,80286,80386,80486,and the Pentium)or Motorolas680x0
family(68000,68010,68020,68030,68040.etc.).These microprocessors contain no RAM,
no ROM, and no I/O PORTS on the chip itself. For this reason, they are commonly
referred as general-purpose microprocessors.
(A)General purpose Micro processor System
CPU RAM ROM
I/O TIMER Serial
RAM
CPU
General
purpose
Micro
Processor
ROMI/OPORT TIMER
SERIALCOM
PORT
Address bus
Data bus
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
16/137
16
COM
PORT
(b)Microcontroller
A system designer using a general-purpose microprocessor such as the Pentium or
the 68040 must add RAM, ROM, I/O PORTS, and TIMERS externally to make them
functional. Although the addition of external RAM, ROM and I/O PORTS makes these
systems bulkier and much expensive, they have the advantage of versatility such that the
designer can decide on the amount of RAM, ROM and I/O PORTS needed to fit the task
at hand this is not the case with microcontrollers.
A microcontroller has a CPU (a microprocessor) in addition to a fixed amount of
RAM, ROM, I/OPORTS, and a timer all on a single chip. In other words, the processor,
RAM, ROM, I/OPORTS, and timer are all embedded together on one chip; therefore, the
designer cant add any external memory, I/O, or timer to it. The fixed amount of on-chip
ROM, RAM, and number of I/O PORTS in microcontrollers makes them ideal for many
applications in which cost and space are critical. In many applications, for example a TV
remote control, there is no need for the computing power of a 486 or even an 8086
microprocessor. In many applications, the space it takes, the power it consumes, and the
price per unit are much more critical considerations than the computing power. These
applications most often require some I/O operation to read signal and turn on and off
certain bits. For these reason some call these processors IBP (itty-bitty processors).
In 1981,Intel corporation introduced an 8 bit microcontroller called the 8051.This
microcontroller had 128 bytes of RAM,4K bytes of on-chip ROM, two timers, one serial
port, and 4 ports(each 8-bits wide)all on single chip. At that time it was also referred to as
a system on a chip.
The 8051 is an 8-bit processor, meaning that the CPU can work on only 8-bits of
data at a time. Data larger than 8-bits has to be broken into 8-bit pieces to be processed
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
17/137
17
by the CPU. The 8051 can have a maximum of 64K bytes of ROM; many manufacturers
have put only 4Kbytes on chip.
A Micro controller consists of a powerful CPU tightly coupled with memory,
various I/O interfaces such as serial port, parallel port timer or counter, interrupt
controller, data acquisition interfaces-Analog to Digital converter, Digital to Analog
converter, integrated on to a single silicon chip. If a system is developed with a
microprocessor, the designer has to go for external memory such as RAM, ROM,
EPROM and peripherals. But controller is provided all these facilities on a single chip.
Development of a Micro controller reduces PCB size and cost of design. One of the
major differences between a Microprocessor and a Micro controller is that a controller
often deals with bits not bytes as in the real world application. Intel has introduced a
family of Micro controllers called the MCS-51.
The Major Features:
Compatible with MCS-51 products 4k Bytes of in-system Reprogrammable flash memory Fully static operation: 0HZ to 24MHZ Three level programmable clock 128 * 8bit timer/counters Six interrupt sources Programmable serial channel Low power idle power-down modes
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
18/137
18
o Why AT 89C51? :
The system requirements and control specifications clearly rule out the use of 16,
32 or 64 bit micro controllers or microprocessors. Systems using these may be earlier to
implement due to large number of internal features. They are also faster and more reliable
but, the above application is satisfactorily served by 8-bit micro controller. Using an
inexpensive 8-bit Microcontroller will doom the 32-bit product failure in any competitive
market place.
Coming to the question of why to use AT89C51 of all the 8-bit microcontroller
available in the market the main answer would be because it has 4 Kb on chip flashmemory which is just sufficient for our application. The on-chip Flash ROM allows the
program memory to be reprogrammed in system or by conventional non-volatile memoryProgrammer. Moreover ATMEL is the leader in flash technology in todays market place
and hence using AT 89C51 is the optimal solution.
AT89C51 MICROCONTROLLER ARCHITECTURE
The 89C51 architecture consists of these specific features:
Eightbit CPU with registers A (the accumulator) and B Sixteen-bit program counter (PC) and data pointer (DPTR) Eight- bit stack pointer (PSW) Eight-bit stack pointer (Sp) Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51) Internal RAM of 128 bytes:
1. Four register banks, each containing eight registers2. Sixteen bytes, which maybe addressed at the bit level3. Eighty bytes of general- purpose data memory
Thirtytwo input/output pins arranged as four 8-bit ports:p0-p3 Two 16-bit timer/counters: T0 and T1
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
19/137
19
Full duplex serial data receiver/transmitter: SBUF Control registers: TCON, TMOD, SCON, PCON, IP, and IE Two external and three internal interrupts sources. Oscillator and clock circuits.
Functional block diagram of micro controller
The 89C51 oscillator and clock:
The heart of the 89C51 circuitry that generates the clock pulses by which all the
internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is provided
for connecting a resonant network to form an oscillator. Typically a quartz crystal and
capacitors are employed. The crystal frequency is the basic internal clock frequency of
the microcontroller. The manufacturers make 89C51 designs that run at specific
minimum and maximum frequencies typically 1 to 16 MHz.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
20/137
20
Oscillator and timing circuit
Types of memory:
The 89C51 have three general types of memory. They are on-chip memory,
external Code memory and external Ram. On-Chip memory refers to physically existing
memory on the micro controller itself. External code memory is the code memory that
resides off chip. This is often in the form of an external EPROM. External RAM is the
Ram that resides off chip. This often is in the form of standard static RAM or flash
RAM.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
21/137
21
a) Code memory
Code memory is the memory that holds the actual 89C51 programs that is to be
run. This memory is limited to 64K. Code memory may be found on-chip or off-chip. It
is possible to have 4K of code memory on-chip and 60K off chip memory
simultaneously. If only off-chip memory is available then there can be 64K of off chip
ROM. This is controlled by pin provided as EA
b) Internal RAM
The 89C51 have a bank of 128 of internal RAM. The internal RAM is found on-
chip. So it is the fastest Ram available. And also it is most flexible in terms of reading
and writing. Internal Ram is volatile, so when 89C51 is reset, this memory is cleared. 128
bytes of internal memory are subdivided. The first 32 bytes are divided into 4 register
banks. Each bank contains 8 registers. Internal RAM also contains 128 bits, which are
addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte
can be addressed by the user. They are numbered 00h to 7Fh. The user may make use of
these variables with commands such as SETB and CLR.
FLASH MEMORY:
Flash memory (sometimes called "flash RAM") is a type of constantly-powered
non volatile that can be erased and reprogrammed in units of memory called blocks. It is
a variation of electrically erasable programmable read-only memory (EEPROM) which,
unlike flash memory, is erased and rewritten at the byte level, which is slower than flash
memory updating. Flash memory is often used to hold control code such as the basic
input/output system (BIOS) in a personal computer. When BIOS needs to be changed
(rewritten), the flash memory can be written to in block (rather than byte) sizes, making it
easy to update. On the other hand, flash memory is not useful as random access memory
(RAM) because RAM needs to be addressable at the byte (not the block) level.
Flash memory gets its name because the microchip is organized so that a section
of memory cells are erased in a single action or "flash." The erasure is caused by Fowler-
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
22/137
22
Nordheim tunneling in which electrons pierce through a thin dielectric material to remove
an electronic charge from afloating gate associated with each memory cell. Intel offers a
form of flash memory that holds two bits (rather than one) in each memory cell, thus
doubling the capacity of memory without a corresponding increase in price.
Flash memory is used in digital cellular phones, digital cameras, LAN switches,
PC Cards for notebook computers, digital set-up boxes, embedded controllers, and other
devices.
Memory Types
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
23/137
23
Memory Type Features
FLASH Low-cost, high-density, high-speed
architecture; low power; high reliability
ROM
Read-Only Memory
Mature, high-density, reliable, low cost;
time-consuming mask required, suitable
for high production with stable code
SRAM
Static Random-Access Memory
Highest speed, high-power, low-density
memory; limited density drives up cost
EPROM
Electrically Programmable Read-Only
Memory
High-density memory; must be exposed
to ultraviolet light for erasure
EEPROM or E
Electrically Erasable Programmable
Read-Only Memory
Electrically byte-erasable; lower
reliability, higher cost, lowest density
DRAM
Dynamic Random Access Memory
High-density, low-cost, high-speed,
high-power
Technical Overview of Flash Memory
Flash memory is a nonvolatile memory using NOR technology, which allows the
user to electrically program and erase information. Intel Flash memory uses memory
cells similar to an EPROM, but with a much thinner, precisely grown oxide between the
floating gate and the source (see Figure 2). Flash programming occurs when electrons are
placed on the floating gate. The charge is stored on the floating gate, with the oxide layer
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
24/137
24
allowing the cell to be electrically erased through the source. Intel Flash memory is an
extremely reliable nonvolatile memory architecture.
Pin diagram of AT89C51
Pin Description:
VCC: Supply voltage.
GND: Ground.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
25/137
25
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 may also be configured to be the multiplexed low order
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.
Port 1 also receives the low-order address bytes during Flash programming and
verification.
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 memories that use 16-bit addresses (MOVX
@DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During
accesses to external data memories that use 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.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
26/137
26
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 pull-ups 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 AT89C51 as listed
below:
Port 3 also receives some control signals for Flash programming and verification
Tab 6.2.1 Port pins and their alternate functions
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 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/6the
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.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
27/137
27
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
AT89C51 is executing code from external program memory, PSEN is activated twice
each machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
EA/VPP:
External Access Enable (EA) must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H up to
FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on
reset.
EA should be strapped to VCC for internal program executions. This pin also receives the
12-volt programming enable voltage (VPP) during Flash programming, for parts that
require 12-volt VPP.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2:
Out put from the inverting oscillator amplifier.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in Figs
6.2.3. 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
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
28/137
28
shown in Figure 6.2.4.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 flip-
flop, but minimum and maximum voltage high and low time specifications must be
observed.
Oscillator Connections External Clock Drive Configuration
Notes:
1. Under steady state (non-transient) conditions, IOL must be externally limited as
follows:
Maximum IOL per port pin: 10 mA Maximum IOL per 8-bit port: Port 0: 26 mA Ports 1, 2, 3: 15 mA Maximum total IOL for all output pins: 71 mA If IOL exceeds the test condition, VOL may exceed the related specification.
Pins are not guaranteed to sink current greater than the listed test conditions.
2. Minimum VCC for Power-down is 2V.
Types of memory:
The 8051 have three general types of memory. They are on-chip memory,
external Code memory and external Ram. On-Chip memory refers to physically existing
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
29/137
29
memory on the micro controller itself. External code memory is the code memory that
resides off chip. This is often in the form of an external EPROM. External RAM is the
Ram that resides off chip. This often is in the form of standard static RAM or flash
RAM.
b) Code memory
Code memory is the memory that holds the actual 8051 programs that is to be run.
This memory is limited to 64K. Code memory may be found on-chip or off-chip. It is
possible to have 4K of code memory on-chip and 60K off chip memory simultaneously.
If only off-chip memory is available then there can be 64K of off chip ROM. This is
controlled by pin provided as EA
b) Internal RAM
The 8051 have a bank of 128 bytes of internal RAM. The internal RAM is found
on-chip. So it is the fastest Ram available. And also it is most flexible in terms of reading
and writing. Internal Ram is volatile, so when 8051 is reset, this memory is cleared. 128
bytes of internal memory are subdivided. The first 32 bytes are divided into 4 register
banks. Each bank contains 8 registers. Internal RAM also contains 128 bits, which are
addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte
can be addressed by the user. They are numbered 00h to 7Fh. The user may make use of
these variables with commands such as SETB and CLR.
Special Function registered memory:
Special function registers are the areas of memory that control specific
functionality of the 8051 micro controller.
a) Accumulator (0E0h)
As its name suggests, it is used to accumulate the results of large no of
instructions. It can hold 8 bit values.
B) B register (0F0h)
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
30/137
30
The B register is very similar to accumulator. It may hold 8-bit value. The b
register is only used by MUL AB and DIV AB instructions. In MUL AB the higher byte
of the product gets stored in B register. In div AB the quotient gets stored in B with the
remainder in A.
c) Stack pointer (81h)The stack pointer holds 8-bit value. This is used to indicate where the next value
to be removed from the stack should be taken from. When a value is to be pushed onto
the stack, the 8051 first store the value of SP and then store the value at the resulting
memory location. When a value is to be popped from the stack, the 8051 returns the
value from the memory location indicated by SP and then decrements the value of SP.
d) Data pointer
The SFRs DPL and DPH work together work together to represent a 16-bit value
called the data pointer. The data pointer is used in operations regarding external RAM
and some instructions code memory. It is a 16-bit SFR and also an addressable SFR.
e) Program counter
The program counter is a 16 bit register, which contains the 2 byte address, which
tells the 8051 where the next instruction to execute to be found in memory. When the
8051 is initialized PC starts at 0000h. And is incremented each time an instruction is
executes. It is not addressable SFR.
f) PCON (power control, 87h)
The power control SFR is used to control the 8051s power control modes.
Certain operation modes of the 8051 allow the 8051 to go into a type of sleep mode
which consume much lee power.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
31/137
31
g) TCON (timer control, 88h)
The timer control SFR is used to configure and modify the way in which the
8051s two timers operate. This SFR controls whether each of the two timers is running
or stopped and contains a flag to indicate that each timer has overflowed. Additionally,
some non-timer related bits are located in TCON SFR. These bits are used to configure
the way in which the external interrupt flags are activated, which are set when an
external interrupt occurs.
h) TMOD (Timer Mode, 89h)
The timer mode SFR is used to configure the mode of operation of each of the
two timers. Using this SFR your program may configure each timer to be a 16-bit timer,
or 13 bit timer, 8-bit auto reload timer, or two separate timers. Additionally you may
configure the timers to only count when an external pin is activated or to count events
that are indicated on an external pin.
i) TO (Timer 0 low/high, address 8A/8C h)
These two SFRs taken together represent timer 0. Their exact behavior depends
on how the timer is configured in the TMOD SFR; however, these timers always count
up. What is configurable is how and when they increment in value.
j) T1 (Timer 1 Low/High, address 8B/ 8D h)
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
32/137
32
These two SFRs, taken together, represent timer 1. Their exact behavior depends
on how the timer is configured in the TMOD SFR; however, these timers always count
up. What is
Configurable is how and when they increment in value.
k) P0 (Port 0, address 90h, bit addressable)
This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0
of port 0 is pin P0.0, bit 7 is pin p0.7. Writing a value of 1 to a bit of this SFR will send a
high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.
l) P1 (port 1, address 90h, bit addressable)
This is port latch1. Each bit of this SFR corresponds to one of the pins on a
micro controller. Any data to be outputted to port 0 is first written on P0 register. For
e.g., bit 0 of port 0 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR
will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to
low level
m) P2 (port 2, address 0A0h, bit addressable) :
This is a port latch2. Each bit of this SFR corresponds to one of the pins on a
micro controller. Any data to be outputted to port 0 is first written on P0 register. For e.g.,
bit 0 of port 0 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will
send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low
level.
n) P3(port 3,address B0h, bit addressable) :
This is a port latch3. Each bit of this SFR corresponds to one of the pins on a
micro controller. Any data to be outputted to port 0 is first written on P0 register. For e.g.,
bit 0 of port 0 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will
send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low
level
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
33/137
33
o) IE (interrupt enable, 0A8h):
The Interrupt Enable SFR is used to enable and disable specific interrupts. The
low 7 bits of the SFR are used to enable/disable the specific interrupts, where the MSB
bit is used to enable or disable all the interrupts. Thus, if the high bit of IE is 0 all
interrupts are disabled regardless of whether an individual interrupt is enabled by setting
a lower bit.
p) IP (Interrupt Priority, 0B8h)
The interrupt priority SFR is used to specify the relative priority of each interrupt.
On 8051, an interrupt maybe either low or high priority. An interrupt may interrupt
interrupts. For e.g., if we configure all interrupts as low priority other than serial
interrupt. The serial interrupt always interrupts the system, even if another interrupt is
currently executing. However, if a serial interrupt is executing no other interrupt will be
able to interrupt the serial interrupt routine since the serial interrupt routine has the
highest priority.
q) PSW (Program Status Word, 0D0h)
The program Status Word is used to store a number of important bits that are set
and cleared by 8051 instructions. The PSW SFR contains the carry flag, the auxiliary
carry flag, the parity flag and the overflow flag. Additionally, it also contains the register
bank select flags, which are used to select, which of the R register banks currently in
use.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
34/137
34
r) SBUF (Serial Buffer, 99h)
SBUF is used to hold data in serial communication. It is physically two registers.
One is writing only and is used to hold data to be transmitted out of 8051 via TXD. The
other is read only and holds received data from external sources via RXD. Both mutually
exclusive registers use address 99h.
I/O ports:
One major feature of a microcontroller is the versatility built into the input/output
(I/O) circuits that connect the 8051 to the outside world. The main constraint that limits
numerous functions is the number of pins available in the 8051 circuit. The DIP had 40
pins and the success of the design depends on the flexibility incorporated into use of
these pins. For this reason, 24 of the pins may each used for one of the two entirely
different functions which depend, first, on what is physically connected to it and, then, on
what software programs are used to program the pins.
PORT 0
Port 0 pins may serve as inputs, outputs, or, when used together, as a bi directional
low-order address and data bus for external memory. To configure a pin as input, 1 must
be written into the corresponding port 0 latch by the program. When used for interfacing
with the external memory, the lower byte of address is first sent via PORT0, latched
using Address latch enable (ALE) pulse and then the bus is turned around to become the
data bus for external memory.
PORT 1
Port 1 is exclusively used for input/output operations. PORT 1 pins have no dual
function. When a pin is to be configured as input, 1 is to be written into the
corresponding Port 1 latch.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
35/137
35
PORT 2
Port 2 maybe used as an input/output port. It may also be used to supply a high
order address byte in conjunction with Port 0 low-order byte to address external memory.
Port 2 pins are momentarily changed by the address control signals when supplying the
high byte a 16-bit address. Port 2 latches remain stable when external memory is
addressed, as they do not have to be turned around (set to 1) for data input as in the case
for Port 0.
PORT 3
Port 3 may be used to input /output port. The input and output functions can be
programmed under the control of the P3 latches or under the control of various special
function registers. Unlike Port 0 and Port 2, which can have external addressing functions
and change all eight-port b se, each pin of port 3 maybe individually programmed to be
used as I/O or as one of the alternate functions. The Port 3 alternate uses are:
Pin Alternate Use SFR
P3.0 - RXD Serial data input SBUF
P3.1 - TXD Serial data output SBUF
P3.2 - INTO 0 External interrupt 0 TCON.1
P3.3 - INTO 1 External interrupt 1 TCON.3
P3.4 - T0 External Timer 0 input TMOD
P3.5 T1 External timer 1 input TMOD
P3.6 - WR External memory write pulse -
P3.7 - RD External memory read pulse -
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
36/137
36
TIMERS
On-chip timing/counting facility has proved the capabilities of the microcontrollerfor implementing the real time application. These includes pulse counting, frequency
measurement, pulse width measurement, baud rate generation, etc,. Having sufficient
number of timer/counters may be a need in a certain design application. The 8051 has
two timers/counters. They can be used either as timers to generate a time delay or as
counters to count events happening outside the microcontroller. Let discuss how these
timers are used to generate time delays and we will also discuss how they are been used
as event counters.
PROGRAMMING 8051 TIMERS
The 8051 has timers: Timer 0 and Timer1.they can be used either as timers or as
event counters. Let us first discuss about the timers registers and how to program the
timers to generate time delays.
BASIC RIGISTERS OF THE TIMER
Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit
architecture, each 16-bit timer is accessed as two separate registers of low byte and high
byte.
TIMER 0 REGISTERS
The 16-bit register of Timer 0 is accessed as low byte and high byte. the low
byte register is called TL0(Timer 0 low byte)and the high byte register is referred to as
TH0(Timer 0 high byte).These register can be accessed like any other register, such as
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
37/137
37
A,B,R0,R1,R2,etc.for example, the instruction MOV TL0, #4Fmoves the value 4FH
into TL0,the low byte of Timer 0.These registers can also be read like any other register.
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1
TH0 TL0
TIMER 1 REGISTERS
Timer 1 is also 16-bit register is split into two bytes, referred to as TL1 (Timer
1 low byte) and TH1(Timer 1 high byte).these registers are accessible n the same way as
the register of Timer 0.
TMOD (timer mode) REGISTER
Both timers 0 and 1 use the same register, called TMOD, to set the various timer
operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside for
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
38/137
38
Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2 bits are used to set the
timer mode and the upper 2 bits to specify the operation.
MODES:
M1, M0:
M0 and M1 are used to select the timer mode. There are three modes: 0, 1, 2.Mode 0 is
a 13-bit timer, mode 1 is a 16-bit timer, and mode 2 is an 8-bit timer. We will concentrate
on modes 1 and 2 since they are the ones used most widely. we will soon describe the
characteristics of these modes, after describing the reset of the TMOD register.
GATE Gate control when set. The timer/counter is enabled only
while the INTx pin is high and the TRx control pin is.
set. When cleared, the timer is enabled.
C/T Timer or counter selected cleared for timer operation
(Input from internal system clock).set for counter
operation (input TX input pin).
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
39/137
39
M 1 Mode bit 1
M0 Mode bit 0
M1 M0 MODE Operating Mode
0 0 0 13-bit timer mode
8-bit timer/counter THx with TLx as
5-bit prescaler.
0 1 1 16-bit timer mode
16-bit timer/counters THx with TLx are
cascaded; there is no prescaler
1 0 2 8-bit auto reload
8-bit auto reload timer/counter;THx
Holds a value that is to be reloaded into
TLx each time it overflows.
1 1 3 Split timer mode.
TMOD Register
C/T (clock/timer):
This bit in the TMOD register is used to decide whether the timer is used as a delay
generator or an event counter. If C/T=0, it is used as a timer for time delay generation.
The clock source for the time delay is the crystal frequency of the 8051.this section is
concerned with this choice. The timers use as an event counter is discussed in the next
section.
EX: Find the values of TMOD to operate as timers in the following modes.
(a)Mode 1 Timer 1(b)Mode 2 Timer 0.Mode 2 Timer 1
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
40/137
40
(c)Mode 0 Timer 1
Solution:
(a)TMOD is 00010000 = 10H
The gate control bit and C/T bit are made 0, and the unused timer(Timer 0 bit is also 0)
(b) TMOD is 01010010=52H
(c) TMOD is 00000000H = 00H
Note: 8051 Timers use 1/12 of XTAL frequency, regardless of machine cycle time.
Clock source for timer
As you know, every timer needs a clock pulse to tick. What is the source of the clock
pulse for the 8051 timers? If C/T=0, the crystal frequency attached to the 8051 is the
source of the clock for the timer. This means that the size of the crystal frequency
attached to the 8051 also decides the speed at which the 8051 timer ticks. The frequency
for the timer is always 1/12th
the frequency of the crystal attached to the 8051.
Although various 8051-based systems have an XTAL frequency of 10MHz,we will
concentrate on the XTAL frequency of 11.0592MHz.the reason behind such an odd
number has to do with the baud rate for serial communication of the 8051.XTAL
=11.0592MHz allows the 8051 system to communicate with the IBM PC with no errors.
Gate
The other bit of the TMOD register id the GATE bit. Notice in the TMOD register in the
below example figure that both Timers 0 and 1 have the GATE bit. What is its purpose?
Every timer has a means of starting and stopping. Some timers do this by software, some
by hardware, and some have both software and hardware controls. the timers in the 8051
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
41/137
41
have is achieved by the instructions SETB TR1 and CLR TR1 for Timer 1,and
SETB TR0 and CLR TR0 for Timer0.the SETB instruction starts it, and it is stopped
by the CLR instruction. These instructions start and stop the timers as long as GATE =0
in the TMOD register. The hardware way of starting and stopping the timer by an
external source GATE =0, meaning that no external hardware is needed to start and stop
the timers. in using software to start and stop the timer where GATE=0,all we need are
the instructions SETB TRx and CLR TRx.
Now that we have this basic understanding of the role of the TMOD register, we will
look at the timers modes and how they are programmed to create a time delay. Because
modes 1 and 2 are so widely used, we describe each of them in detail.
EX:
How are timers 0 and 1 started and stopped by instruction?
Solution:
The timers are started by using instructions to set timer start bits TR0 and
TR1,which are called timer run control bits. They can be cleared by clearing these bits.
When a timer counts to its maximum value, it sets a flag TF0 or TF1.at this point, it is
necessary to know more about the bits TF and TR for timers 0 and 1.while TMOD
controls the timer modes, another register called the TCON controls the timer/counter
operations. The lower four bits of TCON cater to interrupt functions, but the upper four
bits are for timer operations. The details of the TCON register are shown below.
MSB LSB
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
42/137
42
BIT SYMBOL FUNCTION
TCON.7 TF1 Timer 1 overflows flag
TCON.6 TR1 Timer 1 run control bit
TCON.5 TF0 Timer 0 overflows flag
TCON.4 TR0 Timer 0 run control bit
Some assemblers dont allow the use of TF0, TR0, etc.in programs, but instead need the
use of these as bits of TON. For example, TF1 is TCON.7 and TR1 is TCON.6.
Mode 1 programming
The following are the characteristic and operations of mode 1:
1. it is a 16-bit timer: therefore, it allows values of 0000 to FFFFH to be loaded intothe timers registers TL and TH.
2. After TH and TL are loaded with 16-bit initial value, the timer must be started.This is done by SETB TR0 for Timer 0 and SET TR1 for Timer1.
3. After the timer is started, it starts to count up. it counts up until it reaches its limitof FFFFH. When it rolls over from FFFFH to 0000, it sets high a flag bit called
TF (timer flag).this timer flag can be monitored. When this timer flag is raised,
one option would be to stop the timer with the instructions CLR TR0 or CLR
TR1 for Timer 0 and Timer 1, respectively.again, it must be noted that each
timer has its own timer flag: TF0 for Timer 0, and TF1 for Timer 1.
4. After the timer reaches its limit its limit and rolls over, in order to repeat theprocess the registers TH and TL must be reloaded with the original value and TF
must be reset to 0
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
43/137
43
. _
C/T =0 TR TF goes high overflow
When FFFF0 flag
XTAL
oscillat
or/12 TH TL TF
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
44/137
44
Steps to program in mode 1
1. Load the TMOD value register indicating which timer (Timer 0 or Timer 1) is tobe used and which timer mode (0 or 1) is selected.
2. Load register TL and TH with initial count values.3. Start the timer.4. Keep monitoring the timer flag (TF) with the JNB TFx, target instruction to see
if it is raised. Get out of the loop when TF becomes high.
5. Stop the timer.6. Clear the TF flag for the next round7. Go back to Step 2 to load TH and TL again.
EX: In the following program, we are creating a square wave of 50% duty cycle (with
equal portion high and low) on the P1.5 bit. Timer 0 is used to generate the time delay.
Analyze the program.
Solution:
MOV TMOD, # 01 ; Timer 0, mode 1 (16bit mode)
HERE: MOV TL0, #0F2H ; TL0 =F2H, the low byte
MOV TH0, #0FFH ; TH0 =FFH, the High byte
CPL P1.5 ;toggle P1.5
ACALL DELAY
SJMP HERE ; load TH , TL again
; ------------ delay using Timer 0
DELAY:
SETB TR0 ; start Timer 0
AGAIN: JNB TF0, AGAIN ; monitor Timer 0 flag until
; It rolls over
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
45/137
45
CLR TR0 ; stop Timer 0
CLR TF0 ; clear Timer 0 flag
RET
Finding values to be loaded into the timer
Assuming that we know the amount of timer delay we need, the question is how to find
the values needed for the TH, TL registers. To calculate the values to be loaded into the
TL and TH registers.
1. Divide the desired time delay by 1.085s.2. Perform 65536-n, where n is the decimal value we got in step 1.3. Convert the result of step 2 to hex, where yyxx is the initial hex value to be loaded
into the timers registers.
4. Set TL=xx and TH=yy.
Generating a large time delay
Size of the time delay depends on two factors; (a) the crystal frequency and (b) the
timers 16-bit register in mode 1.both of these factors are beyond the control of the 8051
programmer. We saw earlier that the largest time delay is achieved by making both TH
and TL zero. what if that is not enough?
See the below example.
Ex: AssumingXTAL = 2MHz,write a program to generate a pulse train 2 seconds period
on pin P2.4.USse Timer 1 in mode 1.
Solution:
MOV TMOD, #10H ; Timer 1, mode 1
REPT: MOV R0, #28 ; counter for multiple delays
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
46/137
46
CPL P2.4 ; complement P2.4
BACK: MOV TL1, #00H ; load count value in TL1
MOV TH1, #00H ; load count value in th1
SETB TR1 ; start timer
AGAIN: JNB TF1, AGAIN ; stay until timer roller over
CLR TR1 ; stop timer
CLR TF1 ; clear timer flag
DJNZ R0, BACK ; if R0 is not zero, reload timer
SJMP REPT ; repeat for continuous pulse
generation
Calculation = 28x 35.75ms =1001 ms.
Mode 0
Mode 0 is exactly like mode 1 except that it is a 13-bit timer instead of 16-bit.the 13-bit
counter can hold values between 0000 to 1FFFH in TH-TL. Therefore, when the timer
reaches its maximum of 1FFH, it rolls over to 0000, and TF is raised.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
47/137
47
Mode 2 programming
The following are the characteristics and operations of mode 2.
1. It is 8-bit timer; therefore, it allows only values if 00 to FFH to be loaded into thetimers register TH.
2. After TH is loaded with the 8-bit value, the 8051 gives a copy of it to TL. Thenthe 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 started, it start to count up by incrementing the TLregister. 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, and TF1 is raised.
Overflow
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
48/137
48
flag
TR TF goes high
when FF---0
4. When the TL registers rolls from FFH to 0 and TF is set to 1, TL is reloadedautomatically 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 an auto-reload, in
contrast with mode 1 in which the programmer has to reload TH and TL.
XTAL
Oscillator /12 TL
TH
TF
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
49/137
49
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 the
original value. This mode has many applications, including setting the baud rate in
serial communication.
Steps to program in mode 2
To generate a time delay using the timers mode 2 take the following steps.
1. Load the TMOD value register indicting which timer (Timer 0 or Timer 1) is tobe used, and select the timer mode(mode 2).
2. Load the TH registers with the initial count value.3. start the timer
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
50/137
50
4. Keep monitoring the timer flag (TF) with the JNB TFx, target instruction to seewhether it is raised. get out of the loop when TF goes high.
5. clear the TF flag6. Go back to step 4, since mode 2 is auto-reload.
SERIAL COMMUNICATION:
Computers can transfer data in two ways: parallel and serial. In parallel
data transfers, often 8 or more lines (wire conductors) are used to transfer data to a device
that is only a few feet away. Examples of parallel transfers ae printers and hard disks;
each uses cables with many wire strips. Although in such cases a lot of data can be
transferred in a short amount of time by using many wires in parallel, the distance cannot
be great. To transfer to a device located many meters away, the serial method is used. In
serial communication, the data is sent one bit at a time, in contrast to parallel
communication, in which the data is sent a byte or more at a time. Serial communication
of the 8051 is the topic of this chapter. The 8051 has serial communication capability
built into it, there by making possible fast data transfer using only a few wires.
If data is to be transferred on the telephone line, it must be converted from 0s and
1s to audio tones, which are sinusoidal-shaped signals. This conversion is performed by
a peripheral device called a modem, which stands for modulator/demodulator.
Serial data communication uses two methods, asynchronous and synchronous.
The synchronous method transfers a block of data at a time, while the asynchronous
method transfers a single byte at a time.
In data transmission if the data can be transmitted and received, it is a duplex
transmission. This is in contrast to simplex transmissions such as with printers, in which
the computer only sends data. Duplex transmissions can be half or full duplex,
depending on whether or not the data transfer can be simultaneous. If data is transmitted
one way at a time, it is referred to as half duplex. If the data can go both ways at the
same time, it is full duplex. Of course, full duplex requires two wire conductors for the
data lines, one for transmission and one for reception, in order to transfer and receiv e
data simultaneously.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
51/137
51
Asynchronous serial communication and data framing
The data coming in at the receiving end of the data line in a serial data transfer is
all 0s and 1s; it is difficult to make sense of the data unless the sender and receiver agree
on a set of rules, a protocol, on how the data is packed, how many bits constitute a
character, and when the data begins and ends.
Start and stop bits
Asynchronous serial data communication is widely used for character-oriented
transmissions, while block-oriented data transfers use the synchronous method. In the
asynchronous method, each character is placed between start and stop bits. This is called
framing. In the data framing for asynchronous communications, the data, such as ASCII
characters, are packed between a start bit and a stop bit. The start bit is always one bit,
but the stop bit can be one or two bits. The start bit is always a 0 (low) and the stop bit
(s) is 1 (high).
Data transfer rate
The rate of data transfer in serial data communication is stated in bps (bits per
second). Another widely used terminology for bps is baud rate. However, the baud and
bps rates are not necessarily equal. This is due to the fact that baud rate is the modem
terminology and is defined as the number of signal changes per second. In modems a
single change of signal, sometimes transfers several bits of data. As far as the conductor
wire is concerned, the baud rate and bps are the same, and for this reason we use the bps
and baud interchangeably.
The data transfer rate of given computer system depends on communication ports
incorporated into that system. For example, the early IBMPC/XT could transfer data at
the rate of 100 to 9600 bps. In recent years, however, Pentium based PCS transfer data at
rates as high as 56K bps. It must be noted that in asynchronous serial data
communication, the baud rate is generally limited to 100,000bps.
RS232 Standards
To allow compatibility among data communication equipment made by various
manufacturers, an interfacing standard called RS232 was set by the Electronics Industries
Association (EIA) in 1960. In 1963 it was modified and called RS232A. RS232B AND
RS232C were issued in 1965 and 1969, respectively. Today, RS232 is the most widely
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
52/137
52
used serial I/O interfacing standard. This standard is used in PCs and numerous types of
equipment. However, since the standard was set long before the advert of the TTL logic
family, its input and output voltage levels are not TTL compatible. In RS232, a 1 is
represented by -3 to -25V, while a 0 bit is +3 to +25V, making -3 to +3 undefined. For
this reason, to connect any RS232 to a microcontroller system we must use voltage
converters such as MAX232 to convert the TTL logic levels to the RS232 voltage levels,
and vice versa. MAX232 IC chips are commonly referred to as line drivers.
RS232 pins
RS232 cable, commonly referred to as the DB-25 connector. In labeling, DB-25P
refers to the plug connector (male) and DB-25S is for the socket connector(female).
Since not all the pins are used in PC cables, IBM introduced the DB-9 Version of the
serial I/O standard, which uses 9 pins only, as shown in table.
DB-9 pin connector
1 2 3 4 5
6 7 8 9
(Out of computer and exposed end of cable)
Pin Functions:
Pin Description
1 Data carrier detect (DCD)
2 Received data (RXD)
3 Transmitted data (TXD)
4 Data terminal ready(DTR)
5 Signal ground (GND)6 Data set ready (DSR)
7 Request to send (RTS)
8 Clear to send (CTS)
9 Ring indicator (RI)
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
53/137
53
Note: DCD, DSR, RTS and CTS are active low pins.
The method used by RS-232 for communication allows for a simple connection of three
lines: Tx, Rx, and Ground. The three essential signals for 2 way RS-232
Communications are these:
TXD: carries data from DTE to the DCE.
RXD: carries data from DCE to the DTE
SG: signal ground
8051 connection to RS232
The RS232 standard is not TTL compatible; therefore, it requires a line driver
such as the MAX232 chip to convert RS232 voltage levels to TTL levels, and vice versa.
The interfacing of 8051 with RS232 connectors via the MAX232 chip is the main topic.
The 8051 has two pins that are used specifically for transferring and receiving
data serially. These two pins are called TXD and RXD and a part of the port 3 group
(P3.0 and P3.1). pin 11 of the 8051 is assigned to TXD and pin 10 is designated as RXD.
These pins are TTL compatible; therefore, they require a line driver to make them RS232
compatible. One such line driver is the MAX232 chip.
MAX232 converts from RS232 voltage levels to TTL voltage levels, and viceversa. One advantage of the MAX232 chip is that it uses a +5V power source which, is
the same as the source voltage for the 8051. In the other words, with a single +5V power
supply we can power both the 8051 and MAX232, with no need for the power supplies
that are common in many older systems. The MAX232 has two sets of line drivers for
transferring and receiving data. The line drivers used for TXD are called T1 and T2,
while the line drivers for RXD are designated as R1 and R2. In many applications only
one of each is used.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
54/137
54
Embedded
Controller
RXD
TXD
TXD
RXD2
3
5
GND
MAX 232
Baud rate in the 8051
The 8051 transfers and receives data serially at many different baud rates. The
baud rate in the 8051 is programmable. The is done with the help of Timer1. The 8051
divides the crystal frequency by 12 to get the machine cycle frequency. In the case of
XTAL=11.0592MHZ, the machine cycle frequency is 921.6 KHz
(11.0592MHz/12=921.6KHz). the 8051s serial communication UART circuitry divides
the machine cycle frequency of 921.6khz divided by 32 once more before it is used by
Timer 1 to set the Baud rate. Therefore, 921.6 kHz divided by 32 gives 28,800 Hz. This
is the number well use to find the Timer 1 value to set baud rate.
Baud rate TH1(Decimal) TH1(Hex)
9600 -3 FD
4800 -6 FA
2400 -12 F4
1200 -24 E8
NOTE: XTAL=11...592MHz
SBUF register
SBUF is an 8-bit register used solely for serial communication in the 8051. for a
byte of data to be transferred via the TXD line, it must be placed in the SBUF register.
Similarly, SBUF holds the byte of data when it is received by the 8051s RXD line.
SBUF can be accessed like any other register in the 8051. Look at the following the
examples of how this register is accessed.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
55/137
55
MOV SBUF, #D ; load SBUF=44h, ASCII for D
MOV SBUF, A ; copy accumulator into SBUF
MOV A, SBUF ; copy SBUF into accumulator
The moment a byte is written into SBUF, it is framed with the start and stop bits
and transferred serially via the TXD pin. Similarly, when the bits are received serially
via RXD, the 8051 defames it by eliminating the stop and start bits, making a byte out of
the data received, and then placing it in the SBUF.
SCON (serial control) register
The SCON register is an 8-bit register used to program the start bit, stop bit, and
data bits of data framing, among other things.
The following describes various bits of the SCON register.
SM0 SM1 SM2 REN TB8 RB8 TI RI
SM0 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
TI SCON.1 Transmit interrupt flag. Set by hardware at the beginning
Of the stop bit in mode 1. Must be cleared by software.
RI SCON.0 Receive interrupt flag. Set by hardware halfway through
the stop bit time mode 1. Must be cleared by software.
Note: Make SM2, TB8, and RB8=0.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
56/137
56
SM0, SM1
SM0 and SM1 are D7 and D6 of the SCON register, respectively. These two bits
determine the framing of data by specifying the number of bits per character and the start
and stop bits. They take the following combinations.
SM0 SM1 FUNCTION
0 0 Serial Mode 0
0 1 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit
1 0 Serial Mode 2
1 1 Serial Mode 3
Of the 4 serial modes, only mode 1 is of interest to us. In the SCON register,
when serial mode 1 is chosen, the data framing is 8 bits, 1 stop bit, and 1 start bit, which
makes it compatible with the COM port of IBM/compatible PCs. More importantly,
serial mode 1 allows the baud rate to be variable and is set by Timer 1 of the 8051. In
serial mode 1, for each character a total of 10 bits are transferred, where the first bit is the
start bit, followed by 8 bits of data, and finally 1 stop bit.
MODE 0
In mode 0, the data are transferred through the RXD pin, while clock pulses appear on the
TXD pin. The bout rate is fixed at 1/12 the quartz oscillator frequency. On transmit, the
least significant bit (LSB bit) is being sent/received first. (received).
TRANSMIT
Data transmission in form of pulse train automatically starts on the pin RXD at the
moment the data has been written to the SBUF register.In fact, this process starts after
any instruction being performed on this register. Upon all 8 bits have been sent, the bit TI
in the SCON register is automatically set.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
57/137
57
RECEIVE
Starts data receiving through the pin RXD once two necessary conditions are met: bit
REN=1 and RI=0 (both bits reside in the SCON register). Upon 8 bits have been
received, the bit RI (register SCON) is automatically set, which indicates that one byte is
received.
Since, there are no START and STOP bits or any other bit except data from the SBUF
register, this mode is mainly used on shorter distance where the noise level is minimal
and where operating rate is important. A typical example for this is I/O port extension by
adding cheap IC circuit ( shift registers 74HC595, 74HC597 and similar).
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
58/137
58
Mode 1
In Mode1 10 bits are transmitted through TXD or received through RXD in the following
manner: a START bit (always 0), 8 data bits (LSB first) and a STOP bit (always 1) last.
The START bit is not registered in this pulse train. Its purpose is to start data receiving
mechanism. On receive the STOP bit is automatically written to the RB8 bit in the SCON
register.
TRANSMIT
A sequence for data transmission via serial communication is automatically started upon
the data has been written to the SBUF register. End of 1 byte transmission is indicated by
setting the TI bit in the SCON register.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
59/137
59
RECEIVE
Receiving starts as soon as the START bit (logic zero (0)) appears on the pin RXD. The
condition is that bit REN=1and bit RI=0. Both of them are stored in the SCON register.
The RI bit is automatically set upon receiving has been completed.
The Baud rate in this mode is determined by the timer 1 overflow time.
MODE 2
SM2
SM2 is the D5 bit of the SCON register. This bit enables the multiprocessing
capability of the 8051. For our applications, we will make SM2=0 since we are not using
the 8051 in a multi processor environment.
REN
The REN (receive enable) bit is D4 of the SCON register. The REN bit is also
referred to as SCON.4 since SCON is a bit-addressable register. When the REN bit is
high, it allows the 8051 to receive data on the RXD pin of the 8051. As a result if we
want the 8051 to both transfer and receive data, REN must be set to 1. By making
REN=0, the receiver is disabled. Making REN=1 or REN=0 can be achieved by the
instructions SETB SCON.4 and CLR SCON.4, respectively. Notice that these
instructions use the bit-addressable features of the register SCON. This bit can be used to
block any serial data reception and is an extremely important in the SCON register.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
60/137
60
TB8
TB8 (transfer bit 8) is bit D3 of SCON. It is used for serial modes 2 and 3. we
make TB8=0 since it is not used in our applications.
RB8
RB8 (receive bit 8) is bit D2 of the SCON register. In serial mode 1, this bit gets
a copy of the stop bit when an 8-bit data is received. This is (as is the case for TB8) is
rarely used anymore. In all our applications we will make RB8=0. Like TB8, the RB8
bit is also used in serial modes 2 and 3.
TRANSMIT
TI (transmit interrupt) is bit D1 of the SCON register. This is an extremely
important flag bit in the SCON register. When the 8051 finishes the transfer of the 8-bit
character, it raises the TI flag to indicate that it is ready to transfer another byte. The TI
bit is raised at the beginning of the stop bit.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
61/137
61
RECEIVE
RI (receive interrupt) is the D0 of the SCON register. This is another extremely
important flag bit in the SCON register. When the 8051 receives data serially via RXD,
it gets rid of the start and stop bits and places the byte in the SBUF register. Then it
raises the RI flag bit to indicate that a byte has been received and should be picked up
before it is lost. RI is raised halfway through the stop bit.
Mode 3
Mode 3 is the same as Mode 2 except the baud rate. In Mode 3 is variable and can be
selected.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
62/137
62
FLOW CHART:
TX Loop:
START
Initialization:
Load SFRs with Respective values
Copy data into Accumulator
(or) memory location
Copy into SBUF
IsTI = = 1
Clr TI
STOP
RX Loop:
START
Initialization:
Load SFRs with Respective values
`
Copy SBUF into
Memory
Is
RI = = 1
Clr RI
STOP
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
63/137
63
BAUD RATE CALCULATION:
Internal timer stages are as fallows
XClkDivided
b 12
Divided
by 32
Divided
by X
UARTBaud Rate
Divided by X box can be replaced with T1 timer so that by changing the value of timer
we can obtain the required baud rate.
Let XClk = 11.0592 Mhz
Baud Rate = (XClk / 12 / 16 / 2 / X )
For attaining 9600 baud Rate,
X can be calculated as
= 11.0592 x 106 / 12 / 16 / 2 / 9600
= 3
So set the 2s Complement of 3 in Timer 1 so that we can achieve 9600 baud rates.
Note: Assuming 8-bit Auto reload mode and 8-bit variable baud rate modes.
Doubling the baud rate in the 8051:
There are two ways to increase the baud rate to data transfer in the 8051.
1. Use a higher- frequency crystal.2. Change a bit in the PCON register, shown below.
SMOD -- -- -- GF1 GF0 PD IDL
Option1 is not feasible in many situations since the system crystal is fixed. More
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
64/137
64
Importantly, it is not feasible because the new crystal may not be compatible with the
IBM PC serial COM ports baud rate. Therefore, we will explore option2. there is a
software way to double the baud rate of the 8051 while the crystal frequency is fixed.
This is done with the register called PCON (power control). The PCON register is an 8-
bit register. Of the 8 bits, some are unused, and some are used for the power control
capability of the 8051. The bit that is used for the serial communication is D7, the SMOD
(serial mode) bit. When the 8051 is powered up, D7 (SMOD) of this PCON register is
zero. We can set it to high by software and thereby double the baud rate. The following
sequence of instructions must be used to set high D7 of PCON, since it is not a bit-
addressable register:
MOV A, PCON ; place a copy a of PCON in ACC
SETB ACC.7 ; make D7=1MOV PCON, A ; changing any other bits
To see how the baud rate is double with this method, we show the role of the
SMOD bit (D7 bit of the PCON register), which can be 0 or 1. we discuss each case.
Baud rates for SMOD =0
When SMOD=0, the 8051 divides 1/12 of the crystal frequency by 32 and uses
that frequency for Timer 1 to set the baud rate. In the case of XTAL=11.0592MHZ we
have:
Machine cycle freq.=11.0592 MHz/12 = 921.6KHz
And
921.6 KHz/32 = 28,800 Hz since SMOD=0
This is the frequency used by Timer 1 to set the baud rate. This has been the basis
of all the examples so far since it is the default when the 8051 is powered up. The baud
rate for SMOD=0 was listed in above table.
Baud rates for SMOD = 1
With the fixed crystal frequency, we can double the baud rate by making
SMOD=1. When the SMOD bit (D7 of the PCON register) is set to 1, 1/12 of XTAL is
divided by 16 (instead of 32) and that is the frequency used by Timer 1 to set the baud
rate. In the case of XTAL=11.0592 MHz, we have:
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
65/137
65
Machine cycle freq. = 11.0592 MHz / 12 = 921.6 KHz
And
921.6 KHz / 16 = 57,600 Hz since SMOD = 1
This is the frequency used by Timer 1 to set the baud rate.
Table: Baud Rate comparison for SMOD = 0 and SMOD = 1
TH1 (Decimal) (Hex) SMOD = 0 SMOD = 1
-3 FD 9,600 19,200
-6 FA 4,800 9,600
-12 F4 2,400 4,800
-24 E8 1,200 2,400
Note: XTAL=11.0592 MHz.
Table: shows that the values loaded into TH1 are the same for both cases; however, thebaud rates are doubled when SMOD=1.
INTERRUPTS:
Interrupts are hardware signals that are used to determine conditions that exist in
external and internal circuits. Any interrupt can cause the 8051 to perform a hardware
call to an interrupt handling subroutine that is located at a predetermined absolute
address in the program memory.
Five interrupts are provided in the 8051. Three of these are generated automatically
by the internal operations: Timer flag 0, Timer Flag 1, and the serial port interrupt (RI or
TI) Two interrupts are triggered by external signals provided by the circuitry that is
connected to the pins INTO 0 and INTO1. The interrupts maybe enable or disabled, given
priority or otherwise controlled by altering the bits in the Interrupt Enabled (IE) register,
Interrupt Priority (IP) register, and the Timer Control (TCON) register. . These interrupts
are mask able i.e. they can be disabled. Reset is a non maskable interrupt which has the
highest priority. It is generated when a high is applied to the reset pin. Upon reset, the
registers are loaded with the default values.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
66/137
66
Each interrupt source causes the program to do store the address in PC onto the
stack and causes a hardware call to one of the dedicated addresses in the program
memory. The appropriate memory locations for each for each interrupt are as follows:
Interrupt Address
RESET 0000
IE0 (External interrupt 0) 0003
TF0 (Timer 0 interrupt) 000B
IE1 (External interrupt 1) 0013
TF1 (Timer 1 interrupt) 001B
SERIAL 0023
Functions of micro controller in main unit are
1. Sends appropriate commands to ADC to start conversion,
2. Collects the output of ADC for every 10 sec and stores in buffer,
3. Sends command to the modem for dialing the base every 80 sec,
4. Sends data in a serial manner to MODEM,
5. After data gets transmitted sends command for disconnection.
6. Sends appropriate information to the display unit as per status
of the communication medium.
-
7/27/2019 88043168 16 Doc of Automatic Load Sharing of Transformers
67/137
67
RELAY:
A relay is an electrical switch that opens and closes under the control of another
electrical circuit. In the original form, the switch is operated by anelectromagnetto open
or close one or many sets of contacts. It was invented byJoseph Henryin1835. Because
a relay is able to control an output circuit of higher power than the input circuit, it can be
considered to be, in a broad sense, a form of an electricalamplifier.
Operation
When acurrentflows through thecoil, the resultingmagnetic fieldattracts an armature
that is mechanically linked to a moving contact. The movement either makes or breaks a
connection with a fixed contact. When the current to the coil is switched off, the armature
is returned by a force approximately half as strong as the magnetic force to its relaxed
position. Usually this is aspring, but gravity is also used commonly in industrial motor
starters. Most relays are manufactured to operate quickly. In a low voltage application,
this is to reduce noise. In a high voltage or high current application, this is to reduce
arcing.
If the coil is energized with DC, adiodeis frequently installed across the coil, to dissipate
the energy from the collapsing magnetic field at deactivation, which would otherwise
generate a spike of voltage and might cause damage to circuit components. Some
automotive relays already include that diode inside the relay case. Alternatively a contact
protection network, consisting of a capacitor and resistor in series, may absorb the surge.
If the coil is designed to be energized with AC, a small copper ring can be crimped to the
end of the solenoid. This "shading ring" creates a small out-of-phase current, which
increases the minimum pull on the armature during the AC cycle.[1]
By analogy with the functions of the original electromagnetic device, a solid-state relay is
made with athyristoror other solid-state switching device. To achieve electrical isolation
anoptocouplercan be used which is alight-emitting diode(LED) coupled with a photo
transistor.
http://en.wikipedia.org/wiki/Switchhttp://en.wikipedia.org/wiki/Switchhttp://en.wikipedia.org/wiki/Electrical_circuithttp://en.wikipedia.org/wiki/Electrical_circuithttp://en.wikipedia.org/wiki/Magnethttp://en.wikipedia.org/wiki/Magnethttp://en.wikipedia.org/wiki/Magnethttp://en.wikipedia.org/wiki/Joseph_Henryhttp://en.wikipedia.org/wiki/Joseph_Henryhttp://en.wikipedia.org/wiki/Joseph_Henryhttp://en.wikipedia.org/wiki/1835http://en.wikipedia.org/wiki/1835http://en.wikipedia.org/wiki/1835http://en.wikipedia.org/wiki/Amplifierhttp://en.wikipedia.org/wiki/Amplifierhttp://en.wikipedia.org/wiki/Amplifierhttp://en.wikipedia.org/wiki/Current_%28electricity%29http://en.wikipedia.org/wiki/Current_%28electricity%29http://en.wikipedia.org/wiki/Current_%28electricity%29http://en.wikipedia.org/wiki/Coilhttp://en.wikipedia.org/wiki/Coilhttp://en.wikipedia.org/wiki/Coilhttp://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Armature_%28electrical_engineering%29http://en.wikipedia.org/wiki/Armature_%28electrical_engineering%29http://en.wikipedia.org/wiki/Spring_%28device%29http://en.wikipedia.org/wiki/Spring_%28device%29http://en.wikipedia.org/wiki/Spring_%28device%29http://en.wikipedia.org/wiki/Arcinghttp://en.wikipedia.org/wiki/Arcinghttp://en.wikipedia.org/wiki/Flyback_diodehttp://en.wikipedia.org/wiki/Flyback_diodehttp://en.wikipedia.org/wiki/Flyback_diodehttp://en.wikipedia.org/wiki/#_note-0http://en.wikipedia.org/wiki/#_note-0http://en.wikipedia.org/wiki/#_note-0http://en.wikipedia.org/wiki/Thyristorhttp://en.wikipedia.org/wiki/Thyri