John Errington's Experiments with an Arduino
Important notes on power supplies and grounds
Power supplies and connecting wires are NOT "IDEAL"
Power supplies and connections can often be a source of problems in a practical circuit - but are often ignored during design, and even not shown on a schematic.
if your project includes any of the following:
- components that take significant current
- inductive or capacitive loads
- analog inputs
- multiple power supplies
and if you are having problems with instability or inaccurate readings then perhaps you should examine your design or layout in the light of the following explanations.
Practical circuits
The "ideal" circuit is the way we usually treat power supplies.
However:
a "real world" power supply is NOT a perfect voltage source, but has a source resistance Rs; and
the wires, connections and circuit board tracks also have resistance, inductance (and capacitance) - shown R1 L1, R2 L2.
The "practical circuit" is the same circuit for a switched resistive load, but showing the effect of the source resistance and distributed resistance and inductance of the circuit as built.
A common error in circuit layout.
R1 represents the resistance in the ground line.
Suppose the total ground line resistance is 0.1 ohm.
The large current i1 that flows when the motor is turned on causes a voltage across R1.
A motor taking 2 amps will produce a voltage of 200mV across R1
This causes the voltage on A0 to be increased - so you get an incorrect reading.
The tiny current (1mA) that flows when the switch is pressed won't have much effect.
A better layout - seperate Analog, Digital and Power grounds connected at a "STAR POINT"
In this circuit each of the ground connections is kept entirely separate until they meet (as they must) at a single common point - a "star point".
By arranging your grounds in this way the voltages developed in the motor or "power" ground and the logic ground will not affect the ADC reading.
Driving LEDs - and the Arduino ground
Dont ignore the currents flowing in the Arduino ground!
In this diagram each LED takes around 10mA when lit.
If all 4 are lit thats 40mA - and the current flows from the 5V rail, through the resistor and LED, then through the Arduino to ground.
The whole 40mA appears across R1!
In this case your analog ground must be connected directly to the ground pin on the arduino so the voltage across R1 does not affect your reading.
However ideally the resistance of the ground connection between the arduino and the 0V star point should be very low.
Summary
To summarise: if you have
- large currents - say over 100mA, especially if they are being switched; and/or
- particularly sensitive inputs such as analog measurements
you should pay attention to the layout of your ground connections to prevent unwanted results.