Electronic Eye For detecting multi-colors
-
Upload
smaran-rachakonda -
Category
Documents
-
view
208 -
download
0
description
Transcript of Electronic Eye For detecting multi-colors
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 1
INTRODUCTION
1.1 DESCRIPTION:
In this project an LDR is used the color sensor, which senses color intensity and
converts into voltage with respect to the light intensity. This voltage is converted into the
digital data using analog to digital converter. By this we can get selected compositions of
the radiant light. By using this sensor we can find color of the object. The LDR detects each
color and it gives different voltage levels. Analog to digital converter will take that voltage
and convert it into digital form. These digital values are varying from color to color. Here
ADC0804 is used to convert analog voltage levels into digital 8 bit data.
If this color sensor is irradiant with any color, it produces different voltage outputs
to the microcontroller then microcontroller compares the voltages to the different colors and
displays the corresponding light color on LCD.
1.2 AIM:
This project is aimed to design a system to find out the color of the Object by using
color sensor interfaced to Microcontroller.
1 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
1.3 INTRODUCTION OF EMBEDDED SYSTEM:
An embedded system is a system which is going to do a predefined specified task is
the embedded system and is even defined as combination of both software and hardware. A
general-purpose definition of embedded systems is that they are devices used to control,
monitor or assist the operation of equipment, machinery or plant. "Embedded" reflects the
fact that they are an integral part of the system. At the other extreme a general-purpose
computer may be used to control the operation of a large complex processing plant, and its
presence will be obvious.
All embedded systems are including computers or microprocessors. Some of these
computers are however very simple systems as compared with a personal computer.
The very simplest embedded systems are capable of performing only a single function or set
of functions to meet a single predetermined purpose. In more complex systems an
application program that enables the embedded system to be used for a particular purpose in
a specific application determines the functioning of the embedded system. The ability to
have programs means that the same embedded system can be used for a variety of different
purposes. In some cases a microprocessor may be designed in such a way that application
software for a particular purpose can be added to the basic software in a second process,
after which it is not possible to make further changes. The applications software on such
processors is sometimes referred to as firmware.
The simplest devices consist of a single microprocessor (often called a "chip”),
which may itself be packaged with other chips in a hybrid system or Application Specific
Integrated Circuit (ASIC). Its input comes from a detector or sensor and its output goes to a
switc or activator which (for example) may start or stop the operation of a machine or, by
operating a valve, may control the flow of fuel to an engine.
2 DEPARTMENT OF ECE, KGRCET
Software Hardware
ALPCVB Etc.,
ProcessorPeripheralsmemory
Embedded System
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Figure.1: Block diagram of Embedded System
Software deals with the languages like ALP, C, and VB etc., and Hardware deals with
Processors, Peripherals, and Memory.
Memory: It is used to store data or address.
Peripherals: These are the external devices connected
Processor: It is an IC which is used to perform some task
Applications of embedded systems
Manufacturing and process control
Construction industry
Transport
Buildings and premises
Domestic service
Communications
Office systems and mobile equipment
Banking, finance and commercial
Medical diagnostics, monitoring and life support
Testing, monitoring and diagnostic systems
3 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Processors are classified into four types like:
Micro Processor (µp)
Micro controller (µc)
Digital Signal Processor (DSP)
Application Specific Integrated Circuits (ASIC)
Micro Processor (µp):
A silicon chip that contains a CPU. In the world of personal computers, the terms
microprocessor and CPU are used interchangeably. At the heart of all personal computers
and most workstations sits a microprocessor. Microprocessors also control the logic of
almost all digital devices, from clock radios to fuel-injection systems for automobiles.
Three basic characteristics differentiate microprocessors:
Instruction set: The set of instructions that the microprocessor can execute.
Bandwidth : The number of bits processed in a single instruction.
Clock speed : Given in megahertz (MHz), the clock speed determines how many
instructions per second the processor can execute.
Fig.2:Three Basic Elements of a Microprocessor
Micro Controller (µc):
A microcontroller is a small computer on a single integrated circuit containing a processor
core, memory, and programmable input/output peripherals. Program memory in the form
of NOR flash or OTP ROM is also often included on chip, as well as a typically small
amount of RAM. Microcontrollers are designed for embedded applications, in contrast to
the microprocessors used in personal computers or other general purpose applications.
4 DEPARTMENT OF ECE, KGRCET
Timer, Counter, serial communication ROM, ADC, DAC, Timers, USART, Oscillators
Etc.,
ALU
CU
Memory
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Fig.3: Block Diagram of Micro Controller (µc)
Digital Signal Processors (DSPs):Digital Signal Processors is one which performs scientific and mathematical
operation.Digital Signal Processor chips - specialized microprocessors with architectures
designedspecifically for the types of operations required in digital signal processing.
Application Specific Integrated Circuit (ASIC)
ASIC is a combination of digital and analog circuits packed into an IC to achieve the desired
control/computation function
ASIC typically contains
CPU cores for computation and control
Peripherals to control timing critical functions
Memories to store data and program
Analog circuits to provide clocks and interface to the real world which is analog in
nature
I/Os to connect to external components like LEDs, memories, monitors etc.
5 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Memory Architecture
There two different type’s memory architectures there are:
Harvard Architecture
Von-Neumann Architecture
Harvard Architecture
Computers have separate memory areas for program instructions and data. There are
two or more internal data buses, which allow simultaneous access to both
instructions and data. The CPU fetches program instructions on the program
memory bus.
Von-Neumann Architecture
The von Neumann architecture is a design model for a stored-program digital
computer that uses a central processing unit (CPU) and a single separate storage
structure ("memory") to hold both instructions and data. It is named after the
mathematician and early computer scientist John von Neumann. Such computers
implement a universal Turing machine and have a sequential architecture.
Conclusion: Before starting practical the theory helped us understand the working
principal.
6 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 2
OPERATONAL REPRESENTATON
2.1 BLOCK DIAGRAM:
The Power supply of 230v is stepped-down to 12v.Then the 12v is passed through
bridge rectifier which gives a continues DC output.The DC output s fed to the voltage
regulator which is given to the microcontroller.Power for ADC is fetched from voltage
regulator of 5v.Voltage regulator output is connected for LCD also.
7 DEPARTMENT OF ECE, KGRCET
AT89S52
Power Supply
16X2 LCD
ADC 0804/0808
Colored
Specimen
Colored
Specimen
LDR
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
2.2 POWER SUPPLY:
Block diagram:
OPERATION:
The input voltage to the diodes 1 and 2 is supplied from a transformer and is equal
to the peak AC voltage of the secondary winding of the transformer as shown in
graph 1.
The circuit consisting of the combination of the two diodes is called full wave
rectifier.
These diodes combined with a capacitor are known as full wave rectifier with a
capacitor. This capacitor is known as filtering capacitor improves the output of the
rectifier and the efficiency of this rectifier is 81.2%.
The resistor is used to limit the voltage and current those are supplied to the
regulator in order to avoid the regulator from getting damaged.
The diode 3 is used to protect the diodes 1 and 2 from the back current discharged
by the capacitor.
The output at this point is not completely regulated since there is still some amount
of ripple present in the rectified voltage.
Therefore a regulator is used to ensure low voltage ripple and excellent load and line
voltage regulation.
The resistor after the regulator is used to limit the current supplied to the LED.
When the voltage supplied is greater than 3.8V, the LED will glow. The regulated
DC voltage output is taken across the capacitor and is further supplied to other
applications.
8 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 3
CIRCUIT SCHEMATICS
3.1 SCHEMATIC CIRCUIT DIAGRAM:
The following schematic explanation includes the detailed pin connections of every device
with the microcontroller.
9 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
3.2 SYSTEM WORKING:
Fig.4:Working of system
Power Supply:
The main aim of this power supply is to convert the 230V AC into 5V DC in order to give
supply for the TTL or CMOS devices. In this process we are using a step down transformer, a bridge
rectifier, a smoothing circuit and the RPS.
At the primary of the transformer we are giving the 230V AC supply. The secondary is
connected to the opposite terminals of the Bridge rectifier as the input. From other set of opposite
terminals we are taking the output to the rectifier.
The bridge rectifier converts the AC coming from the secondary of the transformer into
pulsating DC. The output of this rectifier is further given to the smoother circuit which is capacitor
10 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
in our project. The smoothing circuit eliminates the ripples from the pulsating DC and gives the
pure DC to the RPS to get a constant output DC voltage. The RPS regulates the voltage as per our
requirement.
LCD module:
This module is used to display the status of the devices.This module consists of 8 data lines
D0 – D7, which are connected to the 8 pins of port1 (P0). Additionally this module is having 3
control lines namely RS, RW and EN, which are connected to the port2 higher pins P2.7, P2.6 and
P2.5 respectively. And the supply connections are given from the Power supply output 7805 to the
VCC and VSS.
Microcontroller:
The microcontroller AT89S52 with Pull up resistors at Port0 and crystal oscillator of 11.0592
MHz crystal in conjunction with couple of capacitors of is placed at 18 th & 19th pins of 89S52 to
make it work (execute) properly.
LED:
All the three LED’s (Red,Green,Blue) are connected in parallel for power.A power
of 5v,an output,ground are connected to the ADC for data processing.
11 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 4
HARDWARE DESCRIPTION
4.1 DESCRIPTION OF MICROCONTROLLER AT89S52:
The AT89S52 is a low-power, high-performance CMOS 8-bit micro controller with
8Kbytes of in-system programmable Flash memory. The device is manufactured Using
Atmel’s high-density non-volatile memory technology and is compatible with the industry-
standard 80C51 micro controller. 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 in-system programmable flash one monolithic chip;
the Atmel AT89S52 is a powerful micro controller, which provides a highly flexible and
cost-effective solution to many embedded control applications.
The AT89S52 provides the following standard features: 8K bytes of Flash, 256
bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters,
full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is
designed with static logic for operation down to zero frequency and supports two software
selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM
timer/counters, serial port, and interrupt system to continue functioning. The Power-down
mode saves the RAM contents but freezes the oscillator.
12 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
4.2 Architecture of 8052:
Fig.5: Architecture of 8052.
13 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
PIN CONFIGURATION & DESCRIPTION OF MICROCONTROLLER AT89S52
Fig.6: Pin configuration of AT89S52
PIN DESCRIPTION OF MICROCONTROLLER AT89S52:
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 1sare 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
14 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
high by the internal pull-ups and can be used as inputs. In addition, P1.0 and P1.1 can be
configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input P1.1/T2EX), respectively, as shown
in the following table. Port 1 also receives the low-order address bytes during Flash
programming and verification.
Table 1: Port 1 functions
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. 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 use 8-bit
addresses (MOVX @ RI), Port 2emits 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. 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 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 writen 1s are written to Port 3 pins,
15 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
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 AT89S52, as shown in the
following table. Port 3 also receives some control signals for Flash programming and
verification.
Table 2: Port 3 functions
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
ALE/PROG:
Address Latch Enable is an output pulse for latching the low byte of the address during access 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/16 the oscillator frequency and may be
used for external timing or clocking purpose. Note, however, that one ALE pulse is skipped during
each access to external Data memory.
PSEN
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to external
data memory.
16 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the device
to fetch code from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. A
should be strapped to VCC for internal program executions. This pin also receives the 12-
voltProgramming enables voltage (VPP) during Flash programming.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2:
Output from the inverting oscillator amplifier.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
that can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz
crystal or ceramic resonator may be used. To drive the device from an External clock
source, XTAL2 should be left unconnected while XTAL1 is driven, as shown.
Special Function Register (SFR) Memory:
Special Function Registers (SFR s) are areas of memory that control specific
functionality of the 8051 processor. For example, four SFRs permit access to the 8051’s 32
input/output lines. Another SFR allows the user to set the serial baud rate, control and
access timers, and configure the 8051’s interrupt system.
The Accumulator:
The Accumulator, as its name suggests is used as a general register to accumulate
the results of a large number of instructions. It can hold 8-bit (1-byte) value and is the most
versatile register.
17 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
The “R” registers:
The “R” registers are a set of eight registers that are named R0, R1. Etc up to R7.
These registers are used as auxiliary registers in many operations.
The “B” registers:
The “B” register is very similar to the accumulator in the sense that it may hold an
8-bit (1-byte) value. Two only uses the “B” register 8051 instructions: MUL AB and DIV
AB.
The Data Pointer:
The Data pointer (DPTR) is the 8051’s only user accessible 16-bit (2Bytes)
register. The accumulator, “R” registers are all 1-Byte values. DPTR, as the name suggests,
is used to point to data. It is used by a number of commands, which allow the 8051 to
access external memory.
THE PROGRAM COUNTER AND STACK POINTER:
The program counter (PC) is a 2-byte address, which tells the 8051 where the next
instruction to execute is found in memory. The stack pointer like all registers except DPTR
and PC may hold an 8-bit (1-Byte) value.
ADDRESSING MODES:
An “addressing mode” refers that you are addressing a given memory location. In
summary, the addressing modes are as follows, with an example of each:
Each of these addressing modes provides important flexibility.
Immediate Addressing MOV A, #20 H
Direct Addressing MOV A, 30 H
Indirect Addressing MOV A, @R0
Indexed Addressing
18 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
a.External Direct MOVX A, @DPTR
b.Code In direct MOVC A, @A+DPTR
Timer 2 Registers:
Control and status bits are contained in registers T2CON and T2MOD for
Timer 2. The register pair (RCAP2H , RCAP2L) are the Capture / Reload registers for
Timer 2 in 16-bit capture mode or 16-bit auto-reload mode .
Interrupt Registers:
The individual interrupt enable bits are in the IE register . Two priorities can
be set for each of the six interrupt sources in the IP register.
Sy
mbol
Posit
ion
Function
EA
IE.7 Disables all interrupts.if EA=C.no interrupt is
acknowledged.if EA=1.each interrupt source is
individually enabled or desabled by setting or clearing
its erasable bit.
-- IE.6 Reserved.12
ET2 IE.5 Timer 2 interrupt enable bit.
ES IE.4 Serial port interrupt enable bit.
ET IE.3 Timer 1 interrupt enable bit.
EX1 IE.2 External interrupt 1 enable bit.
ET0 IE.1 Timer 0 interrupt enable bit.
EX0 IE.0 External interrupt 0 enable bit.
19 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Table 3: Interrupt registers functions
Timer 2:
Timer 2 is a 16-bit Timer / Counter that can operate as either a timer or an
event counter. The type of operation is selected by bit C/T2 in.
The SFR T2CON. Timer 2 has three operating Modes : capture , auto-reload
( up or down Counting ) , and baud rate generator . The modes are selected by bits in
T2CON. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the
TL2 register is incremented every machine cycle. Since a machine cycle consists of 12
oscillator periods, the count rate is 1/12 of the oscillator frequency. In the Counter
function , the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin , T2 .When the samples show a high in one cycle
and a low in the next cycle, the count is incremented . Since two machine cycles (24
Oscillator periods ) are required to recognize 1-to-0 transition , the maximum count
rate is 1 / 24 of the oscillator frequency .
20 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
TCON REGISTER:
Table 4: Timer/counter Control Register
21 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
TMOD REGISTER:
7 6 5 4 3 2 1 0
GATE1 C/T1# M11 M01 GATE0 C/T0# M10 M00
Bit
numbe
r
Bit
Mnemonic
Description
7 GATE1 Timer 1 gating control BitClear to enable timer 1 whenever the TR1 bit is set.Set to enable timer 1 only while the INT1# pin is high and TR1 bit is set.
6 C/T1# Timer 1 Counter/Timer select bitClear for timer operation:timer 1 counts the divide-down system clock.Select Counter operation:timer 1 counts negative transitions on external pin l 1.
5 M11 Timer 1 Mode Select Bits.
4 M01 M11 M01 Operating mode 0 0 mode 0:8-bit timer/counter (TH1) with 6-bit proscalar(TL1). 0 1 mode 1:16-bit timer/counter. 1 0 mode 2:8-bit auto-reload timer/counter (TL1).Reloaded from TH1 at overflow. 1 1 mode 3:timer 1 halted.Routine count.
3 GATE0 Timer 0 Gating Control BitClear to enable timer 0 whenever the TR0 bit is set.Set to enable timer/counter 0 only while the INT0#pin is high and the TR0 bit is set.
2 C/T0# Timer 0 counter/timer select BitClear Timer operation:timer 0 counts the divided-down system clock.Set for counter operation:timer 0 counts negative transitions on external pin T0.
1 M10 Timer 0Mode select Bit
22 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
0 M00 M11 M01 Operating mode 0 0 mode 0:8-bit timer/counter (TH0) with 6-bit proscalar(TL0). 0 1 mode 1:16-bit timer/counter. 1 0 mode 2:8-bit auto-reload timer/counter (TL0).Reloaded from TH0 at overflow. 1 1 mode 3:TL0 is an 8-bit timer/counter. TH0 is an 8-bit timer using timer 1’s TR0 and TF0 bits.
Table 5: Timer/Counter 0 and 1 Modes
4.3 ANALOG TO DIGITAL CONVERTER – ADC
Analog to digital converters are among the most widely used devices for data
acquisition. Digital computers use binary values, but in physical world everything is analog.
Temperature, pressure, humidity, are a few examples of physical quantities that we deal
with everyday. A physical quantity is converted to electrical signals using a device called a
transducer. Transducers are also referred to as sensors. Sensors for temperature, velocity,
pressure, light, and many other natural quantities produce an output that is voltage(or
current). Therefore, we need an analog to digital converter to translate analog signals to
digital numbers so that microcontroller can read and process them. An ADC has n-bit
resolution where n can be 8,10,12,16 or even 24 bits. The higher resolution ADC provides
smaller step size, where step size is the smallest change that can be discerned by an ADC.
In addition to resolution, converter time is another major factor in judging an ADC.
Conversion time is defined as the time it takes the ADC to convert the analog input to
digital number.Commonly used ADC device – ADC804.
ADC0804 CHIP:
The ADC0804 IC is an 8 bit parallel ADC in the family of the ADC0800
series. In ADC0804, the conversion time varies depending on the clocking signals applied
to the CLK IN pin, but it can not be faster than 110micro seconds.
Pin diagram:
23 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Fig 7: ADC Pin diagram
• CS – Chip Select , active low
• RD – Read Digital data from ADC, H-L edge triggered
• WR -- Start conversion, L-H pulse edge triggered
• INTR -- end of conversion, Goes low to indicate conversion done
• Data bits -- D0-D7
• CLK IN & CLK R
– CLK IN is an input pin connected to an external clock source when an external clock is
used for timing. However, ADC804 has an internal clock
generator.
To use the internal clock generator of the ADC804, the CLK IN and CLK R pins are
connected to a capacitor and a resistor. In that case, the
clock frequency is determined by the equation.
f = 1/1.1RC
R=10K and C=150pF f=606Hz
the conversion time is 110us.
Input Voltage range
• Default 0-5V. Can be changed by setting different value for Vref/2 pin.
Vin=Vin(+) – Vin (-)
• Range = 0 to 2x Vref/2.
for Vin = 2x Vref/2. we get 256 as a digital output on D0-D7. (Refer Table)
•Step Size is a Smallest change
– (2 x Vref/2)/ 256 for ADC804
24 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
for eg for step size 10mv ,digital output on D0-D7 changes by one count for every 10mv
change of the input analog voltage.
Data out
Dout = Vin / Step Size
for input vtg. of 2.56 volts (Vref=1.28 volts) and stepsize of 10mv Dout =2560/10 =256 or
FF that is full scale output.
4.4 INTERFACING ADC804 TO 8052 MCRO CONTROLLER
Signals to be interfaced (on the ADC804)
D0-D7, RD, WR, INTR, CS
Can do both Memory mapping and IO mapping
Memory Mapping (timing is critical)
Connect D0-D7 of ADC804 to the data bus of the 8051 system
Connect RD, WR of the ADC804 to the 8051 system (ensure polarity)
Connect CS of ADC804 to an appropriate address decoder output
Connect INTR of ADC804 to an external interrupt Pin on the 8051 (INT0 or INT1)
IO Mapping (easiest - I prefer )
Connect D0-D7, RD, WR, CS, INTR to some port bits on the 8051 (12 in all).
Algorithm
Make CS=0 and send a low-to-high to pin WR to start the conversion.
Keep monitoring INTR
If INTR =0, the conversion is finished and we can go to the next step.
If INTR=1, keep polling until it goes low.
After INTR=0, we make CS=0 and send a high-to-low pulse to RD to get the data out of
the ADC804 chat
25 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
4.5 LCD DISPLAY (LIQUID CRYSTAL DISPLAY):
A liquid-crystal display (LCD) is a flat panel display, electronic visual display, or
video display that uses the light modulating properties of liquid crystals. Liquid crystals do
not emit light directly.
LCDs are available to display arbitrary images (as in a general-purpose computer
display) or fixed images which can be displayed or hidden, such as preset words, digits, and
7-segment displays as in a digital clock. They use the same basic technology, except that
arbitrary images are made up of a large number of small pixels, while other displays have
larger elements.
LCDs are used in a wide range of applications including computer monitors,
televisions, instrument panels, aircraft cockpit displays, and signage. They are common in
consumer devices such as video players, gaming devices, clocks, watches, calculators, and
telephones, and have replaced cathode ray tube (CRT) displays in most applications. They
are available in a wider range of screen sizes than CRT and plasma displays, and since they
do not use phosphors, they do not suffer image burn-in. LCDs are, however, susceptible to
image persistence.[1]
The LCD screen is more energy efficient and can be disposed of more safely than a
CRT. Its low electrical power consumption enables it to be used in battery-powered
electronic equipment. It is an electronically modulated optical device made up of any
number of segments filled with liquid crystals and arrayed in front of a light source
(backlight) or reflector to produce images in color or monochrome. Liquid crystals were
first discovered in 1888.[2] By 2008, worldwide sales of televisions with LCD screens
exceeded annual sales of CRT units; the CRT became obsolete for most purposes.
LCD is finding wide spread use replacing LEDs because of the following reasons
The declining prices of LCDs.
The ability to display numbers, characters and graphics. This is in contrast to LEDs,
which are limited to numbers and a few characters.
Ease of programming for characters and graphics.
26 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
These components are “specialized” for being used with the microcontrollers,
which means they cannot be activated by standard IC circuits. They are used for writing
different messages on a miniature LCD.
Fig 8: LCD display screen
Advantages Very compact and light.
Low power consumption. Depending on the set display brightness and content being
displayed, the older CCFT backlit models typically use 30–50% of the power a CRT
monitor of the same size viewing area would use, and the modern LED backlit
models typically use 10–25% of the power a CRT monitor would use.
Very little heat emitted during operation, due to low power consumption.
No geometric distortion.
The possible ability to have little or no flicker depending on backlight technology.
Usually no refresh-rate flicker, because the LCD pixels hold their state between
refreshes (which are usually done at 200 Hz or faster, regardless of the input refresh
rate).
Is very thin compared to a CRT monitor, which allows the monitor to be placed
farther back from the user, reducing close-focusing related eye-strain.
Razor sharp image with no bleeding/smearing when operated at native resolution.
27 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Features:
Interface with either 4-bit or 8-bit microprocessor.
Display data RAM
80xx8 bits (80 characters).
Character generator ROM
160 different 5x7 dot-matrix character patterns.
Character generator RAM
8 different user programmed 5x7 dot-matrix patterns.
Display data RAM and character generator RAM may be
Accessed by the microprocessor.
Numerous instructions
Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,
Blink Character, Cursor Shift, Display Shift.
Built-in reset circuit is triggered at power ON.
Built-in oscillator.
Description Of 16x2:
This is the first interfacing example for the Parallel Port. We will start with
something simple. This example doesn't use the Bi-directional feature found on
newer ports, thus it should work with most, if no all Parallel Ports. It however
doesn't show the use of the Status Port as an input. So what are we interfacing? A 16
Character x 2 Line LCD Module to the Parallel Port. These LCD Modules are very
common these days, and are quite simple to work with, as all the logic required to
run them is on board
28 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Schematic Diagram:
fig 9:LCD schematic diagram
The 2 line x 16 character LCD modules are available from a wide range of manufacturers and should all be compatible with the HD44780. The one I used to test this circuit was a Power tip PC-1602F and an old Philips LTN211F-10 which was extracted from a Poker Machine! The diagram to the right, shows the pin numbers for these devices. When viewed from the front, the left pin is pin 14 and the right pin is pin 1
16 x 2 Alphanumeric LCD Module Features:
Intelligent, with built-in Hitachi HD44780 compatible LCD controller and RAM
providing simple interfacing
61 x 15.8 mm viewing area
5 x 7 dot matrix format for 2.96 x 5.56 mm characters, plus cursor line
Can display 224 different symbols
Low power consumption (1 mA typical)
29 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Powerful command set and user-produced characters
TTL and CMOS compatible
Connector for standard 0.1-pitch pin headers
Power supply for LCD driving:
Fig 10: power supply for LCD
PIN DESCRIPTION:
Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins
are extra in both for back-light LED connections).
Fig 11:pin diagram of 1x16 lines LCD
30 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Table 6: LCD Pin specifications
4.6 CONTROL LINES:
EN:
Line is called "Enable." This control line is used to tell the LCD that you are sending
it data. To send data to the LCD, your program should make sure this line is low (0) and
then set the other two control lines and/or put data on the data bus. When the other lines are
completely ready, bring EN high (1) and wait for the minimum amount of time required by
the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.
RS:
Line is the "Register Select" line. When RS is low (0), the data is to be treated as a
command or special instruction (such as clear screen, position cursor, etc.). When RS is
high (1), the data being sent is text data which sould be displayed on the screen. For
example, to display the letter "T" on the screen you would set RS high.
RW:
Line is the "Read/Write" control line. When RW is low (0), the information on the
data bus is being written to the LCD. When RW is high (1), the program is effectively
31 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command.
All others are write commands, so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation
selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1,
DB2, DB3, DB4, DB5, DB6, and DB7.
Logic status on control lines:
E - 0 Access to LCD disabled
1 Access to LCD enabled
R/W - 0 Writing data to LCD
1 Reading data from LCD
RS - 0 Instructions
1 Character
Writing data to the LCD:
Set R/W bit to low
Set RS bit to logic 0 or 1 (instruction or character)
Set data to data lines (if it is writing)
Set E line to high
Set E line to low
Read data from data lines (if it is reading) on LCD:
Set R/W bit to high
Set RS bit to logic 0 or 1 (instruction or character)
Set data to data lines (if it is writing)
Set E line to high
Set E line to low
32 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
FLOWCHART:
Fig 12: flow chart of LCD.
4.7 Light Dependent Resistor
A photoresistor or light dependent resistor or cadmium sulfide (CdS) cell is
a resistor whose resistance decreases with increasing incident light intensity. It can also be
referred to as a photoconductor.
A photo resistor is made of a high resistance semiconductor. If light falling on the
device is of high enough frequency, photons absorbed by the semiconductor give
bound electrons enough energy to jump into the conduction band. The resulting free
electron (and its hole partner) conduct electricity, there by lowering resistance.
33 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
A photoelectric device can be either intrinsic or extrinsic. An intrinsic
semiconductor has its own charge carriers and is not an efficient semiconductor, e.g. silicon.
In intrinsic devices the only available electrons are in the valence band, and hence the
photon must have enough energy to excite the electron across the entire bandgap. Extrinsic
devices have impurities, also called dopants, added whose ground state energy is closer to
the conduction band; since the electrons do not have as far to jump, lower energy photons
(i.e., longer wavelengths and lower frequencies) are sufficient to trigger the device. If a
sample of silicon has some of its atoms replaced by phosphorus atoms (impurities), there
will be extra electrons
available for conduction. This is an example of an extrinsic semiconductor.
The symbol for a photoresistor
Applications:
Photoresistors come in many different types. Inexpensive cadmium sulfide cells can
be found in many consumer items such as camera light meters, street lights, clock
radios, alarms, and outdoor clocks.
They are also used in some dynamic compressors together with a small incandescent
lamp or light emitting diode to control gain reduction.
Lead sulfide (PbS) and indium antimonide (InSb) LDRs (light dependent resistor)
are used for the mid infrared spectral region. Ge:Cu photoconductors are among the best
far-infrared detectors available, and are used for infrared astronomy and infrared
spectroscopy.
Fig 13: LDR
34 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
A light dependent resistor is a small, round semiconductor. Light dependent resistors
are used to re-charge a light during different changes in the light, or they are made to turn a
light on during certain changes in lights. One of the most common uses for light dependent
resistors is in traffic lights. The light dependent resistor controls a built in heater inside the
traffic light, and causes it to recharge over night so that the light never dies. Other common
places to find light dependent resistors are in: infrared detectors, clocks and security alarms.
LDRs or Light Dependent Resistors are very useful especially in light/dark sensor
circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000 000
ohms, but when they are illuminated with light resistance drops dramatically.
The animation opposite shows that when the torch is turned on, the resistance of the LDR
falls, allowing current to pass through it.
Circuit Wizard software has been used to display, the range of values of a
ORP12,LDR .
When a light level of 1000 lux (bright light) is directed towards it, the resistanceis
400R(ohms).
When a light level of 10 lux (very low light level) is directed towards it, the resistance has
risen dramatically to 10.43M (10430000 ohms).
Basic structure:
Although there are many ways in which LDR’s or photo resistors can be
manufactured, ther are naturally a few more common methods that are seen. Essentially the
LDR or photo resistor consists of a resistive material sensitive to light that is
exposed to light. The photo resistive element comprises section of material with contacts at
either end. Although many of the material used for light dependent resistors are
semiconductors, when used as photo resistors, they are used only as a resistive element and
there are no p-n junctions. Accordingly the devices purely passive.
Operation:
Light Dependent Resistor made of a high resistance semiconductor, if light falling on
the is of high enough efficiently, photon absorbed by the semiconductor give bound
electrons enough energy to jump into the conduction band. The resulting free electron (and
its hole partner) conduct electricity, thereby lowering resistance.
35 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
In intrinsic devices, the only available electrons are in the valence band, and hence
the photon must have enough energy to excite the electrons across the entire band gap.
Extrinsic devices have impurities added , which have a ground state energy closer to the
conduction band, since the electrons don’t have so far to jump, lower energy photons ( i.e.
longer wavelengths and lower frequencies ) will suffice to trigger the device.
Characteristics of LDR:
The characteristics of LDR are shown below. Here the resistance variations are
shown as a function of illumination. The resistance of LDR decreases with increasing
incident light intensity
10
1.0
0.1
0.1 1.0 10 100
( Ftc )*
*1 Ftc = 10.764 lumens
Fig 14: LDR characteristics.
LDR Applications:
LDR’s are very useful especially in light/dark sensor circuits
1. Camera light meters.
2. Clock radios.
36 DEPARTMENT OF ECE, KGRCET
1000
100
Res.
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 5
SOFTWARE DESCRIPTION
5.1 KEIL µVISION3 Software:
µVISION3 Overview:
The µVision3 IDE is a windows based software development platform that combines
a robust editor, project manager, and integrated make facility. µVision3 integrates all tools
including the C compiler, macro assembler, linker/locator, and HEX file generator.
µVision3 helps expedite the development process of our embedded applications by
providing the following:
Full-featured source code editor.
Device database for configuring the development tool setting.
Project manager for creating and maintaining our projects.
Integrated make facility for assembling, compiling, and linking our embedded
applications.
Dialogs for all development tool settings.
True integrated source level Debugger with high-speed CPU and peripheral
simulator.
Advanced GDI interface for software debugging in the target hardware and for
connection to Keil ULINK.
Flash programming utility for downloading the application program into Flash
ROM.
Links to development tools manuals, device datasheets and user’s guides.
In the Build Mode, we maintain the project files and generate the application. In the
Debug Mode, we verify our program either with a powerful CPU and peripheral simulator
or with the Keil ULINK USB-JTAG Adapter (or other AGDI drivers) that connect the
37 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
debugger to the target system. The ULINK allows us also to download our application into
Flash ROM of our target system.
Environment :
The µVision3 screen provides us with a menu bar for command entry, a tool bar where we
can rapidly select command buttons, and windows for source files, dialog boxes, and information
displays. µVision3 lets us simultaneously open and view multiple source files.
µVision3 has two operating modes:
Build Mode:
Allows us to translate all the application files and to generate executable programs. The
features of the Build Mode are described under Creating Applications.
Debug Mode:
Provides us with a powerful debugger for testing our application. The Debug Mode is
described in Testing Programs.
In both operating modes we may use the source editor of µVision3 to modify our source
code. The Debug mode adds additional windows and stores an own screen layout.
Figure 15 : Debug mode command window
The tabs of the Project Workspace give us access to:
38 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Files and Groups of the project.
CPU Registers during debugging.
Tool and project specific on-line Books.
Text Templates for often used text blocks.
Function in the project for quick editor navigation.
The tabs of the Output Window provides: Build messages and fast error access;
Debug Command input/output console; Find in Files results with quick file access.
The Memory Window gives access to the memory areas in display various formats.
The Watch and Call Stack Window allow us to review and modify program variables
and display the current function call tree.
The Workspace is used for the file editing, disassembly output, and other debug
information.
The Peripheral Dialogs help us to review the status of the on-chip.
Software development Lifecycle :
When you use the Keil µVision3, the project development cycle is roughly the same as it is for
any other software development project.
Create a project, select the target chip from the device database, and configure the tool
settings.
Create source files in C or assembly.
Build our application with the project manager.
Correct errors in source files.
Test the linked application.
39 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
Create a project:
µVision3 includes a project manager which makes it easy to design applications for
an ARM based microcontroller. We need to perform the following steps to create a new
project:
Create Project file and Select CPU
Project Workspace-Books
Create New Source Files
Add Source Files to the Project
Create Files Groups
Set tool Options for Target Hardware
Configure the CPU Start-up Code
Build Project and Generate Application Program Code
Description:
Add Source Files to Project:
Once we have created our source file we can add this file to our project. µVision3 offers
several ways to add source files to a project. For example, we can select the file group in the
Project Workspace — Files page and click with the right mouse key to open a local menu. The
option Add Files opens the standard files dialog. Select the file MAIN.C we have just created.
Simulation:
The µVision3 Debugger incorporates a C script language you can use to create
Signal Functions. Signal functions let us simulate analog and digital input to the
microcontroller. Signal functions run in the background while µVision3 simulates our target
program.
5.2 Program
40 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
#include<reg51.h>
#define lcd_data P2
sbit lcd_rs = P2^0;
sbit lcd_en = P2^1;
sbit rd=P3^2;
sbit wr=P3^3;
sbit intr=P3^4;
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char value) // LCD COMMAND
{
lcd_data=value&(0xf0); //send msb 4 bits
lcd_rs=0; //select command register
lcd_en=1; //enable the lcd to execute command
delay(3);
lcd_en=0;
lcd_data=((value<<4)&(0xf0)); //send lsb 4 bits
lcd_rs=0; //select command register
lcd_en=1; //enable the lcd to execute command
delay(3);
lcd_en=0;
}
void lcd_init(void)
41 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
{
lcdcmd(0x02);
lcdcmd(0x02);
lcdcmd(0x28); //intialise the lcd in 4 bit mode*/
lcdcmd(0x28); //intialise the lcd in 4 bit mode*/
lcdcmd(0x0e); //cursor blinking
lcdcmd(0x06); //move the cursor to right side
lcdcmd(0x01); //clear the lcd
}
void lcddata(unsigned char value)
{
lcd_data=value&(0xf0); //send msb 4 bits
lcd_rs=1; //select data register
lcd_en=1; //enable the lcd to execute data
delay(3);
lcd_en=0;
lcd_data=((value<<4)&(0xf0)); //send lsb 4 bits
lcd_rs=1; //select data register
lcd_en=1; //enable the lcd to execute data
delay(3);
lcd_en=0;
delay(3);
}
void msgdisplay(unsigned char b) // send string to lcd
{
unsigned char s,count1=0;
for(s=0;b[s]!='\0';s++)
{
42 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
count1++;
if(s==16)
lcdcmd(0xc0);
if(s==32)
{
lcdcmd(1);
count1=0;
}
lcddata(b[s]);
}
}
void main()
{
unsigned char a;
lcd_init();
lcdcmd(0x80);
msgdisplay("ELECTRONIC EYE") ;
delay(400);
lcdcmd(0xc0);
msgdisplay("COLOR:");//0X85
intr=1;
rd=1;
wr=1;
while(1)
{
wr=0;
43 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
wr=1;
while(intr==1);
rd=0;
a=P1;
rd=1;
if(a>= && a< )
{
lcdcmd(0xc6);
msgdisplay("");
}
if(a>= && a< )
{
lcdcmd(0xc6);
msgdisplay("");
}
if(a>= && a< )
{
lcdcmd(0xc6);
msgdisplay("");
}
}
}
5.3 Conclusion: By changing the values in the while loop there is a change in the color.The values thus obtained was random and depends on ADC which gives different values for different colours depending on the intensity values of light.
44 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 6
CONCLUSION AND FUTURE SCOPE
6.1 CONCLUSION:
This project presents electronic eye based automation controlling. The controller based on closed loop algorithm is designed and implemented with Atmel MCU in embedded system the domain.
Experimental work has been carried out carefully. with the help of 8052 controller.In all low end applications now a days we are using 8052 controllers like industrial automation and data acquisition.
All the inherent parts of the circuit performed consistently. It helped us to come out with good judgment. With the features what it inherits, it seems to be advantageous to the present era.
6.2 SCOPE OF THE PROJECT:
We can modify this project by replacing LDR sensor with photo camera which is
then image processed for better purpose in future So future scope of this project is ever
lasting and it depends on public need.
45 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
CHAPTER 7
RESULT
The outcome of this project was as expected. The different inputs given to the device gave predicted outputs.And siginificantly other than colored objects were also detected. The received data is displayed on the LCD panel. The LCD panel was very impressive with its emitting ability, it displayed the data very precisely.
LDR’s are very useful especially in light/dark sensor circuits. Normally the
resistance of LDR is very high, sometimes as high as 1000k ohms,but when they are
illuminated with light, resistance drops immediately.The following are some of the major
applications.
1. Camera light meters.
2. Clock radios.
3. Security alarms.
4. Optical switches.
5. Far infrared detector.
6. Streetlights.
The future would be completely automated sytems.This project is majorly used in Textile industries for power looms and Robotics in a wide range.This Project is very cheap and accurate automation system .
46 DEPARTMENT OF ECE, KGRCET
ELECTRONIC EYE FOR SENSING MULTI-COLOURS
BIBILOGRAPHY
Books Referred:
Muhammad Ali Mazidi - The 8051 Micro controller and Embedded systems.
B.Ram - Fundamentals of Micro processors and Micro computers.
Ramesh S.Gaonkar- Micro processor Architecture, Programming& Applications.
D.V.Prasad- Electronic components.
Websites Referred:
www.national.com www.atmel.com www.electronicsforu.com www.futurelec.com
47 DEPARTMENT OF ECE, KGRCET