DC Power Monitor With INA209 and Arduino
DC Power Monitor With INA209 and Arduino
You can measure DC Voltage, Current and Power in a voltage range from 0V to 26V. This
circuit use a high-side current shunt and power monitor with an I2C interface INA209 from
Texas Instruments and an Arduino UNO as microcontroller. The values are shown on a 2x16
LCD display.
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++,
factor that breaks out the functions of the micro-controller into a more
accessible package.
This is an Arduino Uno
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
Hardware description
All the measurements are made by Texas Instruments INA209, it's a high-side current shunt
and power monitor with an I2C interface. The INA209 monitors both shunt drop and shunt
bus voltage. A programmable calibration value, combined with an internal multiplier, enables
direct readouts in amperes. The INA209 also includes an analog comparator and a
programmable 12 bit digital-to-analog converter (DAC) that combine to provide the fastest
possible responses to current overload conditions. The INA209 senses across shunts on buses
that can vary from 0V to 26V.
INA209 Features
The comunication between INA209 and Arduino occurs through the I2C bus. Arduino
controls all function of INA209 and reads the value measured from the dedicated registers.
You can read the INA209 status or set the configuration parameters.
In this version of firmware I designed only the basic functions for continuos measurements of
instantaneous Voltage, Current and Power but you can control all function of INA209 with
my library as described on page INA209 Arduino Library.
The Voltage, Current and Power values are are shown on a 16x2 LCD display connected to
digital pin of Arduino. LCD display is a standard 16x2 character model YM1602C and is
connected to Arduino digital pins 12, 11, 5, 4, 3, 2. The contrast is regulated by a 10k
trimmer and the backlight is software controlled by Arduino PWM digital output on pin 6.
The figure below shown the block diagram of DC Power MonitorIn this version of firmware I
designed only the basic function for continuos measurements of instantaneous Voltage,
Current and Power but you can control all function of INA209 with my library as described
on page INA209 Arduino Library.
General features
Averaging results 2 ÷ 128 samples
Voltage Measurement
Digits 5
Full-Scale range 0 ÷ 26 V
Resolution 4mV
Measurement error ± 0.5% max
Measurement error over temperature ± 1% max
Current Measurement
Digits 5
Full-Scale range 0÷6A
Resolution 1mA
Measurement error ± 0.5% max
Measurement error over temperature ± 1% max
Power Measurement
Digits 6
Full-Scale range 0 ÷ 156 W
Resolution 4mW
Measurement error ± 1% max
Measurement error over temperature ± 2% max
Firmware
The most important part of the firmware is the INA209 library I have written and you can see
it on page INA209 Arduino Library. The library is used for control all functions of INA209
through the I2C bus. The measured value are read from INA209 using a simple and intuitive
function call and you don't need to know how I2C works.
/*
DC Power Monitor by ADPSLAB
Created 12 Sep. 2012 (Rev. 1.0)
Copyright (c) 2012 Antonio Dambrosio (
info@adpslab.com). All rights reserved.
This sketch is for control a Texas Instruments INA209 chip through I2C bu
s
and shown on a LCD Display 2x16 character these values:
Voltage measurement in a range from 0 to +26V with 4mV resolution;
Current measurement in a range from 0 to 6A with mA resolution;
Power measurement with 4mW resolution.
See the schematics on:
http://www.adpslab.com/en/electronics/arduino/22-dc-power-monitor-with-
ina209-and-arduino
*/
void setup() {
analogWrite(BACKLIGHT_PIN, 240);
lcd.begin(16, 2); // set up the LCD's number of columns and rows
Serial.begin(9600); // setup serial
Wire.begin(); // join i2c bus
// ------------- General Configuration ---------
/* Configuration Register 00h (Read/Write)
Default settings -> writeCfgReg(14751)
Bus Voltage Range = 32V
PGA (Shunt Voltage Only) = +/- 320mV
BADC Bus ADC Resolution/Averaging = 12bit
SADC Shunt ADC Resolution/Averaging = 12bit
Operating Mode = Shunt and Bus, Continuos
*/
// ina209a.writeCfgReg(14751); // Default settings no averaging
// ina209a.writeCfgReg(15839); // 8 averaging samples bus and shunt
ina209a.writeCfgReg(16247); // 64 averaging samples bus and shunt
// -------------- Calibration ------------------
/* Calibration Register 16h (Read/Write)
This register sets the current that corresponds to a full-scale drop ac
ross the shunt.
Full-scale range and the LSB of the current and power measurement depen
d on the value entered in this register.
See the Programming the INA209 Power Measurement Engine section of INA2
09 datasheet.
In this example:
Vbus_max = 32V
Vshunt_max = 0,32V
Rshunt = 0,05 Ohm
-> Max Expected Current = +/- 6A
Current LSB = 200uA
Calibration Reg = 4096
Power LSB = 4mW
Max Power = 204,8W
*/
ina209a.writeCal(4096);
// ---------- WARNING WATCHDOG REGISTERS -------
/* These registers set warning limits that trigger flags in the Status
Register
and activate the Warning pin.
*/
ina209a.writeShuntVolPwrn(30000); // set Shunt Voltage Positive
Warning limit to 30000 (= 300mV)
ina209a.writeShuntVolNwrn(-500); // set Shunt Voltage Negative
Warning limit to -500 (= -5mV)
ina209a.writePowerWrn(10000); // set Power Warning limit
ina209a.writeBusOVwrn(52000); // set Bus Over-Voltage Warning
limit, if you want a limit of 26V you have to set 26000*2 = 52000
ina209a.writeBusUVwrn(10000); // set Bus Under-Voltage Warning
limit, if you want a limit of 5V you have to set 5000*2 = 10000
// ---------- OVER-LIMIT/CRITICAL WATCHDOG REGISTERS ----------------
/* These registers set the over-limit and critical DAC limits that
trigger flags to be set in the Status Register
and activate the Overlimit pin or the Critical pin.
*/
ina209a.writePowerOL(12000); // set Power Over-Limit
ina209a.writeBusOVOL(60000); // set Bus Over-Voltage Over-
Limit, if you want a limit of 30V you have to set 30000*2 = 60000 (see the
datasheet for other functions)
ina209a.writeBusUVOL(6000); // set Bus Under-Voltage Over-
Limit, if you want a limit of 3V you have to set 3000*2 = 6000
ina209a.writeCrShuntPV(51200); // set Critical DAC+ Register
(Critical Shunt Positive Voltage). No sign bit (sets a positive limit
only). At full-scale range = 255mV; LSB = 1mV; 8-bit.
// if you want a limit of +200mV
you have to set 200*256 = 51200;
// this register control GPIO
PIN, see the datasheet.
ina209a.writeCrShuntNV(51200); // set Critical DAC– Register
(Critical Shunt Negative Voltage). No sign bit (sets negative limit only).
At full-scale range = –255mV; LSB = 1mV; 8-bit.
// if you want a limit of -200mV
you have to set 200*256 = 51200;
// this register control DAC
Comparator output filter, see the datasheet.
}
void loop() {
Note 1: We have sub divided this article for easy navigation as shown below:-
1. Pin Configuration 2. Block Diagram 3. Control and Display Commands 4. LCD
Interfacing 5. LCD Initialization
Note 2: If you are interested in reading about working of LCD – we have an excellent article
for you – Working of Liquid Crystal Displays (LCD)
Hitachi has set up a mile stone by its LCD controller IC. All the LCD displays use
the same, or any one of the IC s based upon the architecture introduced by Hitachi.
Ok, one minute, all I’m talking about is the character LCD display and not Graphical LCD
Display.
Most of the LCD Displays available in the market are 16X2 (That means, the LCD displays
are capable of displaying 2 lines each having 16 Characters a), 20X4 LCD Displays (4 lines,
20 characters). It has 14 pins. It uses 8lines for parallel data plus 3 control signals, 2
connections to power, one more for contrast adjustment and two connections for LED back
light. Let us have a look to typical pin configurations:
7 DB0
8 DB1
Bi-directional data bus, data transfer is performed once, thru DB0 to
9 DB2
10 DB3 DB7, in the case of interface data length is 8-bits; and twice, through
11 DB4 DB4 to DB7 in the case of interface data length is 4-bits. Upper four
12 DB5 bits first then lower four bits.
13 DB6
14 DB7
15 LED-(K) Back light LED cathode terminal
Data/Signals/Execution of LCD
Now that was all about the signals and the hardware. Let us come to data, signals and
execution.
LCD accepts two types of signals, one is data, and another is control. These signals are
recognized by the LCD module from status of the RS pin. Now data can be read also from the
LCD display, by pulling the R/W pin high. As soon as the E pin is pulsed, LCD display reads
data at the falling edge of the pulse and executes it, same for the case of transmission.
LCD display takes a time of 39-43µS to place a character or execute a command.
Except for clearing display and to seek cursor to home position it takes 1.53ms to 1.64ms.
Any attempt to send any data before this interval may lead to failure to read data or execution
of the current data in some devices. Some devices compensate the speed by storing the
incoming data to some temporary registers.
LCD displays have two RAMs, naming DDRAM and CGRAM. DDRAM registers
in which position which character in the ASCII chart would be displayed. Each byte of
DDRAM represents each unique position on the LCD display. The LCD controller reads the
information from the DDRAM and displays it on the LCD screen. CGRAM allows user to
define their custom characters. For that purpose, address space for first 16 ASCII characters
are reserved for users. After CGRAM has been setup to display characters, user can easily
display their custom characters on the LCD screen.
Images of LCD Display:-
Set
Display & Display(D),Cursor(C)
Cursor On/Off 0 0 0 0 0 0 1 D C B and cursor blink(b) 39 µs
on/off control
Write “20H” to
DDRAM and set
Clear Display 0 0 0 0 0 0 0 0 0 1 43µs
DDRAM Address to
“00H” from AC
AC -Address Counter
Outline
4) Others
The selection of RAM is set by the previous address set instruction. If the address set
instruction of RAM is not performed before this instruction, the data that is read first is
invalid, because the direction of AC is not determined. If the RAM data is read several times
without RAM address set instruction before read operation, the correct RAM data from the
second, but the first data would be incorrect, as there is no time to transfer RAM data. In case
of DDRAM read operation, cursor shift instruction plays the same role as DDRAM address
set instruction; it also transfers RAM data to the output data registers.
After read operation, the data address counter is automatically increased or decreased by 1
according to the entry mode. After CGRAM read operation, display shift may not be
executed properly.
*In case of RAM write operation, AC is increased or decreased by 1 like that of the read
operation. In this time AC indicates the next address position, but the previous data can only
by the read instruction.
Write binary 8bit data to DDRAM/CGRAM. The selection of CGRAM or DRAM is set by
the previous address set instruction; DDRAM address set, CGRAM address set. RAM set
instruction can also determine the AC direction to RAM.
By making this read out operation, it can be determined if the LCD is performing some
internal operation or not. If Busy Flag (BF) is high, some internal operation is going inside
the LCD at that particular moment. To perform further operation the data source (e.g. micro
controller) must wait for the BF to go low. Here, the address counter value can also be read.
Set DDRAM address to AC, this instruction makes DDRAM data available from MPU. In 1-
line display mode, DDRAM address rangers from “00H” to “4FH”. In 2-line display mode,
DDRAM address in the first line ranges from “00H” to “27H”, and DDRAM address in the
2nd line is from “40H” to “67H”.
Set CGRAM address to AC. This instruction makes CGRAM data available from MPU.
When 4 bit mode is activated, the data needs to be transferred in two parts, first higher 4bits,
and then lower 4 bits.
Without writing or reading the display data, shifting right/left cursor position or display.
This instruction is made to correct or search or display data. During 2-line display mode,
cursor moves to the 2nd line after the 40th digit of the 1st line.
When display shift is performed, the contents of the address counter are not changed.
C=’0’ turns off the cursor. But I/D register retains the data
B=’0’ stops the cursor to blink and cursor looks steady if the Cursor is turned on.
When I/D= ’1’ cursor moves to the right and DDRAM address is increased by 1.
When I/D= ’0’ cursor moves to the left and DDRAM address is decreased by 1.
This instruction sets the address counter to ‘00H’, and returns the cursor to the first column of
first line. And if display is shifted previously, this instruction shifts this too. The DDRAM
contents don’t change in this instruction.
Clear all the display data by writing “20H” (ASCII code of ‘space’ character) to all DDRAM
address, AND set value DDRAM address counter (AC) to “00H”. It returns the cursor to the
first column of first line and sets the entry mode to increment mode (I/D=’1’).
8-bit and 4-bit interfacing of LCD
Now the question is how to display data in the LCD or give command to it. There is two
modes of data transfer are supported by LCD displays. One is 4bit mode, another is 8 bit
mode. To transfer data In 8 bit mode, first put your data in the 8bit bus, then put command in
the command bus and then pulse the enable signal.
To send data in 4bit mode; first put upper 4bit in the 4 bit data bus connected to
4MSB pins of LCD display, then put control signals in the control bus, then pulse the E pin
once. Next put the lower 4 bit in the data bus and pulse the E pin again. Here is a flowchart
simply describing it.
LCD Initialisation
We are pretty familiar how to send data. But before displaying characters on the LCD
display, it must be configured first. To configure an LCD display, four command words must
be sent to LCD in either 4 bit mode, or in 8 bit mode. The commands are:
1. Function set
4. Display Clear
LCD Initialization
All these character display modules got the feature to create 8 user defined characters (ASCII
Codes 0…7) in addition to the ROM fixed codes.
1.) The command “CG RAM Address Set” defines the ASCII code (Bit 3, 4, 5) and the dot
line (Bit 0, 1, 2) of the new character. Example demonstrates creating ASCII code “00H”.
2.) Doing 8 times the write command “Data Write” defines line by line the new character. 8th
byte stands for the cursor line.
3.) The new defined character can be used as a “normal” ASCII code (0…7); use with “DD
RAM Address Set” and “Data Write”.
Now let us look up the character set that can be displayed using the LCD Displayed
0×00 0×10 0×20 0×30 0×40 0×50 0×60 0×70 0×80 to 0xd0 0xE 0xF
0 0
0x0D CG6 - = M ] m }
Custom Regional characters vary from manufacturer to manufacturer. The Greek letters may
or may not appear. It too depends upon the design.
Recommended alternative parts
INA219 - Smaller package in SOT23, and does not include watchdog features.
Description
The INA209 is a high-side current shunt and power monitor with an I2C interface. The
INA209 monitors both shunt drop and shunt bus voltage. A programmable calibration value,
combined with an internal multiplier, enables direct readouts in amperes. An additional
multiplying register calculates power in watts. The INA209 features two separate, onboard
watchdog capabilities: a warning comparator and an over-limit comparator. The warning
comparator is useful for monitoring lower warning limits and incorporates a user-defined
delay. The over-limit comparator assists with monitoring upper limits that could require
immediate system shutdown.
The INA209 can be used together with hot swap controllers that already use a current sense
resistor. The INA209 full-scale range can be selected to be either within the hot-swap
controller sense limits, or wide enough to include them.
The INA209 senses across shunts on buses that can vary from 0V to 26V. The device uses a
single +3V to +5.5V supply, drawing a maximum of 1.5mA of supply current. It is specified
for operation from -25°C to +85°C.
Features
SENSES BUS VOLTAGES FROM 0V TO +26V
REPORTS CURRENT, VOLTAGE, AND POWER; STORES PEAKS
TRIPLE WATCHDOG LIMITS:
o Lower Warning with Delay
o Upper Over-limit, No Delay
o Fast Analog Critical
HIGH ACCURACY: 1% MAX OVER TEMP
APPLICATIONS
o SERVERS
o TELECOM EQUIPMENT
o AUTOMOTIVE
o POWER MANAGEMENT
o BATTERY CHARGERS
o WELDING EQUIPMENT
o POWER SUPPLIES
o TEST EQUIPMEN
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!
Transformers
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.
This will convert
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:
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.
So now we get:
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!
The transformer AC/DC in practice
OK now that we've reviewed transformers, diodes when used as rectifiers and big capacitors, lets
look at a chunky plugpack again. This time, we'll look inside by cutting it in half! This power supply is
rated at9VDC @ 200mA.
We can pull it out completely to see the circuit board parts.
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.
These transformer-based plug-packs are really cheap to make - like on the order of under $1!
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.
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.