PC Based Scada Project Implementation
PC Based Scada Project Implementation
INTRODUCTION
The purpose of this PROJECT is to acquire the remote electrical parameters like
Voltage, Current, temperature etc., and send these real time values to PC from
Microcontroller using MAX232. This project is also designed to protect the electrical
circuitry by operating an Electromagnetic Relay. The Relay can be used to operate a
cooling fan to reduce the temperature and further increase in temperature can switch off
the main electrical supply.
1
5. Interfacing sensors to controller.
6. Controlling of electrical appliances automatically.
SCADA stands for Supervisory Control and Data Acquisition. It generally refers
to industrial control systems computer systems that monitor and control industrial,
infrastructure, or facility-based processes, as described below:
2
A SCADA System usually consists of the following subsystems:
3
Some embedded systems have to operate in extreme environmental conditions
such as very high temperatures and humidity.
Application Areas:
Nearly 99 per cent of the processors manufactured end up in embedded systems. The
embedded system market is one of the highest growth areas as these systems are used in
very market segment- consumer electronics, office automation, industrial automation,
telecommunications, transportation, military and so on.
Consumer appliances:
At home we use a number of embedded systems which include digital camera, digital
diary, DVD player, electronic toys, microwave oven, remote controls for TV and air-
conditioner, VCO player, video game consoles, video recorders etc. Today’s high-tech
car has about 20 embedded systems for transmission control, engine spark control, air-
conditioning, navigation etc. Even wristwatches are now becoming embedded systems.
The palmtops are powerful embedded systems using which we can carry out many
general-purpose tasks such as playing games and word processing.
Office automation:
The office automation products using embedded systems are copying machine, fax
machine, key telephone, modem, printer, scanner etc.
Industrial automation:
Today a lot of industries use embedded systems for process control. These include
pharmaceutical, cement, sugar, oil exploration, nuclear energy, electricity generation and
transmission. The embedded systems for industrial use are designed to carry out specific
tasks such as monitoring the temperature, pressure, humidity, voltage, current etc., and
then take appropriate action based on the monitored levels to control other devices or to
send information to a centralized monitoring station. In hazardous industrial environment,
where human presence has to be avoided, robots are used, which are programmed to do
4
specific jobs. The robots are now becoming very powerful and carry out many interesting
and complicated tasks such as hardware assembly.
Medical electronics:
Computer networking:
Telecommunications:
5
Wireless technologies:
Insemination:
Testing and measurement are the fundamental requirements in all scientific and
engineering activities. The measuring equipment we use in laboratories to measure
parameters such as weight, temperature, pressure, humidity, voltage, current etc. are all
embedded systems. Test equipment such as oscilloscope, spectrum analyzer, logic
analyzer, protocol analyzer, radio communication test set etc. are embedded systems built
around powerful processors. Thank to miniaturization, the test and measuring equipment
are now becoming portable facilitating easy testing and measurement in the field by
field-personnel.
Security:
Security of persons and information has always been a major issue. We need to
protect our homes and offices; and also the information we transmit and store.
Developing embedded systems for security applications is one of the most lucrative
businesses nowadays. Security devices at homes, offices, airports etc. for authentication
and verification are embedded systems. Encryption devices are nearly 99 per cent of the
processors that are manufactured end up in~ embedded systems. Embedded systems find
applications in every industrial segment- consumer electronics, transportation, avionics,
biomedical engineering, manufacturing, process control and industrial automation, data
communication, telecommunication, defense, security etc. Used to encrypt the data/voice
being transmitted on communication links such as telephone lines. Biometric systems
using fingerprint and face recognition are now being extensively used for user
6
authentication in banking applications as well as for access control in high security
buildings.
Finance:
Financial dealing through cash and cheques are now slowly paving way for
transactions using smart cards and ATM (Automatic Teller Machine, also expanded as
Any Time Money) machines. Smart card, of the size of a credit card, has a small micro-
controller and memory; and it interacts with the smart card reader! ATM machine and
acts as an electronic wallet. Smart card technology has the capability of ushering in a
cashless society. Well, the list goes on. It is no exaggeration to say that eyes wherever
you go, you can see, or at least feel, the work of an embedded system!
7
above the operating system. The same architecture is applicable to any computer
including a desktop computer. However, there are significant differences. It is not
compulsory to have an operating system in every embedded system. For small appliances
such as remote control units, air conditioners, toys etc., there is no need for an operating
system and you can write only the software specific to that application. For applications
involving complex processing, it is advisable to have an operating system. In such a case,
you need to integrate the application software with the operating system and then transfer
the entire software on to the memory chip. Once the software is transferred to the
memory chip, the software will continue to run for a long time you don’t need to reload
new software.
Now, let us see the details of the various building blocks of the hardware of an
embedded system. For small appliances such as remote control units, air conditioners,
toys etc., there is no need for an operating system and you can write only the software
specific to that application. For applications involving complex processing, it is advisable
to have an operating system. For applications involving complex processing, it is
advisable to have an operating system. In such a case, you need to integrate the
application software with the operating system and then transfer the entire software on to
the memory chip. As shown in Fig.1.1.2 the building blocks are;
· Input Devices
· Output devices
· Communication interfaces
· Application-specific circuitry
Smart card, of the size of a credit card, has a small micro-controller and memory; and it
interacts with the smart card reader! ATM machine and acts as an electronic wallet.
Smart card technology has the capability of ushering in a cashless society. Well, the list
8
goes on. For applications involving complex processing, it is advisable to have an
operating system. For applications involving complex processing, it is advisable to have
an operating system. In such a case, you need to integrate the application software with
the operating system and then transfer the entire software on to the memory chip.
The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is
a low-cost processor. Its main attraction is that on the chip itself, there will be many other
components such as memory, serial communication interface, analog-to digital converter
etc. So, for small applications, a micro-controller is the best choice as the number of
external components required will be very less. On the other hand, microprocessors are
more powerful, but you need to use many external components with them. D5P is used
mainly for applications in which signal processing is involved such as audio and video
processing.
9
Memory:
The memory is categorized as Random Access 11emory (RAM) and Read Only
Memory (ROM). The contents of the RAM will be erased if power is switched off to the
chip, whereas ROM retains the contents even if the power is switched off. So, the
firmware is stored in the ROM. When power is switched on, the processor reads the
ROM; the program is program is executed.
Input devices:
Unlike the desktops, the input devices to an embedded system have very limited
capability. There will be no keyboard or a mouse, and hence interacting with the
embedded system is no easy task. Many embedded systems will have a small keypad-you
press one key to give a specific command. A keypad may be used to input only the digits.
Many embedded systems used in process control do not have any input device for user
interaction; they take inputs from sensors or transducers 1’fnd produce electrical signals
that are in turn fed to other systems.
Output devices:
The output devices of the embedded systems also have very limited capability.
Some embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the
health status of the system modules, or for visual indication of alarms. A small Liquid
Crystal Display (LCD) may also be used to display some important parameters.
Communication interfaces:
The embedded systems may need to, interact with other embedded systems at
they may have to transmit data to a desktop. To facilitate this, the embedded systems are
provided with one or a few communication interfaces such as RS232, RS422, RS485,
Universal Serial Bus (USB), and IEEE 1394, Ethernet etc.
10
CHAPTER 2
11
2.2 DESCRIPTION:
The specification of TTL is for logic’1’=5V and for logic’0’=0V where as RS232
standard is used in desktop, the specification of reserved standard 232 logic is for
logic’1’= -3 to -25.v and for logic’0’ = -3 to 25.v. so to convert TTL logic RS232 logic or
from RS232 logic to TTL logic., we have to use MAX232 which consists of inverting
amplifiers. The clock frequency given to the micro controller is through crystal oscillator
which is having quartz oscillator to provide very constant frequency, the clock frequency
given ADC is from IC555 TIMER which is Astable multi-vibrator.
To drive the loads we are using ULN driver, which amplifies the current to
500mA and the supply given to this ULN driver is +12V and the IC we are using is
ULN2003A , which consists of Darlington pair arrays. And this ULN driver has 7 i/p pins
of that we are using only 1 pin to drive only one relay.
12
The power supply provided to all sections is given through circuit which includes
step down transformer, rectifier, filter and regulator. The available input power supply is
230V AC, but the required voltage is 5V and 12V Dc. So we use all the above
components to provide the required voltages.
13
CHAPTER 3
AT89S52 MICROCONTROLLER
HISTORY
The Intel 8052 is Harvard architecture, single chip microcontroller (µC) which
was developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s
and early 1990s, but today it has largely been superseded by a vast range of enhanced
devices with 8052-compatible processor cores that are manufactured by more than 20
independent manufacturers including Atmel, Infineon Technologies and Maxim
Integrated Products.
14
8052 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 by the
CPU. 8052 is available in different memory types such as UV-EPROM, Flash and NV-
RAM.
The present project is implemented on Keilμvision IDE. And PROLOAD tool has
been used to burn the program onto the microcontroller.
The features, pin description of the microcontroller and the software tools used
are discussed in the following sections.
3.1 Description:
In addition, the AT89S52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes.
INTERNAL MEMORY:- In general cpu requires ROM for storing program (code) and
RAM for data while performing a task.8052 has provide two types of internal memories
i.e. RAM,ROM.
15
Fig 3.1 Architecture of AT89S52
16
SPECIAL FUNCTION REGISTERS:
The 8052 has several special function registers (SFR’s) known as A ,B ,DPTR
,PSW ,IP ,IE ,TCON ,SCON PCON ,P0 ,P1 ,P2 ,P3, SBUF ,SP, T0 ,T1,TMOD.all these
are byte-addressable and some of them are bit-addressable also. The SFR’s can be
accessed by their names or by their addresses.These are useful in accessing I/O ports ,
timers/counters ,UART ,power controlling etc…
TIMERS/COUNTERS:
SERIALPORT:
This unit provides serial data transfer and receiving .this feature is required in
certain communications with other computers and while accessing with some peripherals
like printer, gsm, gps modules etc.
A SFR known as SBUF is used to hold the data before and after serial data
transfer and receive .two other SFR’s SCON and PCON are used to determine the baud
rate transmission, reception.
INTERRUPT CONTROL:
This unit alters the micro-controller’s attention from one TASK to some other.
This may happen when ever an interrupt input become active .Interrupts may generate in
the inside of the 8052 or provided from the external sources .the 8052 has 5 interrupts
such as TF0, TF1, INT0, INT1 and RI/TI.
17
These interrupts either all or selectively enabled or disabled through a SFR
“IE”(interrupt enable register) further the priority among these can determined by
another SFR “IP” (interrupt priority register).
In 8052 there are 4 input/output ports with 8 lines of each some of these ports can
be configured as an input or as an output port. In addition port 3 performs some specified
functions .Hence totally we are having 32 I/O lines.
For example, if you want to add the number 10 and 20, the resulting 30 will be stored in
the Accumulator. Once you have a value in the Accumulator you may continue
processing the value or you may store it in another register or in memory.
The "B" register is very similar to the Accumulator in the sense that it may hold
an 8-bit (1-byte) value. The "B" register is only used by two 8052 instructions: MULAB
18
and DIVAB. Thus, if you want to quickly and easily multiply or divide A by another
number, you may store the other number in "B" and make use of these two instructions. It
is given an address in the SFR address range (0F0 h). It can hold an 8-bit (1-byte) value
and is the most versatile register the 8052 has due to the sheer number of instructions that
make use of the accumulator.
T0, T1, T3 are used as timers/counters these are 16-bit registers Since the 8052 is a 8-bit
controller, these registers also byte addressable i.e. low byte and high byte(TL0,TL1 &
TH0,TH1). Two SFR’s TMOD &TCON are used to monitor the nature of working of the
registers T0, T1. The SFR’s can be accessed by their names or by their addresses. these are useful
in accessing I/O ports , timers/counters ,UART ,power controlling etc.Interrupts may generate
in the inside of the 8052 or provided from the external sources .the 8052 has 5 interrupts
,such as TF0, TF1 ,INT0, INT1 and RI/TI.
I/O(input/output) PORTS:
In 8052 there are 4 input/output ports with 8 lines of each some of these ports can
be configured as an input or as an output port.
19
The "R" registers are a set of eight registers that are named R0, R1, etc. up to and
including R7. The 128 bytes of internal ram is subdivided as shown on the memory map.
The first 8 bytes (00h - 07h) are "register bank 0". By manipulating certain SFRs, a
program may choose to use register banks 1, 2, or 3. These alternative register banks are
located in internal RAM in addresses 08h through 1Fh.
After executing this instruction the Accumulator will contain the value 30.You
may think of the "R" registers as very important auxiliary, or "helper", registers. The
Accumulator alone would not be very useful if it were not for this "R" registers. The "R"
registers are also used to temporarily store values.
The Stack Pointer is an 8-bit (1-byte) register. When you PUSH a value onto the
stack, the 8052 first increments the value of SP and then stores the value at the resulting
memory location. When you POP a value off the stack, the 8052 returns the value from
the memory location indicated by SP and then decrements the value of SP.
When the 8052 is initialized SP will be initialized to 07h. If you immediately push
a value onto the stack, the value will be stored in Internal RAM address 08h. This makes
sense taking into account what was mentioned two paragraphs above: SP is modified
directly by the 8052 by six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI.
.
20
The Data Pointer (DPTR):
The Data Pointer (DPTR) is the 8052s only user-accessible 16-bit (2-byte)
register. DPTR, as the name suggests, is used to point to data. It is used by a number of
commands which allow the 8052 to access external memory. When the 8052 accesses
external memory it will access external memory at the address indicated by DPTR.
It consists of two 8-bit registers, the higher byte DPH and the lower byte DPL
.These have addresses 82 h (DPH) and 83 h(DPL) in SFR address range .
The Program Counter (PC) is a 2-byte address which tells the 8052 where the next
instruction to execute is found in memory. When the 8052 is initialized PC always starts
at 0000h and is incremented each time an instruction is executed.
The Program Counter is special in that there is no way to directly modify its
value. That is to say, you can’t do something like PC=2430h.
This is an 8-bit register .it contains information about the status of the program .it
has several bits that reflect the current status of the CPU .it is given the address (0D0 h)
in the SFR address range .it has one Carry(CY) flag, one Auxiliary Carry flag (AC) , one
general purpose status flag for user (FO) ,two register bank select bits (RS1,RS0) ,one
over flow flag (OV) ,one parity flag (P) ,and one user definable flag (X).T
Carry flag: This flip flop is forced to ‘SET’ state whenever there is a carry or
borrow generated at D7 bit.
21
Auxiliary carry flag: This flip flop is forced to ‘SET’ state whenever carry is
generated fromD3 toD4 position.
Over flow flag: This flip flop is forced to ‘SET’ state whenever the result of
signed numbers addition over flows in to the D7 bit
3.4ADDRESINGMODES:
An "addressing mode" refers to how you are addressing a given memory location.
In summary, the addressing modes are as follows, with an example of each:
Immediate Addressing:
22
For example, the instruction:
MOV AX,[3000]
Immediate addressing is very fast since the value to be loaded is included in the
instruction. However, since the value to be loaded is fixed at compile-time it is not very
flexible.
Direct Addressing:
For example: This instruction will read the data out of Internal RAM address 30
(hexadecimal) and store it in the Accumulator.
Direct addressing is generally fast since, although the value to be loaded isn’t
included in the instruction, it is quickly accessible since it is stored in the 8052s Internal
RAM. It is also much more flexible than Immediate Addressing since the value to be
loaded is whatever is found at the given address--which may be variable.
Also, it is important to note that when using direct addressing any instruction
which refers to an address between 00h and 7Fh is referring to Internal Memory. Any
instruction which refers to an address between 80h and FFh is referring to the SFR
control registers that control the 8052 microcontroller itself.
Indirect Addressing:
23
Indirect addressing appears as follows:
MOV AX, SI
This instruction causes the 8052 to analyze the value of the R0 register. The 8052
will then load the accumulator with the value from Internal RAM which is found at the
address indicated by R0.
For example, let’s say R0 holds the value 40h and Internal RAM address 40h
holds the value 67h. When the above instruction is executed the 8052 will check the
value of R0. Since R0 holds 40h the 8052 will get the value out of Internal RAM address
40h (which holds 67h) and store it in the Accumulator. Thus, the Accumulator ends up
holding 67h.
External Direct:
External Memory is accessed using a suite of instructions which use what I call
"External Direct" addressing. I call it this because it appears to be direct addressing, but it
is used to access external memory rather than internal memory.
There are only two commands that use External Direct addressing mode:
As you can see, both commands utilize DPTR. In these instructions, DPTR must
first be loaded with the address of external memory that you wish to read or write. Once
DPTR holds the correct external memory address, the first command will move the
contents of that external memory address into the Accumulator. The second command
will do the opposite: it will allow you to write the value of the Accumulator to the
external memory address pointed to by DPTR.
External Indirect:
External memory can also be accessed using a form of indirect addressing which I
call External Indirect addressing. This form of addressing is usually only used in
relatively small projects that have a very small amount of external RAM.
24
Once again, the value of R0 is first read and the value of the Accumulator is
written to that address in External RAM. Since the value of @R0 can only be 00h
through FFh the project would effectively be limited to 256 bytes of External RAM.
Interrupts may generate in the inside of the 8052 or provided from the external sources
.the 8052 has 5 interrupts, such as TF0, TF1, INT0, INT1 and RI/TI.
3.5 TIMERS:
The 8052 timers have three general functions: 1) Keeping time and/or calculating
the amount of time between events, 2) Counting the events themselves, or 3) Generating
baud rates for the serial port.
11,059,000 / 12 = 921,583
921,583 times per second. Unlike instructions--some of which require 1 machine cycle,
others 2, and others 4--the timers are consistent: They will always be incremented once
per machine cycle. Thus if a timer has counted from 0 to 50,000 you may calculate:
Once DPTR holds the correct external memory address, the first command will
move the contents of that external memory address into the Accumulator. The second
command will do the opposite: it will allow you to write the value of the Accumulator to
the external memory address pointed to by DPTR.Developing embedded systems for
security applications is one of the most lucrative businesses nowadays. Security devices
at homes, offices, airports etc. for authentication and verification are embedded systems.
Encryption devices are nearly 99 per cent of the processors that are manufactured end up
in~ embedded systems.
25
Bit Name Explanation of Function Timer
When this bit is set the timer will only run when INT1 (P3.3) is
7 GATE1 high. When this bit is clear the timer will run regardless of the 1
state of INT1.
When this bit is set the timer will count events on T1 (P3.5).
6 C/T1 When this bit is clear the timer will be incremented every 1
machine cycle.
When this bit is set the timer will only run when INT0 (P3.2) is
3 GATE0 high. When this bit is clear the timer will run regardless of the 0
state of INT0.
When this bit is set the timer will count events on T0 (P3.4).
2 C/T0 When this bit is clear the timer will be incremented every 0
machine cycle.
Table: 3.4 TMOD - Timer/counter mode control register (address 89H) bit allocation
As you can see in the above chart, four bits (two for each timer) are used to specify a
mode of operation. The modes of operation are:
26
TxM1 TxM0 Timer Mode Description of Mode
0 0 0 13-bit Timer.
0 1 1 16-bit Timer
1 0 2 8-bit auto-reload
Table: 3.6 TCON - Timer/counter control register (address 88H) bit allocation
27
Fig: 3.3 MODE 2 of timer 1
Timer mode "2" is an 8-bit auto-reload mode. When a timer is in mode 2, THz holds the
"reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLx
reaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case of
modes 0 and 1), it will be reset to the value stored in THx.
One of the 8052s many powerful features is its integrated UART, otherwise
known as a serial port. The fact that the 8051 has an integrated serial port means that you
may very easily read and write values to the serial port. If it were not for the integrated
serial port, writing a byte to a serial line would be a rather tedious process requiring
turning on and off one of the I/O lines in rapid succession to properly "clock out" each
individual bit, including start bits, stop bits, and parity bits. For setting the modes we are
using SCON register. Developing embedded systems for security applications is one of
the most lucrative businesses nowadays. Security devices at homes, offices, airports etc.
for authentication and verification are embedded systems. Encryption devices are nearly
99 per cent of the processors that are manufactured end up in~ embedded systems.
Embedded systems find applications in. Every industrial segment- consumer electronics,
transportation, avionics, biomedical engineering, manufacturing, process control and
industrial automation, data communication, telecommunication, defense, security etc.
Used to encrypt the data/voice being transmitted on communication links such as
28
telephone lines. If it were not for the integrated serial port, writing a byte to a serial line
would be a rather tedious process requiring turning on and off one of the I/O lines in
rapid succession to properly "clock out" each individual bit, including start bits, stop bits,
and parity bits.
Bit
Bit Name Explanation of Function
Address
3 TB8 9Bh Transmit bit 8. The 9th bit to transmit in mode 2 and 3.
2 RB8 9Ah Receive bit 8. The 9th bit received in mode 2 and 3.
1 TI 99h Transmit Flag. Set when a byte has been completely transmitted.
0 RI 98h Receive Flag. Set when a byte has been completely received.
Table: 3.7 SCON - Serial port control register (address 98H) bit allocation
SM0 & SM1: Bits SM0 and SM1 let us set the serial mode to a value between 0
and 3, inclusive. The four modes are defined in the chart immediately above. As you can
see, selecting the Serial Mode selects the mode of operation (8-bit/9-bit, UART or Shift
Register) and also determines how the baud rate will be calculated. In modes 0 and 2 the
29
baud rate is fixed based on the oscillator’s frequency. In modes 1 and 3 the baud rate is
variable based on how often Timer 1 overflows. We’ll talk more about the various Serial
Modes in a moment. If it were not for the integrated serial port, writing a byte to a serial
line would be a rather tedious process requiring turning on and off one of the I/O lines in
rapid succession to properly "clock out" each individual bit, including start bits, stop bits,
and parity bits.
REN:
REN is "Receiver Enable." This bit is very straightforward: If you want to receive data
via the serial port, set this bit. You will almost always want to set this bit.
TB8:
The TB8 bit is used in modes 2 and 3. In modes 2 and 3, a total of nine data bits
are transmitted. The first 8 data bits are the 8 bits of the main value, and the ninth bit is
taken from TB8. If TB8 is set and a value is written to the serial port, the data bits will be
written to the serial line followed by a "set" ninth bit. If TB8 is clear the ninth bit will be
"clear."
30
RB8:-The RB8 also operates in modes 2 and 3 and functions essentially the same way as
TB8, but on the reception side. When a byte is received in modes 2 or 3, a total of nine
bits are received. In this case, the first eight bits received are the data of the serial byte
received and the value of the ninth bit received will be placed in RB8.
TI:- TI means "Transmit Interrupt." When a program writes a value to the serial port, a
certain amount of time will pass before the individual bits of the byte are "clocked out"
the serial port. If the program were to write another byte to the serial port before the first
byte was completely output, the data being sent would be garbled. Thus, the 8052 lets the
program know that it has "clocked out" the last byte by setting the TI bit. When the TI bit
is set, the program may assume that the serial port is "free" and ready to send the next
byte.
RI:-Finally, the RI bit means "Receive Interrupt." It functions similarly to the "TI" bit, but
it indicates that a byte has been received. That is to say, whenever the 8052 has received
a complete byte it will trigger the RI bit to let the program know that it needs to read the
value quickly, before another byte is read
31
PIN DESCRIPTION:
GND– Ground
Port 0:
Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin
can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high-impedance inputs. Port 0 can also be configured to be the multiplexed 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.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively.
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 (I IL) because of the internal pull-ups.
32
Port 2 emits the high-order address byte during fetches from external program memory
and during accesses to external data memory that uses 16-bit addresses (MOVX @
DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During
accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits
the contents of the P2 Special Function Register. Port 2 also receives the high-order
address bits and some control signals during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current (I IL) because of the pull-ups. Port 3
also serves the functions of various special features of the AT89C51. Port 3 also receives
some control signals for Flash programming and verification.
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
ALE/PROG:
Address Latch Enable is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during flash programming. In normal operation, ALE is emitted at a constant rate of 1/6
the oscillator frequency and may be used for external timing or clocking purposes.
However, that one ALE pulse is skipped during each access to external data memory. If
desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit
set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
33
Block Diagram of AT89S52
EXTERNAL
INTERRUPT
S TIMER/
INTERRUP ON-CHIP ON- COUNT
T ROM FOR CHIP ER
TIMER 1 COUNT
CONTROL PROGRAM RAM ER
CODE TIMER 0 INPUTS
CPU
P0 P1 P2 P3 Tx Rx
FEATURES:
34
CHAPTER 4
HARDWARE COMPONENTS
4.1 SENSORS
Temperature sensor:
35
General Description
Features:
36
Current/voltage sensors:
Here we use variable resistors as voltage and current sensors. current sensor is a
device that detects electrical current (AC or DC) in a wire, and generates a signal
proportional to it whereas Voltage sensor is a device that detects voltage across two
terminals and generates a signal proportional to it. The generated signal could be analog
voltage or current. It can be then utilized to display the measured current/voltage in an
ammeter / voltmeter or can be stored for further analysis in a data acquisition system or
can be utilized for control purpose.
AC current/voltage input,
o analog output, which duplicates the wave shape of the sensed
current/voltage
o bipolar output, which duplicates the wave shape of the sensed
current/voltage
o unipolar output, which is proportional to the average or RMS value of the
sensed current/voltage
DC current/voltage input,
o unipolar, with a unipolar output, which duplicates the wave shape of the
sensed current/voltage
o digital output, which switches when the sensed current/voltage exceeds a
certain threshold
37
4.2 ADC0809:
The digital output may use different coding schemes. Typically the digital output
will be a two's complement binary number that is proportional to the input, but there are
other possibilities. An encoder, for example, might output a Gray code.
The resolution of the converter indicates the number of discrete values it can
produce over the range of analog values. The values are usually stored electronically in
binary form, so the resolution is usually expressed in bits. In consequence, the number of
discrete values available, or "levels", is a power of two. For example, an ADC with a
resolution of 8 bits can encode an analog input to one in 256 different levels, since
38
28 = 256. The values can represent the ranges from 0 to 255 (i.e. unsigned integer) or
from −128 to 127 (i.e. signed integer), depending on the application.
Resolution can also be defined electrically, and expressed in volts. The minimum
change in voltage required to guarantee a change in the output code level is called the
least significant bit (LSB) voltage. The resolution Q of the ADC is equal to the LSB
voltage. The voltage resolution of an ADC is equal to its overall voltage measurement
range divided by the number of discrete voltage intervals:
Where N the number of voltage intervals and EFSR is the full scale voltage range. EFSR is
given by
Where Vref High and Vref Low are the upper and lower extremes, respectively, of the
voltages that can be coded.
Where M is the ADC's resolution in bits. That is, one voltage interval is
assigned per code level.
Example:
39
In practice, the useful resolution of a converter is limited by the best signal-to-noise
ratio (SNR) that can be achieved for a digitized signal. An ADC can resolve a signal to
only a certain number of bits of resolution, called the effective number of bits (ENOB).
One effective bit of resolution changes the signal-to-noise ratio of the digitized signal by
6 dB, if the resolution is limited by the ADC. If a preamplifier has been used prior to A/D
conversion, the noise introduced by the amplifier can be an important contributing factor
towards the overall SNR.
Response type:
Most ADCs are of a type known as linear. The term linear implies here the range
of the input values that map to each output value has a linear relationship with the output
value.
Accuracy:
An ADC has several sources of errors. Quantization error and (assuming the ADC
is intended to be linear) non-linearity are intrinsic to any analog-to-digital conversion.
There is also a so-called aperture error which is due to a clock jitter and is revealed when
digitizing a time-variant signal (not a constant value).
These errors are measured in a unit called the LSB, which is an abbreviation for
least significant bit. In the above example of an eight-bit ADC, an error of one LSB is
1/256 of the full signal range, or about 0.4%.
Quantization error:
Quantization error (or quantization noise) is the difference between the original
signal and the digitized signal. Hence, The magnitude of the quantization error at the
sampling instant is between zero and half of one LSB. Quantization error is due to the
40
finite resolution of the digital representation of the signal, and is an unavoidable
imperfection in all types of ADCs.
Non-linearity:
All ADCs suffer from non-linearity errors caused by their physical imperfections, causing
their output to deviate from a linear function (or some other function, in the case of a
deliberately non-linear ADC) of their input. These errors can sometimes be mitigated by
calibration, or prevented by testing. Important parameters for linearity are integral non-
linearity (INL) and differential non-linearity (DNL). These non-linear ties reduce the
dynamic range of the signals that can be digitized by the ADC, also reducing the effective
resolution of the ADC.
Aperture error:
Imagine that we are digitizing a sine wave x(t) = Asin(2πf0t). Provided that the actual
sampling time uncertainty due to the clock jitter is Δt, the error caused by this
The error is zero for DC, small at low frequencies, but significant when high frequencies
have high amplitudes. This effect can be ignored if it is drowned out by the quantizing
41
ADC Input frequency
resolution
in bit 1 Hz 44.1 kHz 192 kHz 1 MHz 10 MHz 100 MHz 1 GHz
This table shows, for example, that it is not worth using a precise 24-bit ADC for
sound recording if there is not an ultra low jitter clock. One should consider taking this
phenomenon into account before choosing an ADC.
Clock jitter is caused by phase noise. The resolution of ADCs with a digitization
bandwidth between 1 MHz and 1 GHz is limited by jitter.
When sampling audio signals at 44.1 kHz, the anti-aliasing filter should have
eliminated all frequencies above 22 kHz. The input frequency (in this case, 22 kHz), not
the ADC clock frequency, is the determining factor with respect to jitter performance.
42
Sampling rate:
A continuously varying band limited signal can be sampled (that is, the signal
values at intervals of time T, the sampling time, are measured and stored) and then the
original signal can be exactly reproduced from the discrete-time values by an
interpolation formula. The accuracy is limited by quantization error. However, this
faithful reproduction is only possible if the sampling rate is higher than twice the highest
frequency of the signal. This is essentially what is embodied in the Shannon-Nyquist
sampling theorem.
Since a practical ADC cannot make an instantaneous conversion, the input value
must necessarily be held constant during the time that the converter performs a
conversion (called the conversion time). An input circuit called a sample and hold
performs this task—in most cases by using a capacitor to store the analog voltage at the
input, and using an electronic switch or gate to disconnect the capacitor from the input.
Many ADC integrated circuits include the sample and hold subsystem internally.
Aliasing:
All ADCs work by sampling their input at discrete intervals of time. Their output
is therefore an incomplete picture of the behavior of the input. There is no way of
knowing, by looking at the output, what the input was doing between one sampling
instant and the next. If the input is known to be changing slowly compared to the
sampling rate, then it can be assumed that the value of the signal between two sample
instants was somewhere between the two sampled values. If, however, the input signal is
changing rapidly compared to the sample rate, then this assumption is not valid.
43
If the digital values produced by the ADC are, at some later stage in the system,
converted back to analog values by a digital to analog converter or DAC, it is desirable
that the output of the DAC be a faithful representation of the original signal. If the input
signal is changing much faster than the sample rate, then this will not be the case, and
spurious signals called aliases will be produced at the output of the DAC. The frequency
of the aliased signal is the difference between the signal frequency and the sampling rate.
For example, a 2 kHz sine wave being sampled at 1.5 kHz would be reconstructed as a
500 Hz sine wave. This problem is called aliasing.
Dither:
In A-to-D converters, performance can usually be improved using dither. This is a very
small amount of random noise (white noise) which is added to the input before
conversion. Its effect is to cause the state of the LSB to randomly oscillate between 0 and
1 in the presence of very low levels of input, rather than sticking at a fixed value. Rather
than the signal simply getting cut off altogether at this low level (which is only being
quantized to a resolution of 1 bit), it extends the effective range of signals that the A-to-D
converter can convert, at the expense of a slight increase in noise - effectively the
quantization error is diffused across a series of noise values which is far less
objectionable than a hard cutoff. The result is an accurate representation of the signal
over time. A suitable filter at the output of the system can thus recover this small signal
variation.
Oversampling:
Usually, signals are sampled at the minimum rate required, for economy, with the
result that the quantization noise introduced is white noise spread over the whole pass
band of the converter. If a signal is sampled at a rate much higher than the Nyquist
frequency and then digitally filtered to limit it to the signal bandwidth there are the
following advantages:
44
digital filters can have better properties (sharper roll off, phase) than analogue
filters, so a sharper anti-aliasing filter can be realized and then the signal can be
down sampled giving a better result
a 20-bit ADC can be made to act as a 24-bit ADC with 256× oversampling
The signal due to quantization noise will be higher than if the whole available
band had been used. With this technique, it is possible to obtain an effective
resolution larger than that provided by the converter alone
The improvement in SNR is 3 dB (equivalent to 0.5 bits) per octave of
oversampling which is not sufficient for many applications. Therefore,
oversampling is usually coupled with noise shaping (see sigma-delta modulators).
With noise shaping, the improvement is
The speed of an ADC varies by type. The Wilkinson ADC is limited by the clock
rate which is processable by current digital circuits. Currently, frequencies up to
300 MHz are possible. The conversion time is directly proportional to the number of
channels. For a successive approximation ADC, the conversion time scales with the
logarithm of the number of channels. Thus for a large number of channels, it is possible
that the successive approximation ADC is faster than the Wilkinson. However, the time
consuming steps in the Wilkinson are digital, while those in the successive approximation
are analog. Since analog is inherently slower than digital, as the number of channels
increases, the time required also increases. Thus there are competing processes at work.
Flash ADCs are certainly the fastest type of the three. The conversion is basically
performed in a single parallel step. For an 8-bit unit, conversion takes place in a few tens
of nanoseconds.
There is, as expected, somewhat of a trade off between speed and precision. Flash
ADCs have drifts and uncertainties associated with the comparator levels, which lead to
poor uniformity in channel width. Flash ADCs have a resulting poor linearity. For
successive approximation ADCs, poor linearity is also apparent, but less so than for flash
ADCs. Here, non-linearity arises from accumulating errors from the subtraction
45
processes. Wilkinson ADCs are the best of the three. These have the best differential non-
linearity. The other types require channel smoothing in order to achieve the level of the
Wilkinson.
The sliding scale or randomizing method can be employed to greatly improve the
channel width uniformity and differential linearity of any type of ADC, but especially
flash and successive approximation ADCs. Under normal conditions, a pulse of particular
amplitude is always converted to a certain channel number. The problem lies in that
channels are not always of uniform width, and the differential linearity decreases
proportionally with the divergence from the average width. The sliding scale principle
uses an averaging effect to overcome this phenomenon. A random, but known analog
voltage is added to the input pulse. It is then converted to digital form, and the equivalent
digital version is subtracted, thus restoring it to its original value. The advantage is that
the conversion has taken place at a random point. The statistical distribution of the final
channel numbers is decided by a weighted average over a region of the range of the
ADC. This in turn desensitizes it to the width of any given channel.
ADC structures:
A direct conversion ADC or flash ADC has a bank of comparators sampling the
input signal in parallel, each firing for their decoded voltage range. The
comparator bank feeds a logic circuit that generates a code for each voltage range.
Direct conversion is very fast, capable of gigahertz sampling rates, but usually has
46
only 8 bits of resolution or fewer, since the number of comparators needed, 2N - 1,
doubles with each additional bit, requiring a large expensive circuit.
A Time-interleaved ADC uses M parallel ADCs where each ADC sample data
every M:th cycle of the effective sample clock. The result is that the sample rate is
increased M times compared to what each individual ADC can manage. In
practice, the individual differences between the M ADCs degrade the overall
performance reducing the SFDR. However, technologies exist to correct for these
time-interleaving mismatch errors.
There can be other ADCs that use combination electronics and other technologies:
47
feedback from the comparator to adjust the counter until the DAC's output is close
enough to the input signal.
The various functional blocks of ADC are 8-channel multiplexer, comparator, 256R
resistor ladder, switch tree, successive approximation register, output buffer, address
latch and decoder.
48
Fig 4.4 Block diagram and working of ADC0809
49
4.3 MAX232
50
DB9 Connector:
The term "DB9" refers to a common connector type, one of the D-Subminiature
or D-Sub types of connectors. DB9 has the smallest "footprint" of the D-Subminiature
connectors, and houses 9 pins (for the male connector) or 9 holes (for the female
connector).
DB9 connectors were once very common on PCs and servers. DB9 connectors
are designed to work with the EIA/TIA 232 serial interface standard, which determined
the function of all nine pins as a standard, so that multiple companies could design them
into their products. DB9 connectors were commonly used for serial peripheral devices
like keyboards, mice, joysticks, etc
Today, the DB9 has mostly been replaced by more modern interfaces such as
USB, PS/2, Fire wire, and others. However, there are still many legacy devices that use
the DB9 interface for serial communication. A DB9 connector has 9 pins arranged in two
rows, with one row on top of the other. The top row has 5 pins and the lower row has 4
pins. This interface is commonly used for RS-232 serial applications. For several years,
DB9 ports were standard equipment on PCs; nowadays, many newer computers are being
built without them. On a PC, the serial port is commonly a DB9 male. Gender: Male |
Female.
51
The circuit uses negative feedback from the comparator to adjust the counter until
the DAC's output is close enough to the input signal. The number is read from the
counter. Delta converters have very wide ranges, and high resolution, but the conversion
time is dependent on the input signal level, though it will always have a guaranteed
worst-case. Delta converters are often very good choices to read real-world signals. Most
signals from physical systems do not change abruptly. Some converters combine the delta
and successive approximation approaches; this works especially well when high
frequencies are known to be small in magnitude. Developing embedded systems for
security applications is one of the most lucrative businesses nowadays. Security devices
at homes, offices, airports etc. for authentication and verification are embedded systems.
Encryption devices are nearly 99 per cent of the processors that are manufactured end up
in~ embedded systems.
The DB9 connector is mainly used for serial connections, allowing for the asynchronous
transmission of data as provided for by standard RS-232 (RS-232C). Some converters
combine the delta and successive approximation approaches; this works especially well
when high frequencies are known to be small in magnitude. Developing embedded
systems for security applications is one of the most lucrative businesses nowadays.
Security devices at homes, offices, airports etc. for authentication and verification are
embedded systems.
52
Pins
1 CD - Carrier Detect
9 RI - Ring Indicator
RS232:
53
handshaking is present. Only very few computers have been manufactured where both
serial RS232 channels are implemented. Examples of this are the Sun SPARCstation 10
and 20 models and the Dec Alpha Militia. On personal computers, the smaller DB9
version is more commonly used today. The diagrams show the signals common to both
connector types in black. The defined pins only present on the larger connector are shown
in red. Note, that the protective ground is assigned to a pin at the large connector where
the connector outside is used for that purpose with the DB9 connector version.
The pinout is also shown for the DEC modified modular jack. This type of
connector has been used on systems built by Digital Equipment Corporation; in the early
days one of the leaders in the mainframe world. Although this serial interface is
differential (the receive and transmit have their own floating ground level which is not
the case with regular RS232) it is possible to connect RS232 compatible devices with this
interface because the voltage levels of the bit streams are in the same range.
54
Connector 1 Connector 2 Function
2 3 Rx Tx
3 2 Tx Rx
5 5 Signal ground
TTL is a class of digital circuits built from bipolar junction transistors (BJT) and
resistors. It is called transistor–transistor logic because both the logic gating function
(e.g., AND) and the amplifying function are performed by transistors (contrast this with
RTL and DTL).
TTL is notable for being a widespread integrated circuit (IC) family used in many
applications such as computers, industrial controls, test equipment and instrumentation,
consumer electronics, synthesizers, etc. The designation TTL is sometimes used to mean
TTL-compatible logic levels, even when not associated directly with TTL integrated
circuits, for example as a label on the inputs and outputs of electronic instruments.
55
Input logical ones:
When all the inputs are held at high voltage, the base–emitter junctions of the
multiple-emitter transistor are backward-biased. In contrast with DTL, small (about 10
μA) "collector" currents are drawn by the inputs since the transistor is in a reverse-active
mode (with swapped collector and emitter). The base resistor in combination with the
supply voltage acts as a substantially constant current source. It passes current through
the base–collector junction of the multiple-emitter transistor and the base–emitter
junction of the output transistor thus turning it on; the output voltage becomes low
(logical zero).
If one input voltage becomes zero, the corresponding base–emitter junction of the
multiple-emitter transistor connects in parallel to the two connected in series junctions
(the base–collector junction of the multiple-emitter transistor and the base–emitter
junction of the second transistor). The input base–emitter junction steersall the base
current of the output transistor to the input source (the ground). The base of the output
transistor is deprived of current causing it to go into cut-off and the output voltage
becomes high (logical one). During the transition the input transistor is briefly in its
active region; so it draws a large current away from the base of the output transistor and
thus quickly discharges its base. This is a critical advantage of TTL over DTL that speeds
up the transition over a diode input structure.
The main disadvantage of TTL with a simple output stage is the relatively high
output resistance at output logical "1" that is completely determined by the output
collector resistor. It limits the number of inputs that can be connected (the fan-out). Some
advantage of the simple output stage is the high voltage level (up to VCC) of the output
logical "1" when the output is not loaded.
Logic of this type is most frequently encountered with the collector resistor of the
output transistor omitted, making an open collector output. This allows the designer to
fabricate logic by connecting the open collector outputs of several logic gates together
56
and providing a single external pull-up resistor. If any of the logic gates becomes logic
low (transistor conducting), the combined output will be low. Examples of this type of
gate are the 7401and 7403 series. Developing embedded systems for security applications
is one of the most lucrative businesses nowadays. Security devices at homes, offices,
airports etc. for authentication and verification are embedded systems. Encryption
devices are nearly 99 per cent of the processors that are manufactured end up in~
embedded systems. Embedded systems find applications in every industrial segment-
consumer electronics, transportation, avionics, biomedical engineering, manufacturing,
process control and industrial automation, data communication, telecommunication,
defense, security etc. Used to encrypt the data/voice being transmitted on communication
links such as telephone lines.
Seven darling tons per package output current 500ma per driver (600ma peak)
Output voltage50v
The ULN2001A, ULN2002A, ULN2003 and ULN2004Aare high voltage, high current
darling ton arrays each containing seven open collector darling ton pairs with common
emitters. Each channel is rated at 500mA and can withstand peak currents of
600mA.Suppression diodes are included for inductive load driving and the inputs are
pinned opposite the output simplify board layout. The four common logic families.
Developing embedded systems for security applications is one of the most lucrative
businesses nowadays. Security devices at homes, offices, airports etc.
4.5 RELAY
A type of relay that can handle the high power required to directly control an
electric motor is called a contractor. Solid-state relays control power circuits with no
moving parts, instead using a semiconductor device to perform switching. Relays with
calibrated operating characteristics and sometimes multiple operating coils are used to
58
protect electrical circuits from overload or faults; in modern electric power systems these
functions are performed by digital instruments.
Relays are used where it is necessary to control a circuit by a low-power signal (with
complete electrical isolation between control and controlled circuits), or where several
circuits must be controlled by one signal.
LEDs are semiconductor devices. Like transistors, and other diodes, LEDs are
made out of silicon. What makes an LED give off light are the small amounts of chemical
impurities that are added to the silicon, such as gallium, arsenide, indium,
andnitride.When current passes through the LED, it emits photons as a byproduct.
Normal light bulbs produce light by heating a metal filament until it's white hot. Because
LEDs produce photons directly and not via heat, they are far more efficient than in can
descent bulbs. Not long ago LEDs were only bright enough to be used as indicators on
dashboards or electronic equipment. But recent advances have made LEDs bright enough
to rival traditional lighting technologies. Modern LEDs can replace incandescent bulbs in
almost any application.
59
LED Circuits:
To build LED circuits, it helps to be familiar with Ohm's law, and the concepts of
voltage, resistance, and current. LEDs do not have resistance like a resistor does. LEDs
have a dynamic resistance that is their resistance changes depending on how much
current passes through them. But it's easiest to think of them as having NO resistance.
This means that if you just connect an LED to a battery, you'll have a short circuit. That's
bad. You would probably ruin Your LED. So an LED circuit needs some resistance in it,
so that it isn't a short circuit. Actually we need a very specific amount of resistance.
Among the specifications for LEDs, a "maximum forward current" rating is usually
given. This is the most current that can pass through the LED without damaging it, and
also the current which the LED will produce the most light. A specific value of resistor is
needed to obtain this exact current. There is one more complication. LEDs consume a
certain voltage. This is known as the "forward voltage drop", and is usually given with
the specs for that LED. This must be taken into account when calculating the correct
value of resistor to use. So to drive an LED using a voltage source and a resistor in series
with the LED, use the following equation to determine the needed resistance.
60
4.12 Block Diagram of LED
Don't forget to pay attention to the difference between amps and milliamps. Ohms
law calculations require units in amps, although the specification is usually given in
milliamps. Just divide milliamps by 1000 to get amps.Also remember that it's acceptable
to round the resistance UP to the next closest standard resistor value. Rounding up is
never dangerous, as it will result in slightly less current. You will never find a 327 ohm
resistor, but 330 ohm resistors are quite common, so just use a 330 ohm resistor.
61
Quartz crystals are manufactured for frequencies from a few tens of kilohertz to
tens of megahertz. More than two billion (2×109) crystals are manufactured annually.
Most are used for consumer devices such as wristwatches, clocks, radios, computers, and
cell phones. Quartz crystals are also found inside test and measurement equipment, such
as counters, signal generators, and oscilloscopes.
Crystal oscillator:
A crystal is a solid in which the constituent atoms, molecules, or ions are packed
in a regularly ordered, repeating pattern extending in all three spatial dimensions.
Almost any object made of an elastic material could be used like a crystal, with
appropriate transducers, since all objects have natural resonant frequencies of vibration.
For example, steel is very elastic and has a high speed of sound. It was often used in
mechanical filters before quartz. The resonant frequency depends on size, shape,
elasticity, and the speed of sound in the material. High-frequency crystals are typically
cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used
in digital watches, are typically cut in the shape of a tuning fork. For applications not
needing very precise timing, a low-cost ceramic resonator is often used in place of a
quartz crystal.
A quartz crystal can be modeled as an electrical network with a low impedance (series)
and a high impedance (parallel) resonance point spaced closely together. Mathematically
(using the Laplace transform) the impedance of this network can be written as:
62
or,
Where s is
The complex frequency (s = jω), ωs is the series resonant frequency in radians per second
and ωp is the parallel resonant frequency in radians per second.
Adding additional capacitance across a crystal will cause the parallel resonance to
shift downward. This can be used to adjust the frequency at which a crystal oscillates.
Crystal manufacturers normally cut and trim their crystals to have a specified resonance
frequency with a known 'load' capacitance added to the crystal. For example, a crystal
intended for a 6 pF load has its specified parallel resonance frequency when a 6.0 pF
capacitor is placed across it. Without this capacitance, the resonance frequency is higher.
Resonance modes:
A quartz crystal provides both series and parallel resonance. The series resonance
is a few kilohertz lower than the parallel one. Crystals below 300 MHz are generally
operated between series and parallel resonance, which means that the crystal appears as
an inductive reactance in operation. Any additional circuit capacitance will thus pull the
frequency down. For a parallel resonance crystal to operate at its specified frequency, the
electronic circuit has to provide a total parallel capacitance as specified by the crystal
manufacturer.
63
Crystals above 30 MHz (up to >200 MHz) are generally operated at series
resonance where the impedance appears at its minimum and equal to the series resistance.
For these crystals the series resistance is specified (<100 Ω) instead of the parallel
capacitance. To reach higher frequencies, a crystal can be made to vibrate at one of its
overtone modes, which occur at multiples of the fundamental resonant frequency. Only
odd numbered overtones are used. Such a crystal is referred to as a 3rd, 5th, or even 7th
overtone crystal.
Temperature effects:
In a real application, this means that a clock built using a regular 32 kHz tuning
fork crystal will keep good time at room temperature, lose 2 minutes per year at 10
degrees Celsius above (or below) room temperature and lose 8 minutes per year at 20
degrees Celsius above (or below) room temperature due to the quartz crystal.
Electrical oscillators:
64
A crystal used in hobby radio control equipment to select frequency.
The crystal oscillator circuit sustains oscillation by taking a voltage signal from
the quartz resonator, amplifying it, and feeding it back to the resonator. The rate of
expansion and contraction of the quartz is the resonant frequency, and is determined by
the cut and size of the crystal. When the energy of the generated output frequencies
matches the losses in the circuit, an oscillation can be sustained.
An oscillator crystal has two electrically conductive plates, with a slice or tuning
fork of quartz crystal sandwiched between them. During startup, the circuit around the
crystal applies a random noise AC signal to it, and purely by chance, a tiny fraction of the
noise will be at the resonant frequency of the crystal. The crystal will therefore start
oscillating in synchrony with that signal. As the oscillator amplifies the signals coming
out of the crystal, the signals in the crystal's frequency band will become stronger,
eventually dominating the output of the oscillator. The narrow resonance band of the
quartz crystal filters out all the unwanted frequencies.
Adding additional capacitance across a crystal will cause the parallel resonance to shift
downward. This can be used to adjust the frequency at which a crystal oscillates. Crystal
manufacturers normally cut and trim their crystals to have a specified resonance
frequency with a known 'load' capacitance added to the crystal. For example, a crystal
intended for a 6 pF load has its specified parallel resonance frequency when a 6.0 pF
capacitor is placed across it.
This means that a tuning fork crystal oscillator will resonate close to its target
frequency at room temperature, but will slow down when the temperature either increases
or decreases from room temperature.
As the oscillator amplifies the signals coming out of the crystal, the signals in the
crystal's frequency band will become stronger, eventually dominating the output of the oscillator.
The narrow resonance band of the quartz crystal filters out all the unwanted frequencies. Crystal
manufacturers normally cut and trim their crystals to have a specified resonance
frequency with a known 'load' capacitance added to the crystal. This means that a tuning
65
fork crystal oscillator will resonate close to its target frequency at room temperature, but will
slow down when the temperature either increases or decreases from room temperature. During
startup, the circuit around the crystal applies a random noise AC signal to it, and purely by
chance, a tiny fraction of the noise will be at the resonant frequency of the crystal.
This can be used to adjust the frequency at which a crystal oscillates. Crystal
manufacturers normally cut and trim their crystals to have a specified resonance
frequency with a known 'load' capacitance added to the crystal.
The 8-pin 555 timer must be one of the most useful ICs ever made and it is used
in many projects. With just a few external components it can be used to build many
circuits, not all of them involve timing!
A popular version is the NE555 and this is suitable in most cases where a '555
timer' is specified. The 556 is a dual version of the 555 housed in a 14-pin package, the
two timers (A and B) share the same power supply pins. The circuit diagrams on this
page show a 555, but they could all be adapted to use one half of a 556. . Relays are used
where it is necessary to control a circuit by a low-power signal (with complete electrical
isolation between control and controlled circuits), or where several circuits must be
controlled by one signal. The ability to both sink and source current means that two
devices can be connected to the output so that one is on when the output is low and the
other is on when the output is high.
Standard 555 and 556 ICs create a significant 'glitch' on the supply when their
output changes state. This is rarely a problem in simple circuits with no other ICs, but in
more complex circuits a smoothing capacitor (e.g. 100µF) should be connected across
the +Vs and 0V supply near the 555 or 556. The ability to both sink and source current
means that two devices can be connected to the output so that one is on when the output
is low and the other is on when the output is high. The top diagram shows two LEDs
connected in this way.
66
Fig 4.14 pin Diagram 555&556 TIMER
Low power versions of the 555 are made, such as the ICM7555, but these should
only be used when specified (to increase battery life) because their maximum output
current of about 20mA (with a 9V supply) is too low for many standard 555 circuits. The
ICM7555 has the same pin arrangement as a standard 555.
The circuit symbol for a 555 (and 556) is a box with the pins arranged to suit the
circuit diagram: for example 555 pin 8 at the top for the +Vs supply, 555 pin 3 outputs on
the right. Usually just the pin numbers are used and they are not labeled with their
function.
The 555 and 556 can be used with a supply voltage (Vs) in the range 4.5 to 15V
(18V absolute maximum). The ability to both sink and source current means that two
devices can be connected to the output so that one is on when the output is low and the
other is on when the output is high. The top diagram shows two LEDs connected in this
way
Standard 555 and 556 ICs create a significant 'glitch' on the supply when their
output changes state. This is rarely a problem in simple circuits with no other ICs, but in
67
more complex circuits a smoothing capacitor (e.g. 100µF) should be connected across
the +Vs and 0V supply near the 555 or 556. The ability to both sink and source current
means that two devices can be connected to the output so that one is on when the output
is low and the other is on when the output is high. The top diagram shows two LEDs
connected in this way
The input and output pin functions are described briefly below and there are fuller
explanations covering the various circuits:
Inputs of 555/556
Trigger input: when < 1/3 Vs ('active low') this makes the output high (+Vs). It monitors
the discharging of the timing capacitor in an astable circuit. It has a high input impedance
> 2M .
Threshold input:
when > 2/3 Vs ('active high') this makes the output low (0V)*. It monitors the charging of
the timing capacitor in astable and monostable circuits. It has a high input
impedance > 10M. Providing the trigger input is > 1/3 Vs, otherwise the trigger
input will override the threshold input and hold the output high (+Vs).
Reset input:
when less than about 0.7V ('active low') this makes the output low (0V), overriding other
inputs. When not required it should be connected to +Vs. It has an input impedance of
about 10k .
68
The discharge pin is not an input, but it is listed here for convenience. It is connected to
0V when the timer output is low and is used to discharge the timing capacitor in astable
and monostable circuits.
Output of 555/556
4
4.15 555with relay
555/556 Astable:
An astable circuit produces a 'square wave’; this is a digital waveform with sharp
transitions between low (0V) and high (+Vs). Note that the durations of the low and high
states may be different. The circuit is called an astable because it is not stable in any
state: the output is continually changing between 'low' and 'high'.
69
4.9 SCHEMATIC DIAGRAM
70
4.10 WORKING PRINCIPLE
ULN drivers are used for amplification of current to drive the relay. Crystal
oscillator is used to provide clock frequency to micro-controller and where as the clock
pulse for ADC is given through 555 timer asastable multivibrator circuit.
71
CHAPTER 5
72
Transformer.
Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. Step-up transformers increase voltage, step-down transformers reduce
voltage. Most power supplies use a step-down transformer to reduce the dangerously high
mains ºvoltage (230V in UK) to a safer low voltage
The input coil is called the primary and the output coil is called the secondary. There is
no electrical connection between the two coils, instead they are linked by an alternating magnetic
field created in the soft-iron core of the transformer. The two lines in the middle of the circuit
symbol represent the core.
Rectifier:
A circuit which is used to convert a.c to d.c is known as RECTIFIER. The process
Types of rectifiers:
73
Type of Rectifier
Number of diodes
1 2 3
PIV of diodes
Vm 2Vm Vm
Vdc, at
0.318Vm 0.636Vm 0.636Vm
no-load
Ripple
Frequency F 2f 2f
Rectification
74
Full-wave Rectifier:
From the above comparison we came to know that full wave bridge rectifier as
more advantageous than the other two rectifiers. So, in our project we are using full wave
bridge rectifier circuit.
Bridge Rectifier:
A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig(a) to
achieve full-wave rectification. This is a widely used configuration, both with individual
diodes wired as shown and with single component bridges where the diode bridge is
wired internally.
Capacitive filter:
We have seen that the ripple content in the rectified output of half wave rectifier
is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high
percentages of ripples is not acceptable for most of the applications. Ripples can be
removed by one of the following methods of filtering:
(a) A capacitor, in parallel to the load, provides an easier by –pass for the ripples voltage
though it due to low impedance. At ripple frequency and leave the d.c to appears the load.
(b) An inductor, in series with the load, prevents the passage of the ripple current (due to
high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)
(c) Various combinations of capacitor and inductor, such as L-section filter section
filter, multiple section filter etc. which make use of both the properties mentioned in (a)
and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and
another with full wave rectifier.
75
Filtering is performed by a large value electrolytic capacitor connected across the DC
supply to act as a reservoir, supplying current to the output when the varying DC voltage
from the rectifier is falling. Filtering significantly increases the average DC voltage to
almost the peak value
C = ¼*√3*f*r*Rl
Where,
Voltage regulator:
76
CHAPTER 6
SOFTWARE COMPONENT
6.1KIEL SOFTWARE
Many companies provide the 8051 assembler, some of them provide shareware
version of their product on the Web, Kiel is one of them. We can download them from
their Websites. However, the size of code for these shareware versions is limited and we
have to consider which assembler is suitable for our application.
Select Project - Rebuild all target files or Build target. UVision2 compiles,
assembles, and links the files in your project.
77
Debugging an application in uvision2:
The following limitations apply to the evaluation versions of the C51, C251, or C166 tool
chains. C51 Evaluation Software Limitations:
The compiler, assembler, linker, and debugger are limited to 2 Kbytes of object
code but source Code may be any size. Programs that generate more than 2
Kbytes of object code will not compile, assemble, or link the startup code
generated includes LJMP's and cannot be used in single-chip devices supporting
Less than 2 Kbytes of program space like the Philips750/751/752.
The debugger supports files that are 2 Kbytes and smaller.
Programs begin at offset 0x0800 and cannot be programmed into single-chip
Devices.
Evaluation software:
Code-Banking Linker/Locator
Library Manager.
Peripheral simulation
The u vision2 debugger provides complete simulation for the CPU and on chip
peripherals of most embedded devices. To discover which peripherals of a device are
supported, in u vision2. Select the Simulated Peripherals item from the Help menu. You
78
may also use the web-based device database. We are constantly adding new devices and
simulation support for on-chip peripherals so be sure to check Device Database often.
79
11. A small window opens asking whether to copy the startup code into the file you
have created just now. Just click on “No” to proceed further.
12. Now you can see the TARGET and SOURCE GROUP created in the project
workspace.
13. Now click on “File” and in that “New”. A new page opens and you can start
writing program in it.
14. After the program is completed, save it with any name but with the .asm or .c
extension. Save the program in the file you have created earlier.
15. You can notice that after you save the program, the predefined keywords will be
highlighted in bold letters.
16. Now add this file to the target by giving a right click on the source group. A list of
options open and in that select “Add files to the source group”. Check for this file
where you have saved and add it.
17. Right click on the target and select the first option “Options for target”. A window
opens with different options like device, target, output etc. First click on “target”.
18. Since the set frequency of the microcontroller is 11.0592 MHz to interface with
the PC, just enter this frequency value in the Xtal (MHz) text area and put a tick
on the Use on-chip ROM. This is because the program what we write here in the
keil will later be dumped into the microcontroller and will be stored in the inbuilt
ROM in the microcontroller.
19. Now click the option “Output” and give any name to the hex file to be created in
the “Name of executable” text area and put a tick to the “Create HEX file” option
80
CHAPTER 7
7.1 APPLICATIONS:
1) Water distribution
7.2 ADVANTAGES
1) Automatic control
4) Remote operation
81
SNAPSHOTS
82
When the power supply and machine is in ONState
when the temperature exceeds 40ºc and less than 50ºc, then the cooling fan is ON
83
When the temperature is > 50ºc machine goes to OFFstate & cooling fan is still ON
84
CONCLUSION
Using this project one can control the operation of the machines depending on the
temperature reading automatically and monitoring the operation of the machine along
with voltage and current readings by means of PC. This project can be used in industries
as well as domestic applications wherever automation is needed.
Further this project can be upgraded using advanced technologies, to control the
voltage, current and other factors like speed, intensity etc., of the desired machines.
85
REFERENCES
www.Atmel.com
www.google.com
www.wikipedia.com
www.Microchiptechnology.Com
BOOKS
4) Microelectronic circuits
86