Escolar Documentos
Profissional Documentos
Cultura Documentos
1. Abstract
2. Introduction
2.2 Block Diagram
2.3 Block Description
3. Circuit Details
3.2 Circuit Diagram
3.3 Circuit Description
4. Power supply
5. Microcontroller
6. I/O Ports
7. ADC
8. IR Sensors
9. Motor Driver-L293D
10. Program Code
11. Application
12. Conclusion
13. References
ABSTRACT
The objective of this project is to design an automated railway gate
controller using IR Sensor. The project comprises of two pairs of analog IR
Sensor which is placed in an order, so as to automatically control the
opening & closing of the gate in accordance to the arrival & departure of
the train crossing the public roads.
As the system is completely automated, it avoids manual errors and
thus provides ultimate safety to road users. By this mechanism, presence
of a gatekeeper is not necessary and automatic operation of the gate
through the motor action is achieved. Microcontroller Atmega16 performs
the complete operation i.e., sensing, gate closing and opening operation is
done by software coding written for the controller. The mechanism works
on a simple principle and there are no hardware complexities.
INTRODUCTION
Today’s world is the world of automation. Now a day we can find each
and every part is getting automated. If we talk of the Railway crossing, we
can find that it is manually operated. By the presently existing system
once the train leaves the station, the stationmaster informs the
gatekeeper about the arrival of the train through the telephone. Once the
gatekeeper receives the information, he closes the gate depending on the
timing at which the train arrives. Hence, if the train is late due to certain
reasons then gate remain closed for a long time causing traffic near the
gates. Our project which is “Automatic railway gate controller” can solve
this problem by automating the whole gate system.
MICRO MOTOR
IR SENSORs CONTROLLE DRIVER MOTOR
R
BLOCK DESCRIPTION:
CIRCUIT DETAILS
CIRCUIT DIAGRAM:
POWER SUPPLY
DESCRIPTION:
RECTIFIERS
Half-wave Rectifier: It is the rectifier circuit that rectifies only half part of
the AC signal. It uses only a single diode. It only uses only positive part of
the AC signal to produce half-wave varying DC and produce gaps when the
AC is negative.
Full-wave Rectifier: It is also called as Bridge Rectifier. A bridge rectifier can
be made using four individual diodes, but it is also available in special
packages containing the four diodes required. It is called a full-wave
rectifier because it uses the total AC wave (both positive and negative
sections).
SMOOTHING
This includes 78xx voltage regulators. The most commonly used ones
are 7805 and 7812. 7805 gives fixed 5V DC voltage if input voltage is in
(7.5V-20). You may sometimes have questions like, what happens if input
voltage is <7.5 V or some 3V, the answer is that regulation won't be
proper. Suppose if input is 6V then output may be 5V or 4.8V, but there
are some parameters for the voltage regulators like maximum output
current capability, line regulation etc. won't be proper. Remember that
electronics components should be used in the proper voltage and current
ratings as specified in datasheet. You can work without following it, but
you won't be able to get some parameters of the component.
Mostly available negative voltage regulators are of 79xx family. The mainly
available 79xx IC's are 7905,7912 1.5A output current ,short circuit
protection, ripple rejection are the other features of 79xx IC's.
Many of the fixed voltage regulators have 3 leads and look like power
transistors, such as the 7805 (+5V 1A) regulator shown on the above. If
adequate heat sinking is provided then it can deliver up to maximum 1A
current. For an output voltage of 5v-18v the maximum input voltage is 35v
and for an output voltage of 24V the maximum input voltage is 40V.For
7805 IC, for an input of 10v the minimum output voltage is 4.8V and the
maximum output voltage is 5.2V. The typical dropout voltage is 2V.
The computer on one hand is designed to perform all the general purpose tasks on a
single machine like you can use a computer to run a software to perform calculations
or you can use a computer to store some multimedia file or to access internet
through the browser, whereas the microcontrollers are meant to perform only the
specific tasks, for e.g., switching the AC off automatically when room temperature
drops to a certain defined limit and again turning it ON when temperature rises
above the defined limit.
There are number of popular families of microcontrollers which are used in different
applications as per their capability and feasibility to perform the desired task, most
common of these are 8051, AVR and PIC microcontrollers. In this article we will
introduce you with AVR family of microcontrollers.
History of AVR
AVR was developed in the year 1996 by Atmel Corporation. The architecture of
AVR was developed by Alf-EgilBogen and VegardWollan. AVR derives its name from
its developers and stands for Alf-EgilBogen VegardWollan RISC microcontroller, also
known as Advanced Virtual RISC. The AT90S8515 was the first microcontroller which
was based on AVR architecture however the first microcontroller to hit the
commercial market was AT90S1200 in the year 1997.
1. Tiny AVR – Less memory, small size, suitable only for simpler applications
2. Mega AVR – These are the most popular ones having good amount of memory (up
to 256 KB), higher number of inbuilt peripherals and suitable for moderate to
complex applications.
3. Xmega AVR – Used commercially for complex applications, which require large
program memory and high speed.
The following table compares the above mentioned AVR series of microcontrollers:
The CPU takes values from two input registers INPUT-1 and INPUT-2,
performs the logical operation and stores the value into the OUTPUT
register. All this happens in 1 execution cycle.
Features of ATmega16:
Architecture of AVR
Since AVR can perform single cycle execution, it means that AVR can
execute 1 million instructions per second if cycle frequency is 1MHz. The
higher is the operating frequency of the controller, the higher will be its
processing speed. We need to optimize the power consumption with
processing speed and hence need to select the operating frequency
accordingly.
Naming Convention
PIN DIAGRAM :
Pin Descriptions
14-21 PortD Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive
(PD7..PD0) characteristics with both high sink and source capability. As inputs, Port D pins
that are externally pulled low will source current if the pull-up resistors are
activated. The Port D pins are tri-stated when a reset condition becomes
active, even if the clock is not running.
9 RESET Reset Input. A low level on this pin for longer than the minimum pulse length
will generate a reset, even if the clock is not running. Shorter pulses are not
guaranteed to generate a reset.
12 XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock
operating circuit.
13 XTAL2 Output from the inverting Oscillator amplifier
30 AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should
be externally connected to VCC, even if the ADC is not used. If the ADC is
used,
it should be connected to VCC through a low-pass filter.
32 AREF AREF is the analog reference pin for the A/D Converter.
I/O PORTS
Atmega16 have 32 general purpose digital I/O pins. Corresponding to
every pin, there are 3 bits in 3 different registers which control its
function. Let’s say we are talking about the pin PA0. The three registers
involved with this pin are DDRA, PORTA and PINA and the corresponding
bits are DDRA0, PORTA0 and PINA0.
PORT REGISTERS
DDR - is the Data Direction Register - writing 1 to DDRA0 makes the pin
PA0 act like an output pin and writing 0 makes it an input pin.
Initializes the direction of the port i.e., as input or output.
1 – represents output
0 – represents input
CONTROLLING
i/o STATUS OF D
D
PORT B R
B
Logic 1 – 5 V (high)
Logic 0 – 0V (low)
PORTX = 0B111111111;
PORTX = 0B00000000;
PORTX = 0B10001110;
PINX(for input data)
Logic 1 – 5V (high)
Logic 0 – 0V (low)
A = PINX;
Code example:
DDRC=130;
or,
DDRC= 0b 10000010;
or,
DDRC= 0x 82;
Either of the above statements will make the PC1 and PC7 as output and
rest as input.
Detailed Explanation:
It is to be noted that writing some value onto a register simply means that
the bits of the register will attain values such that the binary number
represented by all the 8 bits of the register together equals the number
assigned to them. e.g. writing 0b10110101 means that the bits in the
register will become like this:
PIN register - This register is used for reading the digital value of the pin. It
can be thought of as actually connected to MCU physical pins. If voltage of
the pin (either in case of input or output) at any instant is low it will read
as 0 otherwise 1.
Code example:
int read;
read = PINB; // stores the value of 8 bit PINB register in the variable read
or,
read =PINB & 4; // this statement stores the value of PB2 bit in read
ADC
Features:
• 10-bit Resolution
• 0.5 LSB Integral Non-
linearity
• ±2 LSB Absolute
Accuracy
• 13 - 260 µs Conversion
Time
• Up to 15 KSPS at Maximum
Resolution
• 8 Multiplexed Single Ended Input
Channels
• Optional Left adjustment for ADC
Result Readout
• 0 - VCC ADC Input Voltage
Range
• Selectable 2.56V ADC Reference
Voltage
• Free Running or Single Conversion
Mode
• ADC Start Conversion by Auto Triggering on
Interrupt Sources
• Interrupt on ADC Conversion
Complete
The ADC contains a Sample and Hold circuit which ensures that the
input voltage to the ADC is held at a constant level during
conversion. The ADC has a separate analog supply voltage pin,
AVCC. AVCC must not differ more than ±0.3 V from VCC.
Internal reference voltages of nominally 2.56V or AVCC are
provided On-chip. The volt- age reference may be externally
decoupled at the AREF pin by a capacitor for better noise
performance.
CODING:
#include<avr/adc.h>
void main()
{
unsigned char x;
adc_init(); //for initialization of ADC port
x=read_adc_channel(channel number); //to read a
particular ADC channel and
//storing in a variable
}
IR SENSORS
DEFINITION
TYPES OF IR SENSORS:
1. Active IR Sensors:
Active IR Sensors are the type of IR Sensors that employs an IR source
& IR detectors (emitter & receiver). They operate by transmitting energy
from either a light emitting diode (LED) or a laser diode. A phototransistor
is used as an active IR detector. In these types of IR sensors, the LED or
laser diode illuminates the target, and the reflected energy is focused onto
a detector. Photoelectric cells, Photodiode or phototransistors are
generally used as detectors. The measured data is then processed using
various signal-processing algorithms to extract the desired information.
Active IR detectors provide count, presence, speed, and occupancy
data in both night and day operation.
2. Passive IR Sensors:
These are basically IR detectors; they don’t use any IR source. These
form the major class of IR sensors/detectors.
A passive infrared system detects energy emitted by objects in the
field of view and may use signal-processing algorithms to extract the
desired information. It does not emit any energy of its own for the
purposes of detection. Passive infrared systems can detect presence,
occupancy, and count.
IR RECEIVER
Transmitter:
Transmitter = LED (Light Emitting Diode)
It is similar to normal LEDs but emit infra-red light its glow can be seen
with a digital camera or mobile phone camera.
Receiver:
Receiver = Photodiode/IR Transistor.
A photodiode is a diode that conducts only when light falls on it
WORKING PRINCIPLE
CONNECTIONS
APPLICATIONS:
MOTOR DRIVER
Whenever we are talking about driving a motor through the outputs
of our microcontroller, it is not easy to do that work. This is so because our
motors specification tells to drive it on 12v dc but our microcontroller can
give a max of 5v. So to drive a motor we need some drivers which can
amplify the 5v voltage to 12v. . These days many IC manufacturers have H-
bridge motor driver available in the market like L293D is most used H-
Bridge driver IC. H-bridge can also be made with the help of transistors
and MOSFETs etc. rather of being cheap, they only increase the size of
the design board, which is sometimes not required so using a small 16 pin
IC is preferred for this purpose. The driver which we are using here to
drive the motor is an IC L293D.
Truth Table
High Left High Right Low Left Low Right Description
On Off Off On Motor runs clockwise
Off On On Off Motor runs anti-clockwise
On On Off Off Motor stops or decelerates
Off Off On On Motor stops or decelerates
As already said, H-bridge can be made with the help of transistors as well
as MOSFETs; the only thing is the power handling capacity of the circuit.
If motors are needed to run with high current then lot of dissipation is
there. So head sinks are needed to cool the circuit.
Now you might be thinking why I did not discuss the cases like High side
left on and Low side left on or high side right on and low side right on.
Clearly seen in the diagram, you don't want to burn your power supply by
shorting them. So that is why those combinations are not discussed in the
truth table.
So we have seen that using simple switching elements we can make our
own H-Bridge, or other option we have is using an IC based H-bridge
driver.
As you can see in the circuit, three pins are needed for interfacing a DC
motor (A, B, Enable). If you want the o/p to be enabled completely then
you can connect Enable to VCC and only 2 pins needed from controller to
make the motor work.
As per the truth mentioned in the image above it’s fairly simple to
program the microcontroller. It’s also clear from the truth table of BJT
circuit and L293D the programming will be same for both of them, just
keeping in mind the allowed combinations of A and B.
PROGRAM CODE
APPLICATION:
CONCLUSION
REFERENCES