Digital Object Counter Using Microcontroller
Digital Object Counter Using Microcontroller
Digital Object Counter Using Microcontroller
1.2 Aim of the Project 1. The Basic aim of the project is to count the number of objects.
2. To design an efficient model with low cost.
DEPT OF E.C.E
Page 1
POWER SUPPLY
OSCILLATOR
9
DISPLAY
IR SENSORS
1
RESET
DEPT OF E.C.E
Page 2
Description of Blocks:
Power Supply: The input to the system is 230v AC; the power supply section converts the input to required DC voltage and distributes to the other parts of the circuit. Oscillator: The oscillator circuit is used to provide micro controller IC with a working clock frequency. Reset: This part is used to reset the micro controller IC Sensor: The heart of the project is the sensor which senses the income of a object and sends a signal to the microcontroller. Controller: It also plays a major role in checking the signal. When ever the sensor gives a signal, the controller gets the signal and increments the counter according to the function assigned to it. LCD display: This is used to display the count for the number of objects.
obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.
Transformer:
Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level.
Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification.
DEPT OF E.C.E
Page 4
Filter:
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage.
Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12 represent the required output voltage levels. A variable regulated power supply, also called a variable bench power supply, is one where you can continuously adjust the output voltage to your requirements. Varying the output of the power supply is the recommended way to test a project after having double checked parts placement against circuit drawings and the parts placement guide. This type of regulation is ideal for having a simple variable bench power supply. Actually this is quite important because one of the first projects a hobbyist should undertake is the construction of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's much handier to have a variable supply on hand, especially for testing.
Figure 2.3 : Pins of Voltage Regulator Most digital logic circuits and processors need a 5-volt power supply. To use these parts we need to build a regulated 5-volt source. Usually you start with an unregulated power supply
DEPT OF E.C.E
Page 5
ranging from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and the Microcontroller Beginner Kit.). To make a 5 volt power supply, we use a LM7805 voltage regulator IC (Integrated Circuit). The IC is shown above.
Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA
Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot
Circuit complexity: Very simple and easy to build Circuit performance: Very stable +5V output voltage, reliable operation Availability of components: Easy to get, uses only very common basic components Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects
Applications: Part of electronics devices, small laboratory power supply Power supply voltage: Unregulated DC 8-18V power supply Power supply current: Needed output current + 5 mA Component costs: Few dollars for the electronics components + the input transformer cost.
DEPT OF E.C.E
Page 6
Figure 2.4: Circuit Diagram of Power Supply This 5V dc acts as Vcc to the microcontroller. The excess voltage is dissipated as heat via an Aluminum heat sink attached to the voltage regulator.
Bridge Rectifier:
A diode bridge is an arrangement of four diodes connected in a bridge circuit as shown below, that provides the same polarity of output voltage for any polarity of the input voltage. When used in its most common application, for conversion of alternating current (AC) input into direct current (DC) output, it is known as a bridge rectifier. The diagram describes a diodebridge design known as a full-wave rectifier. This design can be used to rectify single phase AC when no transformer center tap is available. A bridge rectifier makes use of four diodes in a bridge arrangement 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.
DEPT OF E.C.E
Page 7
Features:
Output Current up to 1A
Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection
Description: The MC7805 three terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents.
An embedded system is a special purpose computing system designed to perform one or a few dedicated functions, often with real time computing constraints. It is usually embedded as a part of a complete device including hardware and software. In contrast, a general purpose computer, such as a personal computer can do many different tasks depending on programming. Embedded systems have become very important today as they control many of the common devices we use. Many embedded systems have substantially different design constraints spectrum than of
embedded systems. However, some combination of cost pressure, long life-cycle, real time requirements, reliability requirements and design function dis-culture can make it difficult to be successful applying traditional computer systems methodologies and tools to embedded applications. Embedded systems in many cases must be optimized for lifecycle and business driven factors rather than for maximum computing throughput. There is currently little tool support for expanding embedded computer design to the scope of holistic embedded system design. However, knowing the strengths and weaknesses of current approaches can set expectations appropriately, identify risk areas to tool adopters and suggest ways in which tool builders can meet industrial needs. Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the cost of the product or increasing the reliability and performance. Some embedded systems are mass produced and thus benefit from economies of scale.
Software often has a fixed function and is specific to the application. Instead of executing spreadsheets, word processing and engineering analysis. Embedded systems typically execute control laws, finite state machines and signal processing algorithms.
2.4.2. Features:
1. 128KB on chip program memory. 2. 128 bytes on chip data memory (RAM). 3. 4 reg banks.
DEPT OF E.C.E
Page 10
4. 128 user defined software flags. 5. 8-bit data bus 6. 16-bit address bus 7. 32 general purpose registers each of 8 bits 8. 16 bit timers (usually 2, but may have more, or less). 9. 3 internal and 2 external interrupts. 10. Bit as well as byte addressable RAM area of 16 bytes. 11. Four 8-bit ports, (short models have two 8-bit ports). 12. 16-bit program counter and data pointer. 13. 1 Microsecond instruction cycle with 12 MHz Crystal.
Typical applications:
8051 chips are used in a wide variety of control systems, telecom applications, robotics as well as in the automotive industry. By some estimation, 8051 family chips make up over 50% of the embedded chip market.
DEPT OF E.C.E
Page 11
DEPT OF E.C.E
Page 12
Figure 2.8 : Crystal connection XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on chip oscillator. 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 in Figure. Pins 40 and 20: Pins 40 and 20 are VCC and ground respectively. The 8051 chip needs +5V 500mA to function properly, although there are lower powered versions like the Atmel 2051 which is a scaled down version of the 8051 which runs on +3V.
Program Store Enable (PSEN) 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. Pin 31- EA/VPP: External Access Enable. EA must be strapped to GND in order to enable the device to fetch Code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. PORTS: There are 4 8-bit ports: P0, P1, P2 and P3. Port P1 (Pins 1 to 8): The port P1 is a general purpose input/output port which can be used for a variety of interfacing tasks. The other ports P0, P2 and P3 have dual roles or additional functions associated with them based upon the context of their usage. The port 1 output buffers can sink/source four TTL inputs. When 1s are written to portn1 pins are pulled high by the internal pull-ups and can be used as inputs.
Port Pin Alternate Functions Port Pin P1.0 P1.1 P1.5 P1.6 P1.7
DEPT OF E.C.E
Alternate Functions T2(external count to Timer/Counter 2), clock-out T2EX(Timer/Counter 2 capture/reload trigger and direction control) MOSI (used for In-System Programming) MISO(used for In-System Programming) SCK(used for In-System Programming)
Page 14
Port P3 (Pins 10 to 17): PORT P3 acts as a normal IO port, but Port P3 has additional functions such as, serial transmit and receive pins, 2 external interrupt pins, 2 external counter inputs, read and write pins for memory access.
Port Pin Alternate Functions: Port Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 Alternate Functions RXD (serial Input port) TXD (serial output port) INT0 bar (external Interrupt 0) INT1 bar (external Interrupt 1) T0 (timer 0 external Input) T1 (timer 1 external input) WR bar (external data memory write strobe) RD bar (external data memory read strobe)
Table 2.2 : Port 3 Pin alternate Function Port P2 (pins 21 to 28): PORT P2 can also be used as a general purpose 8 bit port when no external memory is present, but if external memory access is required then PORT P2 will act as an address bus in conjunction with PORT P0 to access external memory. PORT P2 acts as A8-A15.
DEPT OF E.C.E Page 15
Port P0 (pins 32 to 39): PORT P0 can be used as a general purpose 8 bit port when no external memory is present, but if external memory access is required then PORT P0 acts as a multiplexed address and data bus that can be used to access external memory in conjunction with PORT P2. P0 acts as AD0-AD7. Oscillator: An Electronic device, that generates oscillations (Signals), is called an oscillator. Simply says an oscillator receives DC energy and converts it into AC energy of desired frequency. The frequency of oscillations depends up on the constants of the device. Oscillators are extensively used in electronic equipments. Oscillator CircuitsThe 8051 requires an external oscillator circuit. The oscillator circuit usually runs around 12MHz, although the 8051 (depending on which specific model) is capable of running at a maximum of 40MHz. Each machine cycle in the 8051 is 12 clock cycles, giving an effective cycle rate at 1MHz (for a 12MHz clock) to 3.33MHz (for the maximum 40MHz clock). The oscillator circuit generates the clock pulses so that all internal operations are synchronized
DEPT OF E.C.E
Page 16
Figure 2.9 : Internal architecture of 8051 2.4.6 Data and Program Memory:
The 8051 Microcontroller can be programmed in PL/M, 8051 Assembly, C and a number of other high-level languages. Many compilers even have support for compiling C++ for an 8051.Program memory in the 8051 is read-only, while the data memory is considered to be read/write accessible. When stored on EEPROM or Flash, the program memory can be rewritten when the micro controller is in the special programmer circuit. Program Start Address
DEPT OF E.C.E Page 17
The 8051 starts executing program instructions from address 0000 in the program memory. The A register is located in the SFR memory location 0xE0. The A register works in a similar fashion to the AX register of x86 processors. The A register is called the accumulator, and by default it receives the result of all arithmetic operations.
DEPT OF E.C.E
Page 18
A and B Registers:
The A register is located in the SFR memory location 0xE0. The A register works in a similar fashion to the AX register of x86 processors. The A register is called the accumulator, and by default it receives the result of all arithmetic operations. The B register is used in a similar manner, except that it can receive the extended answers from the multiply and divide operations. When not being used for multiplication and Division, the B register is available as an extra general-purpose register.
DEPT OF E.C.E
Page 19
P - Parity bit. If a number stored in the accumulator is even then this bit will be automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via serial communication. - Bit 1. This bit is intended to be used in the future versions of microcontrollers. OV Overflow occurs when the result of an arithmetical operation is larger than 255 and cannot be stored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared (0). RS0, RS1 - Register bank select bits. These two bits are used to select one of four register banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of RAM.
DEPT OF E.C.E
Page 20
DEPT OF E.C.E
Page 21
If neither external memory nor serial communication system are used then 4 ports with in total of 32 input/output pins are available for connection to peripheral environment. Each bit within these ports affects the state and performance of appropriate pin of the microcontroller. Thus, bit logic state is reflected on appropriate pin as a voltage (0 or 5 V) and vice versa, voltage on a pin reflects the state of appropriate port bit. As mentioned, port bit state affects performance of port pins, i.e. whether they will be configured as inputs or outputs. If a bit is cleared (0), the appropriate pin will be configured as an output, while if it is set (1), the appropriate pin will be configured as an input. Upon reset and power-on, all port bits are set (1), which means that all appropriate pins will be configured as inputs.
DEPT OF E.C.E
Page 22
Figure 2.17 : Timer T0 TMOD Register (Timer Mode): The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to the timer 1.
Figure 2.18 : TMOD Register GATE1 enables and disables Timer 1 by means of a signal brought to the INT1 pin (P3.3):
o o
1 - Timer 1 operates only if the INT1 bit is set. 0 - Timer 1 operates regardless of the logic state of the INT1 bit. 1 - Timer counts pulses brought to the T1 pin (P3.5). 0 - Timer counts pulses from internal oscillator. 1 - Timer 0 operates only if the INT0 bit is set. 0 - Timer 0 operates regardless of the logic state of the INT0 bit. 1 - Timer counts pulses brought to the T0 pin (P3.4). 0 - Timer counts pulses from internal oscillator.
GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2):
o o
T0M1,T0M0 These two bits select the operational mode of the Timer 0.
Page 23
DEPT OF E.C.E
T1M1 0 0 1 1
T1M1,T1M0 These two bits select the operational mode of the Timer 0.
T1M0 0 1 0 1 MODE 0 1 2 3 DESCRIPTION 13-bit timer 16-bit timer 8-bit auto-reload Split mode
TF1 bit is automatically set on the Timer 1 overflow. TR1 bit enables the Timer 1.
o o
TF0 bit is automatically set on the Timer 0 overflow. TR0 bit enables the timer 0.
o o
UART (Universal Asynchronous Receiver and Transmitter): One of the microcontroller features making it so powerful is an integrated UART, better known as a serial port. It is a full-duplex port, thus being able to transmit and receive data simultaneously and at different baud rates. Without it, serial data send and receive would be an
DEPT OF E.C.E Page 24
enormously complicated part of the program in which the pin state is constantly changed and checked at regular intervals. When using UART, all the programmer has to do is to simply select serial port mode and baud rate. When it's done, serial data transmit is nothing but writing to the SBUF register, while data receive represents reading the same register. The microcontroller takes care of not making any error during data transmission.
SM0 - Serial port mode bit 0 is used for serial port mode selection. SM1 - Serial port mode bit 1. SM2 - Serial port mode 2 bit, also known as multiprocessor communication enable bit. When set, it enables multiprocessor communication in mode 2 and 3, and eventually mode 1. It should be cleared in mode 0.
REN - Reception Enable bit enables serial reception when set. When cleared, serial reception is disabled. TB8 - Transmitter bit 8. Since all registers are 8-bit wide, this bit solves the problem of transmiting the 9th bit in modes 2 and 3. It is set to transmit a logic 1 in the 9th bit. RB8 - Receiver bit 8 or the 9th bit received in modes 2 and 3. Cleared by hardware if 9th bit received is a logic 0. Set by hardware if 9th bit received is a logic 1. TI - Transmit Interrupt flag is automatically set at the moment the last bit of one byte is sent. It's a signal to the processor that the line is available for a new byte transmite. It must be cleared from within the software.
DEPT OF E.C.E
Page 25
RI - Receive Interrupt flag is automatically set upon one byte receive. It signals that byte is received and should be read quickly prior to being replaced by a new data. This bit is also cleared from within the software.
As seen, serial port mode is selected by combining the SM0 and SM2 bits:
SM0 0 0 1 1 SM1 0 1 0 1 MODE 0 1 2 3 DESCRIPTION 8-bit Shift Register 8-bit UART 9-bit UART 9-bit UART BAUD RATE 1/12 the quartz frequency Determined by the timer 1 1/32 the quartz frequency (1/64 the quartz frequency) Determined by the timer 1
0 - disables all interrupt requests. 1 - enables all individual interrupt requests. 0 - UART system cannot generate an interrupt. 1 - UART system enables an interrupt. 0 - Timer 1 cannot generate an interrupt. 1 - Timer 1 enables an interrupt.
0 - change of the pin INT0 logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT0 state change.
DEPT OF E.C.E
Page 26
0 - Timer 0 cannot generate an interrupt. 1 - enables timer 0 interrupt. 0 - change of the INT1 pin logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT1 state change.
IP Register (Interrupt Priority): The IP register bits specify the priority level of each interrupt (high or low priority).
PT1 - Timer 1 interrupt priority PX1 - External Interrupt INT1 priority PT0 - Timer 0 Interrupt Priority PX0 - External Interrupt INT0 Priority
PCON Register :
DEPT OF E.C.E
Page 27
SMOD Baud rate is twice as much higher by setting this bit. GF1 General-purpose bit (available for use). GF1 General-purpose bit (available for use). GF0 General-purpose bit (available for use). PD By setting this bit the microcontroller enters the Power Down mode. IDL By setting this bit the microcontroller enters the Idle mode.
2.5 Liquid Crystal Display (LCD): A Liquid crystal display is a thin, flat panel used for electronically displaying information such as text, images, and moving pictures. Its uses include monitors for computers, televisions, instrument panels, and other devices ranging from aircraft cockpit displays, to every-day consumer devices such as video players, gaming devices, clocks, watches, calculators, and telephones. Among its major features are its light weight construction, its portability, and its ability to be produced in much larger screen sizes. 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 pixels filled with liquid crystals and arrayed in front of a light source (backlight) or reflector to produce images in color or monochrome. Each pixel of an LCD typically consists of a layer of molecules aligned between two transparent electrodes and two polarizing filters. With no actual liquid crystal between the polarizing filters, light passing through the first filter would be blocked by the second polarizer. The surfaces of the electrodes that are in contact with the liquid crystal material are treated so as to align the liquid crystal molecules in a particular direction. The direction of the liquid crystal alignment is then defined by the direction of rubbing. Electrodes are made of a transparent conductor called Indium Tin Oxide (ITO).Before applying an electric field, the orientation of the liquid crystal molecules is determined by the alignment at the surfaces of electrodes. In a twisted nematic device (still the most common liquid crystal device), the surface alignment directions at the two electrodes are perpendicular to each other, and so the molecules arrange themselves in a helical structure, or twist. This reduces the rotation of the polarization of the incident light, and the device appears grey. This light will then be mainly polarized perpendicular to the second filter, and thus be blocked and the pixel will appear black. By controlling the voltage applied across the liquid crystal layer in each pixel, light can be allowed to pass through in varying amounts thus constituting different levels of gray.
DEPT OF E.C.E Page 28
Figure 2.25 : LCD Pin Configuration 2.5.1 Pin Description: Vcc, Vss and Vee: While VCC and VSS provide +5V and ground respectively, VEE is used for controlling LCD contrast. RS (Register Select): There are two important registers inside the LCD. 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 that is sent is a text data which should be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high RW (Read/Write): The 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 querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands, so RW will almost be low. EN (Enable):
DEPT OF E.C.E
Page 29
The 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 first set this line high (1) and then set the other two control lines and/or put data on the data bus. D0-D7 (Data Lines): The 8-bit data pins, D0-D7 are used to send information to the LCD or read the content of the LCDs internal registers. To display letters and numbers, we send ASCII codes for the letters A-Z, a-z and numbers 0-9 to these pins while making RS=1. There are also instruction command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor.
DEPT OF E.C.E
Page 30
PIN 1 2 3 4
I/O ---I
DESCRIPTION Ground +5V power supply Power supply to control contrast RS=0 to select command register RS=1 to select data register
R/W
6 7 8 9 10 11 12 13 14
Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus
DEPT OF E.C.E
Page 31
Table 3.5 : LCD Pin Description Table 3.5 : LCD Pin Description Table 2.5 : LCD Pin Description 2.5.2 LCD Command Codes :
CODE (HEX) 1 2 4 6 5 7 8
COMMAND TO LCD INSTRUCTION REGISTER CLEAR DISPLAY SCREEN RETURN HOME DECREMENT CURSOR(SHIFT CURSOR TO LEFT) INCREMENT CURSOR(SHIFT CURSOR TO RIGHT) SHIFT DISPLAY RIGHT SHIFT DISPLAY LEFT DISPLAY OFF,CURSOR OFF
DEPT OF E.C.E
Page 32
A C E F 10 14 18 1C 80 C0 38
DISPLAY OFF,CURSOR ON DISPLAY ON,CURSOR OFF DISPLAY ON CURSOR BLINKING DISPLAY ON CURSOR BLINKING SHIFT CURSOR POSITION TO LEFT SHIFT CURSOR POSITION TO RIGHT SHIFT THE ENTIRE DISPLAY TO THE LEFT SHIFT THE ENTIRE DISPLAY TO THE RIGHT FORCE CURSOR TO BEGINNING OF 1ST LINE FORCE CURSOR TO BEGINNING OF 2ND LINE 2 LINES AND 5x7 MATRIX
The ratio of the intensity of the brightest bright to the darkest dark. Aspect ratio: The ratio of the width to the height (for example, 4:3, 5:4, 16:9 or 16:10).
2.5.4. Advantages:
LCD interfacing with 8051 is a real-world application. In recent years the LCD is finding widespread use replacing LEDs (seven segment LEDs or other multi segment LEDs). This is due to 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.
2.6.1 Features:
Nine standard packages in hermetic and low-cost epoxy End- and side-radiating packages Graded Output High efficiency Ga, AI, As, 880 nm LPE process delivers twice the power of Conventional GaAs 940 nm emitters. Infrared (IR) radiation is electromagnetic radiation whose wavelength is longer than that of visible light (400-700 nm), but shorter than that of terahertz radiation (100 m - 1 mm) and
DEPT OF E.C.E Page 34
microwaves (~30,000 m). Infrared radiation spans roughly three orders of magnitude (750 nm and 100 nm). Direct sunlight has a luminous efficacy of about 93 lumens per watt of radiant flux, which includes infrared (47% share of the spectrum), visible (46%), and ultra-violet (only 6%) light. Bright sunlight provides luminance of approximately 100,000 candelas per square meter at the earths surface.
2.6.2 Overview:
Infrared imaging is used extensively for both military and civilian purposes. Military applications include target acquisition, surveillance, night vision, homing and tracking. Nonmilitary uses include thermal efficiency analysis, remote temperature sensing, short-ranged wireless communication, spectroscopy, and weather forecasting.. Infrared astronomy uses sensor-equipped telescopes to penetrate dusty regions of space, such as molecular clouds; detect cool objects such as planets, and to view highly red-shifted objects from the early days of the universe. At the atomic level, infrared energy elicits vibration modes in a molecule through a change in the dipole moment, making it a useful frequency range for study of these energy states for molecules of the proper symmetry. Infrared spectroscopy examines absorption and transmission of photons in the infrared energy range, based on their frequency and intensity. Origins of the term The name means below red (from the Latin infra, "below"), red being the color of the longest wavelengths of visible light. IR light has a longer wavelength (a lower frequency) than that of red light, hence below. Different regions in the infrared Objects generally emit infrared radiation across a spectrum of wavelengths, but only a specific region of the spectrum is of interest because sensors are usually designed only to collect radiation within a specific bandwidth. As a result, the infrared band is often subdivided into smaller sections.
DEPT OF E.C.E Page 35
DEPT OF E.C.E
High immunity against ambient light Photo detector and preamplifier in one package Improved shielding against electrical field disturbance TTL and CMOS compatibility Active low output Low power consumption Internal filter for PCM frequency.
2.6.4 IR Receiver:
Features Tight production distribution. Steel lead frames for improved reliability in solder mounting. Good optical-to-mechanical alignment. Plastic package is infrared transparent black to attenuate visible light. Can be used with QECXXX LED, Black plastic body allows easy recognition from LED. Phototransistors also consist of a photodiode with internal gain. A phototransistor is in essence nothing more than a bipolar transistor that is encased in a transparent case so that light can reach the base-collector junction. The electrons that are generated by photons in the basecollector junction are injected into the base, and this photodiode current is amplified by the transistor's current gain. Note that while phototransistors have a higher responsively for light
DEPT OF E.C.E Page 37
they are not able to detect low levels of light any better than photodiodes. Phototransistors also have slower response times. A simple model of a phototransistor, would be a forward based LED (emitterbase) and a reverse based photodiode (basecollector) sharing an anode (base) in a single package such that 99% (F%) of the light emitted by the led is absorbed by the photodiode. Each electron-hole recombination in the LED produces one photon and each photon absorbed by the photodiode produces one electron-hole pair.
Figure 2.28 : IR Receiver IR Receiver needs to be in line of sight with the transmitter to efficiently transform light impulses into digital values. The light emitted from the IR LED is modulated with a lens into a compact beam and then turned an and of concerning the message.
DEPT OF E.C.E
Page 38
diagram of 555
DEPT OF E.C.E
Page 39
Operating Voltage Maximum Supply Current High Level Output Voltage Maximum Output Current
= 4.5V to 16V = 5mA @ 5V Operating Voltage = 12mA @ 15V Operating Voltage = 3.3V @ 5V Operating Voltage = 13.3V @ 15V Operating Voltage = 200mA @ 15V Operating Voltage = 100mA @ 5V Operating Voltage
across
increase. When it reaches 2/3 V+ the Flip-Flop is reset. This causes capacitor C1 to discharge very quickly and the output goes low. Maximum output pulse Minimum output pulse R1 minimum resistance R1 maximum resistance = 5 minutes = 5 uS = 1K ohm = 1Mohm
DEPT OF E.C.E
Page 41
DEPT OF E.C.E
Page 42
Figure 2.33: Astable operation In astable mode the in timer continually triggers repeating itself and runs as a on multi the
This
results
a continually
signal being
generated
The external capacitor C1 charges through both R1 and R2 but discharges only through R2. Therefore the duty cycle is determined by the ratio of these resistor. If the value of the two resistors is the same the duty cycle will be 50%and a square wave will be output. The 'High' output time is given by: The 'Low' output time is given by: Therefore the total period is given by: The frequency of oscillation is given by: t1 = 0.693 (R1 + R2) x C1 t2 = 0.693 (R2) x C1 T = t1 + t2 = 0.693 (R1 + R2) x C1 f = 1 / T= 1.44 / ((R1 + R2) x C1
DEPT OF E.C.E
Page 43
While sending a message in the form of bits such as 1,the data is sent to the receiver side correspondingly the LED glows representing the data is being received simultaneously when we send 8 as a data the LED gets off .
Figure 2.34: Light Emitting Diode As in the simple LED circuit, the effect is a form of electroluminescence where incoherent and narrow-spectrum light is emitted from the p-n junction. LEDs are widely used as indicator lights on electronic devices and increasingly in higher power applications such as flashlights and area lighting. An LED is usually a small area (less than 1 mm2) light source, often with optics added to the chip to shape its radiation pattern and assist in reflection. The color of the emitted light depends on the composition and condition of the semi conducting material used, and can be infrared, visible, or ultraviolet. Besides lighting, interesting applications include using UV-LEDs for sterilization of water and disinfection of devices, and as a grow light to enhance photosynthesis in plants
Ultraviolet
2.8.2 Advantages:
1. LEDs have many advantages over other technologies like lasers. As compared to laser diodes or IR sources 2. LEDs are conventional incandescent lamps. For one thing, they don't have a filament that will burn out, so they last much longer. Additionally, their small plastic bulb makes them a lot more durable. They also fit more easily into modern electronic circuits. 3. The main advantage is efficiency. In conventional incandescent bulbs, the lightproduction process involves generating a lot of heat (the filament must be warmed). Unless you're using the lamp as a heater, because a huge portion of the available electricity isn't going toward producing visible light. 4. LEDs generate very little heat. A much higher percentage of the electrical power is going directly for generating light, which cuts down the electricity demands considerably. 5. LEDs offer advantages such as low cost and long service life. Moreover LEDs have very low power consumption and are easy to maintain.
DEPT OF E.C.E
Page 45
2.8.3
Disadvantages:
1. LEDs performance largely depends on the ambient temperature of the operating environment. 2. LEDs must be supplied with the correct current. 3. LEDs do not approximate a "point source" of light, so cannot be used in applications needing a highly collimated beam. But the disadvantages are quite negligible as the negative properties of LEDs do not apply and the advantages far exceed the limitations
amount of time has passed), you can name the instruction group TIMER_LOOP.An assembly language program has three constituent parts: 1. Machine instructions 2. Assembler directives
DEPT OF E.C.E Page 46
3. Assembler controls A Machine instruction is a machine code that can be executed by the machine. Detailed discussion of the machine instructions can be found in the hardware manuals of the 8052. An Assembler directive is used to define the program structure and symbols and generate nonexecutable code (data, messages etc). Assembler directives instruct the assembler how to process subsequent assembly language instructions. Directives also provide a way for you to define program constants and reserve space for variables. An Assembler control sets the assembly mode and directs the assembly flow. Assembler controls direct the operation of the assembler when generating a listing file or object file. Typically, controls do not impact the code that is generated by the assembler. Controls can be specified on the command line or within an assembler source file.
2.9.3 Simulation/debugger:
The simulation/debugger in KEIL can perform a very detailed simulation of a micro controller along with external signals. It is possible to view the precise execution time of a single assembly instruction, or a single line of C code, all the way up to the entire application, simply by entering the crystal frequency. A window can be opened for each peripheral on the device, showing the state of the peripheral. This enables quick trouble shooting of miss-configured
DEPT OF E.C.E Page 47
peripherals. Breakpoints may be set on either assembly instructions or lines of C code, and execution may be stepped through one instruction or Cline at a time. The contents of all the memory areas may be viewed allowing a detailed view of what the microcontroller is doing at any point in time.
Select Debug - Start/Stop Debug Session. Use the Step toolbar buttons to single-step through your program. You may enter Open the Serial Window using the Serial #1 button on the toolbar. Debug your program using standard options like Step, Go, Break, and so on.
DEPT OF E.C.E
Page 48
DEPT OF E.C.E
Page 49
DEPT OF E.C.E
Page 50
Start
Produ ct Sense d
No
DEPT OF E.C.E
Page 51
4.1 Applications:
Digital Object Counter can be used in counting the objects efficiently. This is a low cost efficient device and consumes low power. It can be even used in 1 . Industries where the number of products or objects can be counted. 2. In the parking areas to know the number of vehicles have entered.
DEPT OF E.C.E
Page 52
CHAPTER-5 CONCLUSION
Chapter 2 gives an overview of the implementation of the project and the components used in the project. The main components in the project are described along with working which is useful to understand the project better and helps us in analyzing the scope and working. We have seen the working and output of the project and discussed in detail. It gives us an overview of the implementation of the project and the hardware and software tools used in the project. By doing this project, it was very helpful to us to gain a better insight on the vast field of embedded system. This project does not consume much power and the components used in the project are familiar to many people.
DEPT OF E.C.E
Page 53
CHAPTER-6 REFERENCES
Books Referred:
[1] Muhammad Ali Mazidi and Janice Gillispi Mazidi, The 8051 Microcontroller and Embedded Systems. [2] A.K.Ray, The 8051 Microprocessor and Microcontroller. [3]MICROCONTROLLER (8051) A.P.GODSE
Web Reference:
[1] Datasheets of Microcontroller AT89C51 [2] www.electronicsforu.com [3] www.alldatasheets.com [4] www.datasheet4u.com [5] www.keil.com [6] www.engineersgarage.com
DEPT OF E.C.E
Page 54
here:
increm:
inc r0 mov a,r0 add a,#00h da a mov r0,a mov p1, a sjmp here
decrem:
mov b,r0
DEPT OF E.C.E
Page 55
anl b,#0fh mov a,b cjne a,#00h,skip mov a,r0 cjne a,#00h,next mov p1,#00h sjmp here next: subb a,#07h mov a,r0 mov p1,a sjmp here skip: dec r0 mov a,r0 mov p1,a sjmp here end
//LCD CODE//
#include<reg51.h> #define cmdport P3 #define dataport P1 #define port P2 #define q 100 sbit rs = cmdport^0; //register select pin
DEPT OF E.C.E Page 56
sbit rw = cmdport^1; // read write pin sbit e = cmdport^2; //enable pin sbit op=P2^0; void delay(unsigned int msec) // Function to provide time delay in msec. { int i,j ; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } void lcdcmd(unsigned char item) //Function to send command to LCD { dataport = item; rs= 0; rw=0; e=1; delay(1); e=0; } void lcddata(unsigned char item) //Function to send data to LCD { dataport = item; rs= 1; rw=0; e=1; delay(1);
DEPT OF E.C.E Page 57
e=0; } void lcd_data_string(unsigned char *str) // Function to send string to LCD { int i=0; while(str[i]!='\0') { lcddata(str[i]); i++; delay(10); } } void display(unsigned char z) { unsigned char tmp; unsigned char ASCII[2]; tmp = z>>4; if(tmp <= 0x09) ASCII[1] = tmp+0x30; else { ASCII[1] = tmp-0x09; ASCII[1] += 0x40; } tmp = (z & 0x0f);
DEPT OF E.C.E
// define temporary variable // define 2 digit variable // get upper nibble // if its less then 9 convert it // in ASCII by adding 30
// same operation
ASCII[0] = tmp+0x30; else { ASCII[0] = tmp-0x09; ASCII[0] += 0x40; } lcddata(ASCII[1]); lcddata(ASCII[0]); } void main() { char count=0; P2= 0xff; op=0; lcdcmd(0x38); // for using 8-bit 2 row mode of LCD delay(100); lcdcmd(0x0E); // turn display ON for cursor blinking delay(100); lcdcmd(0x01); //clear screen delay(100); lcdcmd(0x06); //display ON delay(100); lcd_data_string("Product Counter");
DEPT OF E.C.E Page 59
DEPT OF E.C.E
Page 60