Traffic Light
Traffic Light
Traffic Light
Introduction:
Automatic Railway Gate control system using Arduino Uno micro controller. Gates will
close automatically when train arrival and open when train departure from crossing. The
main purpose of this project is to avoid accidents and save time This project utilizes Two
IR Tx./Rx. Pair is placed at either side of the gate with some distance as shown in the
pic above. When train cuts first sensor light signal Red and railway gate will closed.
When train cuts second sensor then a light signal Green and gates will open. You can
easily measure this timing for your toy train. I design circuit using Arduino Uno
microcontroller.IR sensors output is connected to comparator LM324.LM324 generates
TTL High/Low signal at its output pins which is fed to MCU's pins as Input. According to
input from LM324 Micro-controller take action.One DC Motors is used for controlling the
gate, these motor's current requirement is much more then MCU hence we need a
Motor Driver IC L293D.
Defining Arduino
An Arduino is actually a microcontroller based kit which can be either used directly by
purchasing from the vendor or can be made at home using the components, owing to its open
source hardware feature. It is basically used in communications and in controlling or
operating many devices. It was founded by Massimo Banzi and David Cuartielles in 2005.
Arduino Architecture:
Arduino’s processor basically uses the Harvard architecture where the program code and
program data have separate memory. It consists of two memories- Program memory and the
data memory.The code is stored in the flash program memory, whereas the data is stored in
the data memory. The Atmega328 has 32 KB of flash memory for storing code (of which 0.5
KB is used for the bootloader), 2 KB of SRAM and 1 KB of EEPROM and operates with a
clock speed of 16MHz.
Arduino Architecture
Arduino Uno consists of 14 digital input/output pins (of which 6 can be used as PWM
outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an
ICSP header, and a reset button
Power Jack: Arduino can be power either from the pc through a USB or through external
source like adaptor or a battery. It can operate on a external supply of 7 to 12V. Power can be
applied externally through the pin Vin or by giving voltage reference through the IORef pin.
Digital Inputs: It consists of 14 digital inputs/output pins, each of which provide or take up
40mA current. Some of them have special functions like pins 0 and 1, which act as Rx and Tx
respectively , for serial communication, pins 2 and 3-which are external interrupts, pins
3,5,6,9,11 which provides pwm output and pin 13 where LED is connected.
Analog inputs: It has 6 analog input/output pins, each providing a resolution of 10 bits.
The most important advantage with Arduino is the programs can be directly loaded to the
device without requiring any hardware programmer to burn the program. This is done
because of the presence of the 0.5KB of Bootloader which allows the program to be burned
into the circuit. All we have to do is to download the Arduino software and writing the code.
The Arduino tool window consists of the toolbar with the buttons like verify, upload, new,
open, save, serial monitor. It also consists of a text editor to write the code, a message area
which displays the feedback like showing the errors, the text console which displays the
output and a series of menus like the File, Edit, Tools menu.
Programs written in Arduino are known as sketches. A basic sketch consists of 3 parts
1. Declaration of Variables
2. Initialization: It is written in the setup () function.
3. Control code: It is written in the loop () function.
The sketch is saved with .ino extension. Any operations like verifying, opening a
sketch, saving a sketch can be done using the buttons on the toolbar or using the tool
menu.
The sketch should be stored in the sketchbook directory.
Chose the proper board from the tools menu and the serial port numbers.
Click on the upload button or chose upload from the tools menu. Thus the code is
uploaded by the bootloader onto the microcontroller.
We can also design our own Arduino by following the schematic given by the Arduino
vendor and also available at the websites. All we need are the following components- A
breadboard, a led, a power jack, a IC socket, a microcontroller, few resistors, 2 regulators, 2
capacitors.
The IC socket and the power jack are mounted on the board.
Add the 5v and 3.3v regulator circuits using the combinations of regulators and
capacitors.
Add proper power connections to the microcontroller pins.
Connect the reset pin of the IC socket to a 10K resistor.
Connect the crystal oscillators to pins 9 and 10
Connect the led to the appropriate pin.
Mount the female headers onto the board and connect them to the respective pins on
the chip.
Mount the row of 6 male headers, which can be used as an alternative to upload
programs.
Upload the program on the Microcontroller of the readymade Adruino and then pry it
off and place back on the user kit.
1. It is inexpensive
2. It comes with an open source hardware feature which enables users to develop their
own kit using already available one as a reference source.
3. The Arduino software is compatible with all types of operating systems like
Windows, Linux, and Macintosh etc.
4. It also comes with open source software feature which enables experienced software
developers to use the Arduino code to merge with the existing programming language
libraries and can be extended and modified.
5. It is easy to use for beginners.
6. We can develop an Arduino based project which can be completely stand alone or
projects which involve direct communication with the software loaded in the
computer.
7. It comes with an easy provision of connecting with the CPU of the computer using
serial communication over USB as it contains built in power and reset circuitry.
So this is some basic idea regarding an Arduino. You can use it for many types of
applications. For instance in applications involving controlling some actuators like motors,
generators, based on the input from sensors
Introduction
The Arduino platform has become quite popular with people just starting out
with electronics, and for good reason. Unlike most previous programmable
circuit boards, the Arduino does not need a separate piece of hardware (called a
programmer) in order to load new code onto the board – you can simply use a
USB cable. Additionally, the Arduino IDE uses a simplified version of C++,
making it easier to learn to program. Finally, Arduino provides a standard form
factor that breaks out the functions of the micro-controller into a more
accessible package.
The Uno is one of the more popular boards in the Arduino family and a great
choice for beginners. We’ll talk about what’s on it and what it can do later in
the tutorial.
This is a screenshot of the Arduino IDE.
Believe it or not, those 10 lines of code are all you need to blink the on-board
LED on your Arduino. The code might not make perfect sense right now, but,
after reading this tutorial and the many more Arduino tutorials waiting for you
Suggested Reading
Arduino is a great tool for people of all skill levels. However, you will have a
much better time learning along side your Arduino if you understand some basic
world of Arduino.
What is Electricity?
What is a Circuit?
Polarity
Logic Levels
Digital Logic
The Arduino hardware and software was designed for artists, designers,
speakers, GPS units, cameras, the internet, and even your smart-phone or your
TV! This flexibility combined with the fact that the Arduino software is free,
the hardware boards are pretty cheap, and both the software and hardware are
easy to learn has led to a large community of users who have contributed code
For everything from robots and a heating pad hand warming blanket to honest
gauntlet, the Arduino can be used as the brains behind almost any electronics
project.
And that’s really just the tip of the iceberg – if you’re curious about where to
find more examples of Arduino projects in action, here are some good resources
Instructables
Bildr
Arduino Playground
Make: Projects
and, of course, you can find plenty more Arduino tutorials here at
learn.sparkfun.com.
There are many varieties of Arduino boards (explained on the next page) that
can be used for different purposes. Some boards look a bit different from the
one below, but most Arduinos have the majority of these components in
common:
Power (USB / Barrel Jack)
Arduino UNO can be powered from a USB cable coming from your computer
or a wall power supply (like this) that is terminated in a barrel jack. In the
picture above the USB connection is labeled (1) and the barrel jack is labeled
(2).
The USB connection is also how you will load code onto your Arduino board.
More on how to program with Arduino can be found in our Installing and
NOTE: Do NOT use a power supply greater than 20 Volts as you will
overpower (and thereby destroy) your Arduino. The recommended voltage for
The pins on your Arduino are the places where you connect wires to construct a
circuit (probably in conjuction with a breadboard and some wire. They usually
have black plastic ‘headers’ that allow you to just plug a wire right into the
board. The Arduino has several different kinds of pins, each of which is labeled
GND (3): Short for ‘Ground’. There are several GND pins on the
5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of
power, and the 3.3V pin supplies 3.3 volts of power. Most of the simple
components used with the Arduino run happily off of 5 or 3.3 volts.
Analog (6): The area of pins under the ‘Analog In’ label (A0 through A5
on the UNO) are Analog In pins. These pins can read the signal from an
analog sensor (like a temperature sensor) and convert it into a digital
Digital (7): Across from the analog pins are the digital pins (0 through 13
on the UNO). These pins can be used for both digital input (like telling if
PWM (8): You may have noticed the tilde (~) next to some of the digital
pins (3, 5, 6, 9, 10, and 11 on the UNO). These pins act as normal digital
pins, but can also be used for something called Pulse-Width Modulation
(PWM). We have a tutorial on PWM, but for now, think of these pins as
being able to simulate analog output (like fading an LED in and out).
AREF (9): Stands for Analog Reference. Most of the time you can leave
(between 0 and 5 Volts) as the upper limit for the analog input pins.
Reset Button
Just like the original Nintendo, the Arduino has a reset button (10). Pushing it
will temporarily connect the reset pin to ground and restart any code that is
loaded on the Arduino. This can be very useful if your code doesn’t repeat, but
you want to test it multiple times. Unlike the original Nintendo however,
tiny LED next to the word ‘ON’ (11). This LED should light up whenever you
plug your Arduino into a power source. If this light doesn’t turn on, there’s a
TX RX LEDs
TX is short for transmit, RX is short for receive. These markings appear quite a
our case, there are two places on the Arduino UNO where TX and RX appear –
once by digital pins 0 and 1, and a second time next to the TX and RX indicator
LEDs (12). These LEDs will give us some nice visual indications whenever our
Main IC
The black thing with all the metal legs is an IC, or Integrated Circuit (13). Think
different from board type to board type, but is usually from the ATmega line of
IC’s from the ATMEL company. This can be important, as you may need to
know the IC type (along with your board type) before loading up a new program
from the Arduino software. This information can usually be found in writing on
the top side of the IC. If you want to know more about the difference between
Voltage Regulator
The voltage regulator (14) is not actually something you can (or should) interact
with on the Arduino. But it is potentially useful to know that it is there and what
it’s for. The voltage regulator does exactly what it says – it controls the amount
of voltage that is let into the Arduino board. Think of it as a kind of gatekeeper;
it will turn away an extra voltage that might harm the circuit. Of course, it has
its limits, so don’t hook up your Arduino to anything greater than 20 volts.
addition, part of being open source hardware means that others can modify and
produce derivatives of Arduino boards that provide even more form factors and
functionality. If you’re not sure which one is right for your project, check this
guide for some helpful hints. Here are a few options that are well-suited to
The Uno is a great choice for your first Arduino. It’s got everything you need to
get started, and nothing you don’t. It has 14 digital input/output pins (of which 6
can be used as PWM outputs), 6 analog inputs, a USB connection, a power jack,
LilyPad Arduino
SparkFun. Each LilyPad was creatively designed with large connecting pads
and a flat back to allow them to be sewn into clothing with conductive thread.
The LilyPad also has its own family of input, output, power, and sensor boards
that are also built specifically for e-textiles. They’re even washable!
RedBoard
At SparkFun we use many Arduinos and we’re always looking for the simplest,
most stable one. Each board is a bit different and no one board has everything
we want – so we decided to make our own version that combines all our
favorite features.
The RedBoard can be programmed over a USB Mini-B cable using the Arduino
IDE. It’ll work on Windows 8 without having to change your security settings
(we used signed drivers, unlike the UNO). It’s more stable due to the
USB/FTDI chip we used, plus it’s completely flat on the back, making it easier
to embed in your projects. Just plug in the board, select “Arduino UNO” from
the board menu and you’re ready to upload code. You can power the RedBoard
over USB or through the barrel jack. The on-board power regulator can handle
The Arduino Mega is like the UNO’s big brother. It has lots (54!) of digital
input/output pins (14 can be used as PWM outputs), 16 analog inputs, a USB
or power it with a AC-to-DC adapter or battery to get started. The large number
of pins make this board very handy for projects that require a bunch of digital
Arduino Leonardo
with built-in USB. This means that it can be cheaper and simpler. Also, because
the board is handling USB directly, code libraries are available which allow the
While your Arduino board sure is pretty, it can’t do a whole lot on its own –
you’ve got to hook it up to something. There are lots of tutorials here on learn
as well as the links back in the ‘What does it do’ section, but rarely do we talk
about the general kinds of things you can easily hook into. In this section we’ll
introduce basic sensors as well as Arduino shields, two of the most handy tools
Sensors
With some simple code, the Arduino can control and interact with a wide
variety of sensors - things that can measure light, temperature, degree of flex,
Just a few of the sensors that are easily compatible with Arduino
Shields
Additionally, there are these things called shields – basically they are pre-built
circuit boards that fit on top of your Arduino and provide additional capabilities
CIRCUIT DIAGRAM
Component list
1 - Arduino (Obvious)
1 - Breadboard
6 - 270 ohm resistors
2 - Red LED
2 - Yellow LED
2 - Green LED
Misc. - Wires and Patients.
I used Pins 2 - 7 to make things easy. I don't know if it hurts the Arduino to use both PWM
and standard pins or not but, It works.
I wired up the grounds to the ground rail through the 270 OHM Resistors, it seems backwards
to me, because I'm and electrician, to go to ground through a resistor but, I have seen this
alot.
Program
void setup(){
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void loop(){
digitalWrite(2, HIGH); //Side 1 Red ON
delay(100);
digitalWrite(7, HIGH); //Side 2 Green ON
delay(5000);
digitalWrite(7, LOW); //Side 2 GREEN OFF
// delay(2000);
digitalWrite(6, HIGH); //Side 2 Yellow ON
delay(2000);
digitalWrite(6, LOW); //Side 2 Yellow OFF
// delay(2000);
digitalWrite(5, HIGH); //Side 2 Red ON
delay(100);
digitalWrite(2, LOW); //Side 1 Red OFF
// delay(2000);
digitalWrite(4, HIGH); //Side 1 Green ON
delay(5000);
digitalWrite(4, LOW); //Side 1 Green OFF
// delay(1000);
digitalWrite(3, HIGH); //Side 1 Yellow ON
delay(2000);
digitalWrite(3, LOW); //Side 1 Yellow OFF
// delay(1000);
digitalWrite(5, LOW); //Side 2 Red OFF
// digitalWrite(2,LOW); //Side 1 Red
// delay(1000);
}
Working of Relays
In this article, the basics of a relay like energized relay and de-energized relay are
explained in detail. Also, the design, construction, working, applications, and also relay
selection is explained in detail.
What is a relay?
We know that most of the high end industrial application devices have relays for their
effective working. Relays are simple switches which are operated both electrically and
mechanically. Relays consist of a n electromagnet and also a set of contacts. The switching
mechanism is carried out with the help of the electromagnet. There are also other operating
principles for its working. But they differ according to their applications. Most of the devices
have the application of relays.
The main operation of a relay comes in places where only a low-power signal can be used to
control a circuit. It is also used in places where only one signal can be used to control a lot of
circuits. The application of relays started during the invention of telephones. They played an
important role in switching calls in telephone exchanges. They were also used in long
distance telegraphy. They were used to switch the signal coming from one source to another
destination. After the invention of computers they were also used to perform Boolean and
other logical operations. The high end applications of relays require high power to be driven
by electric motors and so on. Such relays are called contactors.
Relay Design
Electromagnet
Movable Armature
Switch point contacts
Spring
The figures given below show the actual design of a simple relay.
Relay Construction
It is an electro-magnetic relay with a wire coil, surrounded by an iron core. A path of very
low reluctance for the magnetic flux is provided for the movable armature and also the switch
point contacts. The movable armature is connected to the yoke which is mechanically
connected to the switch point contacts. These parts are safely held with the help of a spring.
The spring is used so as to produce an air gap in the circuit when the relay becomes de-
energized.
The working of a relay can be better understood by explaining the following diagram given
below.
Relay Design
The diagram shows an inner section diagram of a relay. An iron core is surrounded by a
control coil. As shown, the power source is given to the electromagnet through a control
switch and through contacts to the load. When current starts flowing through the control coil,
the electromagnet starts energizing and thus intensifies the magnetic field. Thus the upper
contact arm starts to be attracted to the lower fixed arm and thus closes the contacts causing a
short circuit for the power to the load. On the other hand, if the relay was already de-
energized when the contacts were closed, then the contact move oppositely and make an open
circuit.
As soon as the coil current is off, the movable armature will be returned by a force back to its
initial position. This force will be almost equal to half the strength of the magnetic force. This
force is mainly provided by two factors. They are the spring and also gravity.
Relays are mainly made for two basic operations. One is low voltage application and the
other is high voltage. For low voltage applications, more preference will be given to reduce
the noise of the whole circuit. For high voltage applications, they are mainly designed to
reduce a phenomenon called arcing.
Relay Basics
The basics for all the relays are the same. Take a look at a 4 – pin relay shown below. There
are two colours shown. The green colour represents the control circuit and the red colour
represents the load circuit. A small control coil is connected onto the control circuit. A switch
is connected to the load. This switch is controlled by the coil in the control circuit. Now let us
take the different steps that occour in a relay.
relay operation
As shown in the circuit, the current flowing through the coils represented by pins 1 and 3
causes a magnetic field to be aroused. This magnetic field causes the closing of the pins 2 and
4. Thus the switch plays an important role in the relay working. As it is a part of the load
circuit, it is used to control an electrical circuit that is connected to it. Thus, when the relay in
energized the current flow will be through the pins 2 and 4.
Relays have the exact working of a switch. So, the same concept is also applied. A relay is
said to switch one or more poles. Each pole has contacts that can be thrown in mainly three
ways. They are
Normally Open Contact (NO) – NO contact is also called a make contact. It closes
the circuit when the relay is activated. It disconnects the circuit when the relay is
inactive.
Normally Closed Contact (NC) – NC contact is also known as break contact. This is
opposite to the NO contact. When the relay is activated, the circuit disconnects. When
the relay is deactivated, the circuit connects.
Change-over (CO) / Double-throw (DT) Contacts – This type of contacts are used
to control two types of circuits. They are used to control a NO contact and also a NC
contact with a common terminal. According to their type they are called by the names
break before make and make before break contacts.
Single Pole Single Throw (SPST) – This type of relay has a total of four terminals.
Out of these two terminals can be connected or disconnected. The other two terminals
are needed for the coil.
Single Pole Double Throw (SPDT) – This type of a relay has a total of five
terminals. Out f these two are the coil terminals. A common terminal is also included
which connects to either of two others.
Double Pole Single Throw (DPST) – This relay has a total of six terminals. These
terminals are further divided into two pairs. Thus they can act as two SPST’s which
are actuated by a single coil. Out of the six terminals two of them are coil terminals.
Double Pole Double Throw (DPDT) – This is the biggest of all. It has mainly eight
relay terminals. Out of these two rows are designed to be change over terminals. They
are designed to act as two SPDT relays which are actuated by a single coil.
Relay Applications
Relays are used to realize logic functions. They play a very important role in
providing safety critical logic.
Relays are used to provide time delay functions. They are used to time the delay open
and delay close of contacts.
Relays are used to control high voltage circuits with the help of low voltage signals.
Similarly they are used to control high current circuits with the help of low current
signals.
They are also used as protective relays. By this function all the faults during
transmission and reception can be detected and isolated.
Relay Selection
You must note some factors while selecting a particular relay. They are
Protection – Different protections like contact protection and coil protection must be
noted. Contact protection helps in reducing arcing in circuits using inductors. Coil
protection helps in reducing surge voltage produced during switching.
Look for a standard relay with all regulatory approvals.
Switching time – Ask for high speed switching relays if you want one.
Ratings – There are current as well as voltage ratings. The current ratings vary from a
few amperes to about 3000 amperes. In case of voltage ratings, they vary from 300
Volt AC to 600 Volt AC. There are also high voltage relays of about 15,000 Volts.
Type of contact used – Whether it is a NC or NO or closed contact.
Select Make before Break or Break before Make contacts wisely.
Isolation between coil circuit and contacts
Isolation of Arduino from the relays themselves and their switching transistors and
power supply
Isolation of your power wiring from arduino and it's wiring
Let's look at the choices of relay boards. There are two widely available types of relay
boards, and lately they cost about the same.
Boards with a common Ground and +5V supply between the Arduino and the board.
Example HERE:
Boards with optical isolation that can be run with no direct electrical connection
between Arduino and the relays and their power supply, shown below. Example
HERE: Boards like this are available with 2,4 or 8 relays.
Let's look at how to connect the relay board so it is really isolated. Notice that board has a
jumper between "Vcc" and "JD-Vcc". Remove it. For complete optical isolation, connect
"Vcc" to Arduino +5 volts but do NOT connect Arduino Ground. Connect your Arduino
Digital Output pins to "IN0", "IN1" etc. Connect a separate +5 supply to "JD-Vcc" and board
Gnd. This will supply power to the transistor drivers and relay coils. Look at the diagram
above. Only the part to the left of the small blue arrows is connected to Arduino.
People who have designed computer-driven automated machinery know that they have to be
careful about the physical routing, shielding, and isolation of low-level
computer/Microcomputer electronics and high-power motors and loads. Here are a few
guidelines:
Physically separate the low-power Computer/Electronics part from the large power-
handling part
Pay special attention to Grounding: Create a single common ground point in the
power section. Connect the Computer/Electronics ground to it at only that one point.
If possible locate all the power switching devices/relay in the power section, as close
to the load as reasonable
Run connections to the relays etc. from the Computer section to the Power section in
shielded twisted pair (or at least twisted pair) wiring.
Minimize the Electromagnetic Interference put out by the loads by putting
suppression devices across them to absorb the energy put out as they are disconnected
or switched Off. Here are some examples:
o MOVs (Metal Oxide Varistors) conduct at some higher-than-supply voltage.
Good for fast voltage spikes etc.
o DC Loads like solenoids used in electrical valves, and Motors, should have a
diode connected in the Reverse direction across them. This will absorb the
reverse-voltage spike/transient voltage that occurs when they are switched Off.
o Some loads that have to act very fast may be slowed down by a reverse diode,
and need a specially-calculated series Resistor-Capacitor network connected
across them.
Test the switching by attaching a simple light bulb load. When everything works, try
the real heavy load. Then you will know if you have EMI problems.
OK, that's a big deal. What can we do that's simple and helps? I'd suggest this:
Locate the relay board close to the load, (like in the outlet example)
Locate a separate 5V supply near the relay boards, plugged into the Load power, not
near the Arduino power supply or a computer supplying USB power to Arduino.
Run CAT5 cable back to Arduino, one pair for +5V and Arduino ground (NOT
connected on the relay end if you have opto-isolated relays), One pair for each signal,
with one wire connected to ground at Arduino, the far end unconnected
Run the Arduino from a separate 9V supply, not USB connected to a computer
Connect the Arduino Power Supply Ground to building ground. You can connect a
single ground wire to the "Green Ground" connection in an AC plug and plug it into
the wall (Nothing connected to the Line and Neutral connections)..
Suppress the EMI from troublesome loads like motors and solenoids by connecting a
MOV (Metal Oxide Varistor) or other suppression device across the load.
Dc power supply
The most common and inexpensive plugpack power supply type you'll see is the chunky
transformer based plug. Whenever you buy some consumer electronics you'll be getting one
of these:
These guys are everywhere - all sorts of voltage and current ratings. They're available
for sale at any store just about, but there are some big things to watch out for! One is
that the output voltage is not going to be 9V (for example) out of the box, that voltage
rating is just the minimum output for the current rating (200mA for example). And
also, the output is going to have a lot of ripple on it!
Before we talk precisely about these guys, lets go back in time to when engineers had
to build their power supplies with their bare hands!
We aren't going to get into the heavy detail of the electromagnetic theory behind
transformers except to say that they are made of two coils of wire around a chunk of iron. If
the number of coils are the same on both sides then the AC voltage is the same on both
sides. If one side has twice the coils, it has twice the voltage. They can be used 'backwards'
or 'forwards'! For more detailed information, be sure to check out the wikipedia page.
To use it, one half would get wired up to the wall (the 'primary' 'high side')
and the other half would output 12V AC (the 'secondary' 'low side'). The transformer
functioned in two ways: one it took the dangerous high voltage and transformed it to
a much safer low voltage, second itisolated the two sides. That made it even safer
because there was no way for the hot line to show up in your electronics and possibly
electrocute you.
We'll use a schematic symbol to indicate a transformer, its two coils inside which are
drawn out, the schematic symbol will have the same number of coils on either side so
use common sense and any schematic indicators to help you out in figuring which is
primary and which is secondary!
Half wave rectification
Now that the voltage is at a non-electrocutey level of around 12VAC it can be converted into
DC. The easiest and cheapest way to convert (also called rectify) AC to DC is to use a single
diode. A diode is a simple electronic 'valve' - it only lets current flow one way. Since AC
voltage cycles from positive to negative and we only want positive, we can connect it up so
that the circuit only receives the positive halfof the AC cycle.
You'll want to use a power diode such as a 1N4001 , they're extremely common and can put
up with a lot of abuse. The side with the silver stripe matches the schematic symbol side that
the 'arrow' in the diode symbol is pointing to. That's the only direction that current can flow.
The output is then chopped in half so that the voltage only goes positive.
into
What we have now isnt really AC and isn't really DC, its this lumpy wave. The good
news is that it's only positive voltage'd now, which means its safe to put a capacitor on
it.
This is a 2200 microFarad (0.0022 Farad) capacitor, one leg has (-) signs next to it,
this is the negative side. The other side is positive, and there should never be a voltage
across is so that the negative pin is 'higher' than the positive pin or it'll go POOF!
A capacitor smooths the voltage out, taking out the lumps, sort of how spring shocks in car
or mountain bike reduce the bumpiness of the road. Capacitors are great at this, but the big
capacitors that are good at this (electrolytic) can't stand negative voltages - they'll explode!
Because the voltage is very uneven (big ripples), we need a really big electrolytic-type
capacitor. How big? Well, there's a lot of math behind it which you can read about but
the rough formula you'll want to keep in mind is:
Ripple voltage = Current draw / ( (Ripple frequency) * (Capacitor size) )
For a half wave rectifier (single diode) the frequency is 60 Hz (or 50 Hz in europe).
The current draw is how much current your project is going to need, maximum. The
ripple voltage is how much rippling there will be in the output which you are willing
to live with and the capacitor size is in Farads.
So lets say we have a current draw of 50 mA and a maximum ripple voltage of 10mV
we are willing to live with. For a half wave rectifier, the capacitor should be at least =
0.05 / (60 * 0.01) = 0.085 Farads = 85,000 uF! This is a massive and expensive
capacitor. For that reason, its rare to see ripple voltages as low as 10mV. Its more
common to see maybe 100mV of ripple and then some other technique to reduce the
ripple, such as a linear regulator chip.
You don't have to memorize that formula, but you should keep the following in mind:
When the current goes up and the capacitor stays the same, the ripple goes up. If the
current goes up and you want the ripple the same, the capacitor must also increase.
As you can see, there are twice as many humps - there isnt that "half the time, no voltage"
thing going on. This means we can divide the calculated capacitor size to half of what it was
in the previous.
Basically, a full wave rectifier is way better than a half wave! So why even talk about half-
wave type rectifiers? Well, because they're useful for a few other purposes. In general,
you're unlikely to see an AC/DC converter that uses a half wave as the cost of the diodes
makes up for the saving in capacitor size and cost!
Wow so this looks really familiar, right? From let to right, you can see the wires that
come into the transformer from the wall plug, the transformer output has two power
diodes on it and a big capacitor (2,200uF). You might be a little puzzled at
the two diodes - shouldn't there be four for a full-wave rectifier? It turns out that if
you have a special transformer made with a 'center tap' (a wire that goes to the center)
you can get away with using only two diodes . So it really is a full wave rectifier, just
one with a center-tap transformer.
Yow! 14V? That's not anything like the 9V on the package, is this a broken wall wart? No! Its
totally normal! Transformer-based wall adapters are not designed to have precision outputs.
For one thing, the transformer, if you remember, is made of coils of wire. The coils for the
most part act like inductors but they still have some small resistance. For example, if the coil
is 10 ohms of resistance, then 200 mA of current will cause V = I * R = (0.2 Amps) * (10
ohms) = 2 Volts to be lost just in the copper winding! Another thing that causes losses is the
metal core of the transformer becomes less efficient as the amount of current being
transformed increases. Altogether, there are many inefficiencies that will make the output
fluctuate. In general, the output can be as high as twice the 'rated' voltage when there is less
than 10mA of current being drawn.
With no current being drawn on the supply, the voltage output is about 14V
When I connected a 100 ohm resistor (110 mA draw) from the positive pin to the negative
pin, it dropped to 11.2V
As the resistance gets smaller and smaller, the current draw gets higher and higher
and the voltage droops (that's the technical term for it!) You can also see the ripple
increase as the current goes up.
Now we can at least understand the thinking behind saying "9V 200mA" on the label.
As long as we are drawing less than 200mA the voltage will be higher than 9V.