Chapter 1. Overview
Chapter 1. Overview
OVERVIEW
1
1.1 INTRODUCTION
Data acquisition is the process of gathering signals from the measurement sources and
digitizing those signals for storage and analysis. The data of the real world are translated into signals
that can be manipulated by the computer. A Data acquisition system comprises of signal source, signal
connection, signal conditioning and signal measurement. Signal source is a transducer to measure
physical phenomena. Signal conditioning is the process of amplification, filtering and isolation.
This Project deals with development of multi-channel analog data though a PC. It uses an
ADC acd0808 to convert from analog to digital. A microcontroller to control the ADC and send data
to mobile through at the baud rate of 9600. And a MAX 232 chip to convert the RS232 signal. The
ADC0808 and ADC0809 each consists of an analog signal multiplexer, an 8-bit successive-
approximation converter, and related control and output circuitry. The analog multiplexer selects 1 of
8 single-ended input channels as determined by the address decoder.
1.3 METHODOLOGY:
Here microcontroller generates three bit data and applies it to the ADC. Using these bits as
selection bits it selects a channel among the available eight channels.This ADC consists a 8 to 1
multiplexer. so analog signal generated by the sensors will be converted into digital form.This digital
signal is given to the PC via MAX232.
Since serial communication is used for communication with PC the logical levels to be
changed. This is done by MAX232.The result will be displayed on a display system.
2
1.4 IMPORTANCE AND APPLICATIONS:
The existing project can be used for limited purpose, which it can be further improved to its
next generation for a large number of appliances.
1.Automatic control of out door lighting system using light dependant resistor as a sensing element.
2.Door locking system using digital gadget locking.
3
CHAPTER 2. DESCRIPTION OF COMPONENTS
There are many types of power supply. Most are designed to convert high voltage AC
mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power
supply can by broken down into a series of blocks, each of which performs a particular function. They
4
are Transformer, Rectifier, Smoothing component and Regulator. The power supply circuit generating
5V and 12V DC voltages is shown in figure.
The components of the power supply circuit are described below along with output
graph.
Transformer:
5
A transformer steps down high voltage AC mains to low voltage AC. Here we are using a
center-tap transformer of 18v-0-18v, 1A. The transformer output is given to the rectifier circuit. The
transformer component with its output voltage is shown in figure 1.3.
Rectifier:
A rectifier converts AC to DC, but the DC output is varying. There are several types of
rectifiers; here we use a bridge rectifier.
The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both
half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure 1.4. The circuit
has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally opposite
ends of the bridge. The load resistance is connected between the other two ends of the bridge.
For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load
resistance RL and hence the load current flows through RL. For the negative half cycle of the input ac
voltage, diodes D2 and D4 conduct whereas D1 and D3 remain OFF. The conducting diodes D2 and
D4 will be in series with the load resistance RL and hence the current flows through RL in the same
direction as in the previous half cycle. Thus a bi-directional wave is converted into unidirectional.
6
FIGURE 1.3: RECTIFIER DIAGRAM
The varying DC output is suitable for lamps, heaters and standard motors. It is not suitable for
electronic circuits unless they include a smoothing capacitor.
7
Regulator:
Regulator eliminates ripple by setting DC output to a fixed voltage. Voltage regulators ICs are
available with fixed (typically 5, 12 and 15V) or variable output voltages. Negative voltage regulators
are also available. We have used 2 regulators in the power supply circuitry namely 7805 and 7812 for
5v and 12v dc voltage. At the output of the regulator, a 0.1µf capacitor is used in order to avoid any
high frequency voltage spikes at the output.
FEATURES:
DESCRIPTION:
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 4
Kbytes of Flash Programmable and Erasable Read Only Memory (PEROM). The device is
manufactured using Atmel’s high-density non-volatile memory technology and is compatible with the
8
industry standard MCS-51Ô instruction set and pin out. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By
combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful
microcomputer, which provides a highly flexible and cost effective solution to many embedded
control applications.
2.2.1 ARCHITECTURE OF AT89C52:
9
2.2.2 PIN CONFIGURATION:
Pin Description:
10
VCC:
Supply voltage.
GND:
Ground.
Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port.
As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can
be used as high impedance inputs. Port 0 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
memory that uses 16-bit addresses (MOVX @ DPTR). In this application, it 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.
11
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 Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
WR (external data memory Write
P3.6
strobe)
RD (external data memory read
P3.7
strobe)
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/6 the oscillator frequency, and may be used
for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each
12
access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise,
the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
PSEN :
Program Store Enable is the read strobe to external program memory. When the 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 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:
Output from the inverting oscillator amplifier
13
2.2.3 MEMORY ORGANIZATION:
The 89c52 micro controller has separate address for program memory and data
memory. The logical separation of program and data memory allows the data memory to
be accessed by 8-bit address, which can be quickly stored and manipulated by an 8-bit
CPU. Nevertheless, 16-bit data memory address can also be generated through the DPTR
register. Program memory (ROM, EPROM) can only be read, not written to. There can
be up to 64k bytes if program memory the lowest 4k bytes of program are on chip. In the
ROM less versions, all program memory is external. The read strobe for external program
is the PSEN (program store enable). Data memory (RAM) occupies a separate address
space from program memory the lowest 128 bytes of data memory are on chip. Up to 64
bytes of external RAM can be addressed in the external data memory space. In the ROM
less version, the lowest 128bytes of data memory are on chip. The CPU generates read
and write signals, RD and WR, as needed during external data memory access. External
program memory may be combined if desired by applying the RD and PSEN signals to
the inputs of an AND gate and using the output of the gate as the read strobe to the
external program/data memory.
14
Register Banks:
The 8051 use 8 "R" registers, which are used in many of its instructions. These
"R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7).
These registers are generally used to assist in manipulating values and moving data from
one memory location to another.
For example: To add the value of R4 to the Accumulator, we would execute the
following instruction.
ADD A, R4
Thus if the Accumulator (A) contained the value 6 and R4 contained the value 3,
the Accumulator would contain the value 9 after this instruction was executed. However,
as the memory map shows, the "R" Register R4 is really part of Internal RAM.
Specifically, R4 is address 04h. This can be seeing in the bright green section of the
memory map. Thus the above instruction accomplishes the same thing as the following
operation:
ADD A, 04h
This instruction adds the value found in Internal RAM address 04h to the value of
the Accumulator, leaving the result in the Accumulator. Since R4 is really Internal RAM
04h, the above instruction effectively accomplished the same thing.
PSW: It contains math flags; user flags F0 and register select bits RS1 and RS0
to determine the working register bank.
15
STACK AND STACK POINTER:
Stack is used to hold and retrieve data quickly. The 8 – bit SP is incremented
before data is stored during PUSH and CALL executions. While the stack may reside any
where in on-chip RAM, the SP is initialized to 07H after the stack to begin at
manipulated as a 16 – bit register or as two independent 8 – bit registers.
PC:
It addresses the memory locations that program instructions are to be fetched. It is
the only register that does not have any internal address.
FLAGS:
They are 1 – bit register provided to store the results of certain program
instructions. Other instructions can test the conditions of the flags and make the decisions
accordingly. To conveniently address, they are grouped inside the PSW and PCON.
The micro controller has 4 main flags: carry(c), auxiliary carry (AC), over
flow (OV), parity (P) and 3 general-purpose flags: F0, GF0 and GF1.
PORTS:
All ports are bi-directional; each consists of a latch, an output driver and an input buffer.
P0, P1, P2 and P3 are the SFR latches ports 0, 1, 2 and 3 respectively. The main functions
of each port are mentioned below.
Port0: input/output bus port, address output port and data input/output port.
Port1: Quasi-bi-directional input/output port.
Port2: Quasi-bi-directional input/output port and address output port.
Port3: Quasi-bi-directional input/output port and control input/output pin.
16
SBUF:
The microcontroller has serial transmission circuit that uses SBUF register to hold
data. It is actually two separate registers, a transmit buffer and a receive buffer register.
When data is moved to SBUF, it goes to transmit buffer, where it is held for serial
transmission and when it is moved from SBUF, it comes from the receive buffer.
TIMER REGISTER:
Register pairs (TH0, TL1), (TH1, TL1) are the 16-bit counter registers for
timer/counters 0 and 1.
CONTROL REGISTERS:
SFR’s, IP, TMOD, SCON, and PCON contain control and status bits for the
interrupt system, Timers/counters and the serial port.
RESET:
The reset switch is the RST pin of the microcontroller, which is the input to a
Schmitt trigger. It is accomplished by holding the RST pin HIGH for at least two
machine cycles while the oscillator frequency is running the CPU responds by generating
an internal reset
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 Figure 1. Either a
quartz crystal or ceramic resonator may be used.
17
To drive the device from an external clock source, XTAL2 should be left unconnected
while XTAL1 is driven as shown in Figure 2. 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.
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:
The 8051 come equipped with two timers, both of which may be controlled, set,
read, and configured individually.
18
The 8051 timers have three general functions:
The three timer uses are distinct so we will talk about each of them separately.
The first two uses will be discussed in this chapter while the use of timers for baud rate
generation will be discussed in the chapter relating to serial ports.
TIMER SFRs:
As mentioned before, the 8051 have two timers, one timer is TIMER0 and the
other is TIMER1. The two timers share two SFRs (TMOD and TCON), which control the
timers, and each timer also has two SFRs dedicated solely to itself (TH0/TL0 and
TH1/TL1).
We’ve given SFRs names to make it easier to refer to them, but in reality an SFR
has a numeric address. It is often useful to know the numeric address that corresponds to
an SFR name.
When you enter the name of an SFR into an assembler, it internally converts it to
a number. For example, the command:
Moves the value 25h into the TH0 SFR. However, since TH0 is the same as SFR
19
Now, back to the timers. First, lets talk about Timer 0.
You may just think of this as the high and low byte of the timer. That is to say,
when Timer 0 has a value of 0, both TH0 and TL0 will contain 0. When Timer 0 has the
value 1000, TH0 will hold the high byte of the value (3 decimal) and TL0 will contain the
low byte of the value (232 decimal). Reviewing low/high byte notation, recall that you
must multiply the high byte by 256 and add the low byte to calculate the final value. That
is to say:
TH0*256+TL0=1000
3 * 256 + 232 = 1000
Timer 1 works the exact same way, but its SFRs are TH1 and TL1.
TMOD SFR:
The TMOD SFR is used to control the mode of operation of both timers. Each bit
of the SFR gives the specific information concerning how to run a timer. The high four
bits (bits 4 through 7) relate to Timer 1. Whereas the lower four bits (bits 0 through 3)
perform the exact function, for timer 0.
20
INT0 (P3.2) is high. When this bit is clear the timer
will run regardless of the state of INT0.
When this bit is set the timer will count events on
2 C/T0 T0 (P3.4). When this bit is clear the timer will be 0
incremented every machine cycle.
1 T0M1 Timer mode bit (see below) 0
0 T0M0 Timer mode bit (see below) 0
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:
Timer mode "0" is a 13-bit timer. When the timer is in 13-bit mode, TLx will
count from 0 to 31. When TLx is incremented from 31, it will "reset" to 0 and increment
THx. Thus, effectively, only 13 bits of the two-timer bytes are being used: bits 0-4 of
TLx and bits 0-7 of THx. This also means, the timer can only contain 8192 values. If you
set a 13-bit timer to 0, it will overflow back to zero 8192 machine cycles later.
Timer mode "1" is a 16-bit timer. This is a very commonly used mode. It
functions just like 13-bit mode except that all 16 bits are used.
TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets
to 0 and causes THx to be incremented by 1. Since this is a full 16-bit timer, the timer
may contain up to 65536 distinct values. If you set a 16-bit timer to 0, it will overflow
back to 0 after 65,536 machine cycles.
Timer mode "2" is an 8-bit auto-reload mode. What is that, you may ask? Simple.
When a timer is in mode 2, THx holds the "reload value" and TLx is the timer itself.
21
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.
TCON SFR:
Finally, there’s one more SFR that controls the two timers and provides valuable
information about them.
Bit
Bit Name Explanation of Function Timer
Address
Timer 1 Overflow. The micro controller sets this bit
7 TF1 8Fh 1
when Timer 1 overflows.
Timer 1 Run. When this bit is set Timer 1 is turned on.
6 TR1 8Eh 1
When this bit is clear Timer 1 is off.
Timer 0 Overflow. The micro controller sets this bit
5 TF0 8Dh 0
when Timer 0 overflows.
Timer 0 Run. When this bit is set Timer 0 is turned on.
4 TR0 8Ch 0
When this bit is clear Timer 0 is off.
As you may notice, we’ve only defined 4 of the 8 bits. That’s because the other 4
bits of the SFR don’t have anything to do with timers, they have to do with Interrupts and
they will be discussed in the chapter that addresses interrupts.
A new piece of information in this chart is the column "bit address." This is
because this SFR is "bit-addressable." What does this mean? It means if you want to set
the bit TF1.which is the highest bit of TCON--you could execute the command:
22
Or, since the SFR is bit-addressable, you could just execute the command:
SETB TF1.
This has the benefit of setting the high bit of TCON without changing the value of
any of the other bits of the SFR. Usually when you start or stop a timer you don’t
want to modify the other values in TCON, so you take advantage of the fact that the
SFR is bit-addressable.
Initializing a Timer:
Now that we’ve discussed the timer-related SFRs we are ready to write code that
will initialize the timer and start it running.
As you’ll recall, we first must decide what mode we want the timer to be in. In
this case, we want a 16-bit timer that runs continuously.
We must first initialize the TMOD SFR. Since we are working with timer 0 we
will be using the lowest 4 bits of TMOD. The first two bits, GATE0 and C/T0 are both 0
since we want the timer to be independent of the external pins. 16-bit mode is timer mode
1 so we must clear T0M1 and set T0M0. Effectively, the only bit we want to turn on is bit
0 of TMOD. Thus to initialize the timer, we execute the instruction:
Timer 0 is now in 16-bit timer mode. However, the timer is not running. To start
the timer running we must set the TR0 bit we can do that by executing the instruction:
SETB TR0.
Upon executing these two instructions timer 0 will immediately begin counting,
being incremented once every machine cycle (every 12 crystal pulses).
2.5 INTERRUPTS:
The micro controller provides 6 interrupt sources, 2 external interrupts, 2 timer
interrupts and a serial port interrupt and a reset. The external interrupts (INT0 & INT1)
can each be either level activated or transition activated depending on bits IT0 and IT1 in
23
register TCON. The flags that actually generate these interrupts are IE0 & IE1 bits in
TCON.
TF0 and TF1 generate the timer 0 & 1 interrupts, which are set by a roll over in
their respective timer/counter registers. When a timer interrupt is generated the on-chip
hardware clears the flag that generated it when the service routine is vectored to.
The serial port interrupt is generated by logical OR of R1 & T1. Neither of these
flags is cleared by hardware when service routine is vectored to. In fact, the service
routine itself determines whether R1 & T1 generated the interrupt, and the bit is cleared
in the software.
Upon reset, all interrupts are disabled, meaning that none will be responded to
by the micro controller if they are activated. The interrupts must be enabled by software
in order for the micro controller to respond to them.
Serial Interrupts are slightly different than the rest of the interrupts. This is due to
the fact that there is two interrupt flags: RI and TI. If either flag is set, a serial interrupt is
triggered. As you will recall from the section on the serial port, the RI bit is set when a
byte is received by the serial port and the TI bit is set when a byte has been sent.
This means that when your serial interrupt is executed, it may have been triggered
because the RI flag was set or because the TI flag was set or because both flags were set.
Thus, your routine must check the status of these flags to determine what action is
appropriate. Also, since the 8051 does not automatically clear the RI and TI flags you
must clear these bits in your interrupt handler.
24
CHAPTER 3. SERIAL COMMUNICATION
One of the 8051s many powerful features is its integrated UART, otherwise
known as a serial port. The fact that the 8051 have an integrated serial port means that
you may very easily read and write values to the serial port.
25
an SFR to write a value to the serial port or read the same SFR to read a value from the
serial port. The 8051 will automatically let us know when it has finished sending the
character we wrote and will also let us know whenever it has received a byte so that we
can process it.
The first things we must do when using the 8051s integrated serial port is,
obviously, configure it. This lets us tell the 8051 how many data bits we want, the baud
rate we will be using, and how the baud rate will be determined. First, let’s present the
"Serial Control" (SCON) SFR and define what each bit of the SFR represents:
(*) Note: The baud rate indicated in this table is doubled if PCON.7 (SMOD) is set.
26
The SCON SFR allows us to configure the Serial Port. The first four bits (bits 4
through 7) are configuration bits.
Bits SM0 and SM1 let us set the serial mode to a value between 0 and 3. The four
modes are defined in the chart im 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 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.
The next bit, 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.
The last four bits (bits 0 through 3) are operational bits. They are used when
actually sending and receiving data, they are not used to configure the serial port.
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."
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.
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 8051 have
27
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.
Once the Serial Port Mode has been configured, as explained above, the program
must configure the serial ports baud rate. This only applies to Serial Port modes 1 and 3.
The Baud Rate is determined based on the oscillator’s frequency when in mode 0 and 2.
In mode 0, the baud rate is always the oscillator frequency divided by 12. This means if
you’re crystal is 11.059 MHz; mode 0 baud rate will always be 921,583 baud. In mode 2
the baud rate is always the oscillator frequency divided by 64, so a 11.059Mhz crystal
speed will yield a baud rate of 172,797.
To determine the value that must be placed in TH1 to generate a given baud rate,
we may use the following equation (assuming PCON.7 is clear).
If PCON.7 is set then the baud rate is effectively doubled, thus the equation becomes:
3.3 MAX-232:
Since the RS-232 is not compatible with today’s microprocessors and micro
controllers, we need a line driver to convert the RS_232’s signals to TTL voltage levels
that will be acceptable to 89C52’s TxD and RxD pins.
One example of such a converter is MAX-232 from maxim corp. the MAX232
converts RS232 voltage levels to TTL voltage levels and vice versa.
28
. FIGURE 3.1: PIN DESCRIPTION
29
3.4 INTERFACING OF MAX-232 WITH AT89C52:
30
CHAPTER 4. ANALOG TO DIGITAL CONVERTERS
31
Digital circuitry can be connected to sensor devices if they are inherently digitalized
by themselves. Switches, relays, and encoders are easily interfaced with gate circuits due
to the on/off nature of their signals. However, when analog devices are involved,
interfacing is needed to translate analog signals into digital quantities. When data
acquisition hardware receives an analogue signal from sensor it converts it to a voltage. It
then digitizes it with an analogue-to-digital converter, ready for transfer to a computer.
Characteristic parameters for A-D converters are: resolution, sample and hold
acquisition time, linearity, throughput etc. some of the specifications are defined below:
Resolution: Resolution defines the smallest change in the input voltage that can be
detected and encoded by the ADC. Resolution of the A-D converter is the number of
steps the input range is divided into. The resolution is usually expressed by the number of
bits in its output code (n) and the number of steps is 2 to the power n.
Sample and Hold Acquisition Time: A sample and hold circuit freezes the analogue
input voltage at the moment the sample is required. This voltage is held constant whilst
the A-D converter digitizes it. The acquisition time is the time between releasing the hold
state and the output of the sample circuit settling to the new input voltage value.
Throughput: Throughput is the maximum rate at which the A-D converter can output
data values. In general it will be the inverse of the sum of conversion time and acquisition
time. Conversion time is the time taken by an ADC to produce the valid digital output
corresponding to the analog input. Throughput can be increased by using a pipelined A-D
converter, so a second conversion can start while the first is still in progress.
Accuracy: Absolute accuracy or error of an ADC at a given output code is defined as the
difference between the corresponding theoretical analog value and the actual input
voltage required to produce that code.
There are many types of ADC’s such as Flash, Dual slope integrating, Successive
approximation, Delta-sigma etc.
32
4.1 HARDWARE DESIGN
33
The main component of this single chip data acquisition system is its 8-bit analog-to-
digital converter. This converter is designed to give fast, accurate, and repeatable
conversions over a wide range of temperatures. The converter is partitioned into three
major sections: the 256R ladder network, the successive approximation register, and the
comparator.
Successive approximation register counts by trying all values of bits, starting with
most significant bit and finishing at the least significant bit. Throughout the count
process, the register monitors the comparator's output to see if the binary count is less
than or greater than the analog signal input, adjusting the bit values accordingly. The A/D
converter's successive approximation register (SAR) is reset on the positive edge of the
start conversion (SC) pulse. The conversion is begun on the falling edge of the start
conversion pulse. A conversion in process will be interrupted by receipt of a new start
conversion pulse. Continuous conversion may be accomplished by tying the end of-
conversion (EOC) output to the SC input. End-of-conversion will go low between 0 and 8
clock pulses after the rising edge of start conversion. The block diagram of ADC0808 is
shown in figure.
34
FIG 4.2 : 555 TIMER
The threshold and trigger levels are normally two-thirds and one-third,
respectively, of VCC. These levels can be altered by use of the control voltage terminal.
When the trigger input falls below the trigger level, the flip-flop is set and the output goes
high. If the trigger input is above the trigger level and the threshold input is above the
threshold level, the flip-flop is reset and the output is low. RESET can override all other
inputs and can be used to initiate a new timing cycle. When RESET goes low, the flip-
flop is reset and the output goes low. Whenever the output is low, a low-impedance path
is provided between DISCH and ground.
35
FIGURE 4.3: ASTABLE CIRCUIT
The capacitor now discharges with current flowing through R2 into the
discharge pin. When the voltage falls to 1/3Vs (trigger voltage) the output becomes high
again and the discharge pin is disconnected, allowing the capacitor to start charging again
.This cycle repeats continuously unless the reset input is connected to 0V, thus producing
a square wave with a time period of 0.7 (R1+2R2) C1. The square wave generated by
the Astable circuit of 555 timer is given to the 10th pin of ADC0808 to drive the clock.
36
CHAPTER 5. SENSORS
37
Sensors are the devices which are used to sense different parameters .The sensed
signal is converted into our required type with the help of transducers. Potentiometers can
be used to detect variations in voltage and resistance. With proper arrangement they can
also detect variations in angular displacement. It converts variations in all parameters in
terms of voltage. We have to use proper calibrations to convert these voltage variations
back into physical phenomenon. Variations in temperature can be detected and measured
using various types of temperature sensors such as RTDS, thermocouples, ultrasonic and
thermistors. In this project, we are using LM35 sensor which is a thermistor. For
measuring humidity, we are using SYH-2 and potentiometers.
The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus
has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not
required to subtract a large constant voltage from its output to obtain convenient
Centigrade scaling. The LM35 does not require any external calibration or trimming to
provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full -55 to
+150°C temperature range. Low cost is assured by trimming and calibration at the wafer
level. The LM35's low output impedance, linear output, and precise inherent calibration
make interfacing to readout or control circuitry especially easy. It can be used with single
power supplies, or with plus and minus supplies. As it draws only 60 µA from its supply,
it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate over
a -55° to +150°C temperature range, while the LM35C is rated for a -40° to +110°C
range (-10° with improved accuracy). The LM35 series is available packaged in hermetic
TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available
in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface
mount small outline package and a plastic TO-220 package.
38
5.1.1 FEATURES:
You can measure temperature more accurately than a using a thermistor. The sensor
circuitry is sealed and not subject to oxidation, etc.
The LM35 generates a higher output voltage than thermocouples and may not require
that the output voltage be amplified.
39
What Does an LM35 Do? How does it work?
40
How Do You Use An LM35? (Electrical Connections)
Here is a commonly used circuit. For connections refer to the picture above.
• Vc = 4 to 30v
• 5v or 12 v are typical values used.
• Ra = Vc /10-6
Fig.5.1 LM35
41
thermistor Rt. Suitable for air humidifiers and dryers, ventilation and air conditioning
systems, air cleaners, incubators,humidity meters, greenhouses, vehicles, etc.
SPECIFICATIONS:
• Items: syh-2,syh-2s
• Rated voltage: AC 1Vrms
• Rated power: AC 0.22mW
• Operating temp.: 0-60 c
• Operating humidity: 20-95%Rh
• Standard characteristics: at 25 c,60%RH
• Storage temperature: -30 to 85 c
• Storage humidity: within 95%Rh
• Humidity accuracy: 5%RH(at 25 c,60%RH)
• Humidity response time: <60 sec(40 to 80%RH)
• Hysterisis: +/-2%RH
42
CHAPTER 6. BLOCK DIAGRAM, CODING AND CONCLUSION
43
6. block diagram of the project:
ADC
MC 0808
PC MAX-232
89C52
CLK
44
45
FIG.5.3.OVERVIEW OF DATA ACQUISITION SYSTEM USING 89C52
7. CODING
46
#include<reg52.h>
#include<math.h>
sbit ale=P1^4;
sbit oe=P1^5;
sbit sc=P1^6;
sbit eoc=P1^7;
sbit add_a=P1^0;
sbit add_b=P1^1;
sbit add_c=P1^2;
sfr port2=0xa0;
unsigned int c02,c01,c03,c1,c2,c3,c4,t,dispdata,cnl;
ROUTINE
//TO
TRANSMIT THE
// OUTPUT TO THE
unsigned int x; //HYPER
TERMINAL
if(RI==1){
x=SBUF;
RI=0;
if(x=='0')
{
cnl=0;
}
if(x=='1')
{
cnl=1;
47
}
if(x=='2')
{
cnl=2;
}
if(x=='3')
{
cnl=3;
}
if(x=='4')
{
cnl=4;
}
if(x=='5')
{
cnl=5;
}
if(x=='6')
{
cnl=6;
}
if(x=='7')
{
cnl=7;
}
if(x=='t')
{
IE=0X00;
SBUF='\n';
while(TI==0);
TI=0;
c1=c1+48;
SBUF=c1;
while(TI==0);
TI=0;
c2=c2+48;
SBUF=c2;
48
while(TI==0);
TI=0;
c3=c3+48;
SBUF=c3;
while(TI==0);
TI=0;
SBUF='.';
while(TI==0);
TI=0;
c4=c4+48;
SBUF=c4;
while(TI==0);
TI=0;
SBUF=' ';
while(TI==0);
TI=0;
SBUF='c';
while(TI==0);
TI=0;
SBUF='\n';
while(TI==0);
TI=0;
}
if(x=='x')
{
IE=0X00;
SBUF='\n';
while(TI==0);
TI=0;
SBUF='\n';
while(TI==0);
TI=0;
SBUF=' ';
49
while(TI==0);
TI=0;
t=t+48;
SBUF=t;
while(TI==0);
TI=0;
c1=c1+48;
SBUF=c1;
while(TI==0);
TI=0;
SBUF='.';
while(TI==0);
TI=0;
c2=c2+48;
SBUF=c2;
while(TI==0);
TI=0;
c3=c3+48;
SBUF=c3;
while(TI==0);
TI=0;
c4=c4+48;
SBUF=c4;
while(TI==0);
TI=0;
SBUF=' ';
while(TI==0);
TI=0;
SBUF='V';
while(TI==0);
TI=0;
}
if(x=='h'){
IE=0X00;
SBUF='\n';
50
while(TI==0);
TI=0;
c1=c1+48;
SBUF=c1;
while(TI==0);
TI=0;
c2=c2+48;
SBUF=c2;
while(TI==0);
TI=0;
c3=c3+48;
SBUF=c3;
SBUF='.';
while(TI==0);
TI=0;
c4=c4+48;
SBUF=c4;
while(TI==0);
TI=0;
SBUF=' ';
while(TI==0);
TI=0;
SBUF='H';
while(TI==0);
TI=0;
SBUF='\n';
while(TI==0);
TI=0;
}
}
}
void main(void){
51
unsigned int u,v,z,s,f;
float y,d;
y=19.53;
port2=0xFF;
TMOD=0X20;
TH1=0XFD;
SCON=0X50;
TR1=1;
IE=0X90; //ENABLE SERIAL INTERRUPT
eoc=1;
ale=0;
oe=0;
sc=0;
while(1)
{
if(cnl==0)
{
add_a=0;
add_b=0;
add_c=0;
}
if(cnl==1)
{
add_a=1;
add_b=0;
add_c=0;
}
if(cnl==2)
{
add_a=0;
add_b=1;
add_c=0;
}
if(cnl==3)
{
add_a=1;
add_b=1;
add_c=0;
52
}
if(cnl==4)
{
add_a=0;
add_b=0;
add_c=1;
}
if(cnl==5)
{
add_a=1;
add_b=0;
add_c=1;
}
if(cnl==6)
{
add_a=0;
add_b=1;
add_c=1;
}
if(cnl==7)
{
add_a=1;
add_b=1;
add_c=1;
}
for(f=0;f<3000;f++);
ale=1;
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
sc=1;
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
53
ale=0;
sc=0;
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
oe=1
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
for(f=0;f<3000;f++);
s=port2;
// ADC DIGITAL O/P 0N PORT1 STORED
IN S
z=0xA; //HEX TO DEC CONVERSION
v=port2/z;
u=port2%z;
v=v*10;
d=u+v;
d=d*y;
display(d);
oe=0;
54
}
c4=dispdata%10;
c01=dispdata/1000;
c1=c01%10;
c02=dispdata/100;
c2=c02%10;
c03=dispdata/10;
c3=c03%10;
t=dispdata/10000;
return(0);
55
CONCLUSION:
The existing project can be used for limited purpose, which it can be further
improved to its next generation for a large number of appliances.
As now the kit is interfaced with only few devices with other port pins being left
open for further expansion of the system. This could result in including the other house
hold appliances such as tube light, electric heaters; tape audio deck, etc, thus providing a
complete tool for house hold purpose.
This kit may be modified in the hardware as well as the software in a little manner to
obtain regulation of certain devices.
a) Automatic control of out door lighting system using light dependant resistor as a
sensing element.
b) Door locking system using digital gadget locking.
c) We can measure pressure, humidity and velocity.
Thus all the above parameters are chosen to control with the help of micro
controller, as nowadays the embedded controllers are playing a vital in the industries and
in western countries such as United States and other places lot of demand exist for
56
controllers. There by this project work serves as a guidance to enter into those fields,
which gives much encouragement and helps in growing and climbing the ladder.
BIBILOGRAPHY
TEXT BOOKS:
57
APPENDIX
ASCII CODES:
58