Electricity Primer: Difference between revisions

From Phidgets Support
 
(188 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Introduction==
#REDIRECT [[Improving Phidgets Hardware Reliability]]
 
This primer will help you power your Phidgets while being safe to the electronics.  It applies to Phidgets that:
# Use additional or external power such as being plugged into the wall power or a battery, e.g:
#* Motor controllers
#**[[DC Motor and Controller Primer|DC controllers]]
#**[[Stepper Motor and Controller Primer|Stepper controllers]]
#**[[Servo Motor and Controller Primer|Servo controllers]]
#* Pure relay boards
#**[[Solid State Relay Primer|Solid state relay boards]]
#**[[Mechanical Relay Primer|Mechanical relay boards]]
#* Interface kits with relays
#**[[Product - 1017 - PhidgetInterfaceKit 0/0/8]]
#**[[Product - 1014 - PhidgetInterfaceKit 0/0/4]]
#* Powered Digital Output Interface Kits
#** [[Product - 1012 - PhidgetInterfaceKit 0/16/16]]
#* Interface Kits with Powered Hubs
#** The [[SBC|Single Board Computer]]
#** [[Product - 1019 - PhidgetInterfaceKit 8/8/8 w/6 Port Hub]]
# Need to be sensitive to external power such as powered digital inputs or analog voltage outputs, e.g.:
#* [[Temperature Sensor Primer|Thermocouple]] control
#* Analog Output ([[Product - 1002 - PhidgetAnalog 4-Output]])
#* Frequency Counter ([[Product - 1054 - PhidgetFrequencyCounter]])
 
You've also come to the right place if:
* You're looking to learn concepts for how to properly power a self-sufficient, wireless, battery-powered robot (or weather station, control center, etc.)
* You're looking to use more than one motor controller or relay board and not destroy your controller or your PC in the process
* You need to isolate power in or out of the Phidget to control systems or make measurements as precisely as possible
 
This page covers [[#Power Needs|Power Needs]] including choosing a power supply, [[#Selecting Cables|Choosing Cables]], and finally [[#Hooking Up The Pieces|Hooking Up The Pieces]] and carefully grounding your system.  Each section begins with the pertinent basic concepts.
 
You do not need to know much about electrical engineering to design a relatively robust system.  However, without some forethought to power needs, cables, and hookups, you can generate problems ranging from spurious and strange to even destroying your Phidget and/or your computer's USB hub.
 
==Power Needs==
 
This section will help you choose a power supply for your Phidget.  Let's say you want to run the [[SBC|Single Board Computer]] off of a battery.  Or you want to run a motor controller with a power supply you bought from the hobby store.  What do you need to buy?  Will one you already have work?  It is worth it to spend a moment with pencil and paper to work through this section and identify your power needs.
 
===Voltage And Amperage===
 
Power supplies - whether wall power or batteries - are rated based on voltage and amperage. 
 
These two concepts can be described with an analogy: a circuit is like a water faucet.  '''Voltage''' is the pressure on the faucet, and the water supply is '''amperage''', also known as current.  Voltage is indicated with a V, and amperage with an A.
 
Too much pressure behind your faucet, and the water mains or faucet will break.  Likewise, if you have too much voltage from a power supply, your circuit will break.  You should choose a supply with voltage that ''matches the range the Phidget can accept''.  The voltage cannot be over the maximum (otherwise, like pressure in a pipe, the pipe will burst), and the voltage cannot be under the minimum (otherwise, like pressure in a pipe, no flow will occur).
 
But the faucet doesn't care whether there is a big reservoir or small reservoir feeding the system, as long as the pressure is managed.  Likewise, you can choose a power supply with more amperage than you need (a big reservoir to draw from) as long as the voltage matches.  In the same way that a faucet restricts water by design, electrical circuits draw and allow only the amperage that they need. However, the amperage cannot be less than the Phidget needs.  In that case, you will either overextend (and break) your power supply, or the circuit simply will not turn on at all.
 
The specification [[#Device List|for your specific device]] will list its power needs. For most devices, the external power supply needs will simply be listed in voltage and amperage.  USB power is 5V at up to 500 mA (0.5 Amps).  However, some Phidgets (e.g. motors, and the [[SBC|Single Board Computer]]) do not have a straight amperage and voltage specification.  Instead, their power draw will be listed in '''watts'''.  Knowing the watts and either the voltage or the amperage can give you the missing piece using this relation:
 
<math>
\text{Amperage} =\frac{\text{Watts}}{\text{Voltage}}
</math>
 
To obtain your power, you can get it from the [[#Wall Power|wall mains]], or from a [[#Battery Power|battery bank]].
 
===Wall Power===
 
Wall power sources usually take the alternating current (AC) from the wall and convert it into a direct current (DC).  These power supplies often take your familiar two-or-three prong wall connector and put power out via a barrel plug-type connector.  AC power (typically 110 or 240 volts, depending where you live in the world) goes in the typical wall plug, and DC power (typically 5 to 24 volts) comes out the barrel plug.  Most power supplies of this type list the conversion explicitly, such as: 110-240 Volts to 12 Volts at 2 Amps.  You'll want to match your Phidget's needs against the 12 Volts at 2 Amps.
 
A wall power supply is essentially an inexhaustible supply of current, so you don't need to worry about it running out like you would with batteries.
 
===Battery Power===
 
If you intend to use a battery bank (even of only one battery) to power your Phidget, you probably want to know what type of battery to purchase. 
 
Batteries are chosen first by their voltage (V).  Match the voltage exactly to the voltage the Phidget needs.  Over or under this value, you could harm the board or have it simply fail to turn on.
 
Next, choose a battery that has adequate amperage to feed your device for the time you need. The lifespan of the battery will usually be listed in Amp-Hours (or Ah).  For example, a double wide 12 V lantern battery will have usually around 7-8 amp hours.  This means if you drew one amp from it for seven to eight hours, the battery would be totally drained.  Or you could draw two amps from it and drain it in 3.5-4 hours.  A deep cycle rechargeable 12 V car or marine battery for use in a solar setup, as another example, would have 70-100 amp hours.
 
Finding the amperage or voltage sometimes needs to be done indirectly by using a specification of watts.  The relationship between amperage, voltage, and watts is given above in the [[#Voltage And Amperage|voltage and amperage section]].
 
For an example, let us say you want to use battery power to run the [[SBC|Phidget Single Board Computer]].  The specifications say that it uses 1.2 watts as a base value.  The specifications also say that it can take 12 V DC power.  If we choose to use a 12 V battery, at 1.2 watts it will use 0.1 amps according to the equation above.  Going by amp-hours alone, if our battery is a double-wide lantern type 12 V battery, with 7 amp hours, with 0.1 amp draw it will last 70 hours, or almost three days.
 
<math>
\text{Maximum Running Days} =\frac{\text{Battery Amp Hours}}{\text{Device Amps} * \text{24}}
</math>
 
However, to estimate ''average'' running time (rather than maximum running time possible), amp-hours cannot be used so directly.  Over time, batteries decrease in voltage as their power is used up.  Practically speaking, this means that a connected device will draw more amperage.  Say that our 12 V battery has decreased to 10.9 volts due to its amperage being slightly drained.  Using the SBC example above, at 1.2 watts the SBC would now draw 0.11 amps, which would escalate the draining of the battery. The draining would further reduce the battery voltage, which would increase the amperage draw, and so on, creating a cycle.
 
You should usually only count on about 60% of the stated amp hour rating to apply before expecting to run into problems from escalated drain due to battery voltage drop.  This is especially true for deep cycle rechargeable batteries left in an installation, where draining more than 60% could also harm the battery. 
 
Then, for lead-acid batteries, a typical battery is tested from full to complete drain over 20 hours by the manufacturer to obtain the advertised amp-hour rating.  Draining a battery at a faster rate than this will result in even more reduction in capacity, by 10% or more.  This due to [http://en.wikipedia.org/wiki/Peukert%27s_law Peukert's Law].
 
There are plenty of [http://www.google.ca/search?&q=battery+calculator battery calculators] around the Internet which take most or all of these additional factors into account when recommending an amp-hour rating.  For longer-term installations, the solar power online community has some excellent resources.
 
You can hook up multiple batteries in series to get more voltage at the same amperage.  The amperage is additive.  For example, you can hook up two single-wide 6 V lantern batteries in series to produce 12 V.  Or two 12 V batteries in series to produce 24 volts.  This system would still only have the amp hours of ''one'' of the lantern batteries, because you will be essentially using them both at once:
 
[[Image:elec_battery_series.png|250px]]
 
The upside down triangle (ground) is explained below in a [[#Ground|section of its own]].
 
Or, you can hook up multiple batteries in parallel to get more amperage at the same voltage.  For example, you could hook up two 12 V deep cycle batteries in parallel to provide more amperage at 12 V, which is like having a deeper reservoir of power for your device to use:
 
[[Image:elec_battery_parallel.png|250px]]
 
Finally, weight matters - a car battery is much heavier than a lantern battery.  Batteries vary widely by weight per amperage.  Lithium batteries are usually very light for their power, followed by alkaline, followed by lead acid.  This may not seem important at first, but if you are building a mobile robot it is worth calculating in the work of carting around a battery.  You may find that, for the length of time you want it to run, your battery requires some system redesign.
 
===Multiple Devices===
 
If you are using multiple of the same Phidgets, they probably take the same voltage.  Therefore, you can hook them up in parallel to one another, where the power supply is split into one branch per Phidget, and then the grounds are combined and connected to the power supply ground.  There is an image to show a parallel hookup (using batteries rather than Phidgets) in the [[#Battery Power|battery power section]] above.  This will hold the voltage across all the Phidgets at the same value as the power supply.
 
However, the current (amperage) consumption of the Phidgets must be added together to determine the total amperage you need.  This is the same as the battery diagram, but instead of calculating produced power, you are calculating consumed power.
 
==Selecting Cables==
 
===USB Cables===
 
In general, use the shortest cables possible.  There are many reasons for this:
 
; Long cables reduce the voltage that reaches the Phidget.
: This happens in both directions.  So, for every unit cable length added, the voltage decreases by twice the electrical resistance of that length of cable. With especially long cables (&gt; 5m) the Phidget may drop below its 4.6 volt threshold and simply never turn on.
 
; Long cables increase the width of your circuit. 
:All circuits act as emitting antennas for the resonance frequency of the circuit structure.  The longer the wires in the circuit, the lower the frequency, and the higher chance that it will be emissions that will interfere with your data and system.
 
; Longer cables have more length exposed to external interfering emissions.
 
Also, use thick cables that are built to specification.  Some USB cables with thinner wiring have higher electrical resistance.  This can be equal to what a much longer wire would have, and thus create a similar voltage drop where the Phidget will not turn on. 
 
===Power Cables===
 
There are "DC Wire Table" references on the Internet which describe how to pick a wire appropriate for your voltage and amperage. 
 
As with the USB cables above, cut the cables to the shortest length possible.  This is again both for voltage drop reasons and frequency emission reasons.
 
===Hubs===
 
Avoid hubs where possible.  Unpowered hubs are good for reading data from memory keys, but not for powering many external devices.  If you must use a hub, buy a powered one.
 
==Hooking Up The Pieces==
 
Here, things can be tricky.  You might think: just plug everything in and go!  But often it is not that simple.  Systems that require special attention in hooking things up are:
* Projects with two different power supplies, including:
** Motor controllers
** Pure relay boards
** Interface kits with relays (0/0/4)
** Powered Interface Kits (0/16/16)
** The Single Board Computer
* Projects that need sensitivity to the local system being controlled or measured, including:
** Thermocouple control boards
** Analog output boards (1002)
 
Both types of projects require an understanding of [[#Ground|electric ground]], as discussed below.  Projects with two different power supplies but no measurement or control are only subject to the [[#Powered Phidgets|powered Phidgets problems]] below.  Projects that additionally need system sensitivity for measurement or control are subject to the [[#Powered Phidgets|powered Phidgets problems]] and the demands for [[#Precise Voltage Control|precise voltage control]].
 
===Ground===
 
All circuits have a '''ground'''.  This electric ground provides a voltage reference throughout the circuit.  Ground is always '''0''' volts as far as the circuit is concerned.  The reference allows all the parts of the circuit to speak the same language to each other, which matters a lot when a certain voltage means "1" and a certain voltage means "0". 
 
There is only one '''absolute''' ground, and that is the Earth, which is taken to be 0 volts as an absolute value.  Circuits not well-grounded to the Earth (of which there are many - your cell phone, car, etc) operate at a '''relative''' voltage.  Local ground is denoted by an upside-down triangle:
 
[[Image:ground.png]]
 
With relative voltage, only the difference between local ground and the local high voltage matters.  For example, a cell phone might operate as a 3 volt device, which means relative to its ground it always operates between 0 and 3 volts.  But if that cell phone were compared carefully to Earth ground, its absolute voltage could be, say, between 10 and 13 volts.  Until comparison, the device doesn't "feel" charged.  This is the same as how you don't "feel" charged after skidding your feet in socks across a carpeted floor.  But, when you "compare" yourself to Earth ground by touching some well-grounded metal, you receive a static electricity shock.
 
The same thing can happen when you combine two different power supplies, as we discuss [[#Projects With Different Power Sources|below]].
 
===Shielding===
 
From the mention of emissions in the [[#Selecting Cables|cables section above]], you might be tempted to try to shield parts or all of your system from emissions that either your system or external systems create. 
 
Keep in mind that shielding is actually really hard to do correctly.  Especially when grounding your shielding, with ad-hoc design you have a high chance of having an interfering signal (that has traveled out to the shield and traveled back via ground) creating a larger problem than not having a shield at all.  Rather than shielding, it is easier to simply keep your cables short and with as low a resistance as possible throughout your system to minimize your emissions in the first place.
 
===Projects With Different Power Sources===
 
The simplest setup for a Phidget is to use the ground of the computer it gets data and power from over a USB port:
 
[[Image:ground_simple_case.png]]
 
In this case, there is only one relative ground, and it is the PC ground, which is ground #1 in the image.  The PC ground determines what is considered 0 volts for all signals on the Phidget.  When you add different power sources or sinks in the system, you are pulling the system relative to the PC ground. 
 
Recognizing the sharing of a ground is not always easy.  Two common situations where ground gets shared are discussed below - [[#Powered Phidgets | powered Phidgets]] and [[#Precise Voltage Control | precise voltage control]] - as well as ways to manage the sharing.
 
====Powered Phidgets====
 
Powered Phidgets are those Phidgets that run on USB power ''and'' some external power.  We examine two cases below: a single powered Phidget, and multiple powered Phidgets.
 
=====One Powered Phidget=====
 
Let us say you have a motor controller, which takes power from USB, and also takes power from a second power source.  Although the second power source is usually just a wall plug, the simpler case for thinking about ground is actually a battery.  A battery creates a second ''relative'' ground.  Through the Phidget, relative ground #1 (from the PC) and #2 (from the battery) actually become the same ground:
 
[[Image:ground_wall_power.png]]
 
This is why systems with powered Phidgets have to carefully manage ground.  If ground #1 and ground #2 are different with respect to each other (see the static shock analogy in the [[#Ground|ground section]] above), then whatever circuitry along the red dashed arrow must deal with the initial static shock.  In this case it would be the circuitry of the Phidget.  In the case of a battery, after the initial equalizing shock the battery will be whatever relative voltage the PC ground needs it to be.  Hence a battery relative ground can 'float'.
 
If ground #2 comes from the wall, on the other hand, the ground does not 'float' and instead is always absolute 0 volts Earth ground.  With the PC giving the power, this is not a problem in practice because the PC can also float.  But if you were using a different and more powerful USB power supply instead of a PC, and then connected it to the absolute Earth ground through the Phidget, the Phidget would bear the brunt of any ground equalization that would occur.  If neither the new ground nor the old ground float, and the power supplies were powerful enough, this would eventually destroy the Phidget.  In this case, you would want to use isolation, as described in [[#How To Fix This|How To Fix This]] below.
 
=====Multiple Powered Phidgets=====
 
A worse case comes in when you are using two powered Phidgets and one external power source.  Again, say you are using a battery as the external power source.  It would be tempting to simply wire both grounds from the Phidgets to the ground on the battery:
 
[[Image:ground_two_phidget.png]]
 
Although this looks benign, you have actually created a new circuit.  The circuit is a second path, via ground, for the current to return to the voltage source.  This is also known as a '''ground loop'''. The path we intuitively think of the current returning by is  '''<span style="color:blue;">path A</span>''', but the sharing of grounds has created a new path through the motherboard, '''<span style="color:red;">path B</span>''':
 
[[Image:ground_two_paths.png]]
 
All current gets 'pumped' in a loop by voltage, and so it will use all return paths available to it, assuming all paths are equally easy (electrically) to use.  This extends the pipe analogy, where water will flow in every path that exists.  So, if your battery (or other power source with ground #2) is quite powerful, you can actually harm your motherboard within your PC (or at least your USB bus ground), because '''<span style="color:red;">path B</span>''' runs through the motherboard circuitry on the way back to the voltage source.
 
=====Single Board Computer And Powered Hub=====
 
When combining one externally powered Phidget and the [[SBC|Single Board Computer]] or the [[Product - 1019 - PhidgetInterfaceKit 8/8/8 w/6 Port Hub]] on the same external power source, you still may inadvertently create a ground loop as described above in [[#Multiple Powered Phidgets|the multiple powered Phidgets section]].  If they share a true [[#Ground|Earth ground]], this is not a problem.  But if the ground is from a battery, or uninterruptible power supply, etc. then you should carefully draw out your system circuit and examine it for ground loops.
 
=====How To Fix This=====
 
Once you are aware of shared grounds in your system, you have two options. 
 
One, for ground loop problems, you could make the normal return path ('''<span style="color:blue;">path A</span>''') the most electrically desirable path.  This is best for simple systems where you have a lot of control over all of the ground wires within your system.  For the ground wires leading directly from the Phidget to the external power supply ('''<span style="color:blue;">path A</span>'''), lower the resistance in the wire as much as possible.  You can do this by keeping the wires short, and using a thick (large gague) wire for the hookups. 
 
Although this solution works, sometimes you do not have much choice on how long your ground return wires can be, because the location of your power supply and and Phidgets are set by your system design.  If you cannot be totally sure that the direct ground path is the shortest and most electrically desirable path, it is best to use the second option: a '''USB Isolator''' such as the Phidget 3060. 
 
You need isolators for every USB cable in your system, less one.  If you have two USB connections, you need one isolator; three USB connections, two isolators, and so on.  The one USB connection can remain non-isolated because a single ground connection cannot form a loop, as above.
 
This problem does ''not'' apply to using a different power source between a black power plug and for the green control terminal block on, say, a DC motor controller.  Although the grounds are connected, and they run across a part of a Phidget board, creating a ground loop does not actually run through any circuitry if only these types of boards are used.  If you have a complex system with other types of boards and therefore circuitry between black plug power port and green terminal block connections, draw out your system carefully to identify the loops, and use USB isolators where needed.
 
====Precise Voltage Control====
 
We make Phidgets that can create power precisely, or that can take it in and measure it.  One example is the 1002, which outputs a precise analog voltage with which to control an analog system.  Now that you know about [[#Ground|relative ground]], however, you would be right to expect that you do not want to combine the ground in the PC and the ground in the system.
 
First, with multiple Phidgets, you can have the ground loop problems discussed above in the [[#Powered Phidgets|powered Phidgets section]].  In addition, if you are using the Phidget to control a large, powerful powered system, even a single Phidget can receive damage from connecting two powerful power sources
 
But there is another reason to separate (isolate) the electrical grounds in your system.  The reason is: to make your system control more precise.  For example, with the 1002, if you are trying to control an external system with an Phidget output voltage, that output voltage should be relative to the ''system you are trying to control'', not relative to the PC.  Rather than forcing the grounds - and therefore the relative voltages - to be equal to each other, you can provide more precise control by isolating the grounds and working with the relative voltage of the controlled system on its own terms.
 
<span style="color:red;">Schematic-type image of a ground isolated analog out on a 1002</span>
 
The solution to all of these problems is to use USB isolation, even for a single Phidget.  The Phidget 3060 is one such isolator.  It inserts along the USB connection between your PC and the Phidget, and it separates the Phidget (and controlled system) ground from the PC ground.  This fixes ground loops, separates relative voltage mis-matches, and isolates the control system for better precision. 
 
<span style="color:red;">Image of 1002 and Isolator connected, with lines superimposed on the image to show non-copper connection in isolator</span>
 
==Conclusions==
 
This page should have helped you to:
*Choose a power supply from either the [[#Wall Power|wall]] or a [[#Battery Power|battery]]
*Properly [[#Ground|ground]] and/or [[#How To Fix This|isolate]] that power supply from looping through other circuitry
*Also use [[#How To Fix This|isolation]] to make your control or measurement system more precise
*Keep your cables short and thick to reduce electromagnetic emissions
*Be more aware of system-wide power problems in general.

Latest revision as of 18:53, 22 October 2019