0
\$\begingroup\$

I recently bought an Arduino starter kit which comes with an Arduino Uno and some components. I know very little about electronics or physics. The Arduino has some analog-to-digital pins on it which allow you to measure, in code, the voltage "sent to" that pin. What I don't quite understand is which voltage it measures and how.

I set up a test circuit and some code to print out the voltage measured by the input pin. I wired three 220 ohm resistors in series, then connected a wire to the A0 analog-to-digital input pin on the Arduino, and with the other end of the wire probed different points along the circuit. You can see this in the diagram. Note that the four branches coming out of the A0 pin were never all wired up at once, that's just to represent the four points A, B, C and D on the circuit that I probed. Next to each point I've written the voltage that I measured there.

enter image description here

I understand that what I'm measuring at point X is the voltage "between" X and the ground, dropping by 1.66V after each resistor. What I still don't really understand is how the pin measures this. I'm not really looking for an actual explanation of how the voltmeter inside the pin works, just some kind of high level conceptual understanding. For example, one thing that confuses me is that once the A0 pin is connected to the circuit, what I have isn't really a "circuit" anymore, in the way I usually think about them. It's not a straight line from source to ground with components along it. I clearly can't think of the A0 and the wire connecting it to the circuit as just one big component, like the resistors, because that would imply current is traveling both up and back down the wire connecting A0 to the circuit. So how should I think about the A0 pin? Is it like a secondary connection to the ground? A secondary connection to the source? If it's a connection to the ground, wouldn't that imply, due the principle of the path of least resistance, that if I connect it to say point A, no current will travel through any of the resistors?

\$\endgroup\$
3
  • \$\begingroup\$ What point X? A0 would read 0 volts if the 5 volt supply were not so completely shorted out. \$\endgroup\$
    – Andy aka
    May 11 at 18:34
  • \$\begingroup\$ From your mention of "the principle of the path of least resistance", I think you have a common misconception of beginners. Current will flow in all possible paths, with the greatest current flowing in the path having least resistance - but current will also flow in paths having higher resistance. \$\endgroup\$ May 11 at 18:35
  • \$\begingroup\$ See also this question on the Arduino SE \$\endgroup\$
    – Jack M
    May 12 at 20:45

2 Answers 2

1
\$\begingroup\$

The pin can be used as a voltage input for an analog to digital converter (ADC) and the conversion result is a digital value of the measured voltage.

There is no current flowing in or out the analog input pin (in an ideal world there isn't, in real world there is but that is not the point we need to get stuck on and you normally don't need to think about it so it can for now simply be ignored for simplicity).

Basically, that's identical to connecting a multimeter for measuring the voltage. Black lead to ground (0V) and red lead to the point you want to measure.

The ADC measures the voltage on analog input pin in reference to the ground, so if there is 1.66V on the node between resistor and you measure that with multimeter or analog input pin, you get a digital result as a number that matches 1.66V.

If you want to know how the ADC works, just open the microcontroller data sheet to see a block diagram.

\$\endgroup\$
3
  • \$\begingroup\$ But if I point the black probe of a multimeter to ground and put the red probe somewhere on this circuit, conceptually that's like just attaching a wire from that point in the circuit directly to ground, right? How come all the current doesn't just instantly void the part of the circuit past where the red probe is, and just all flow down that wire into the ground? Isn't that the path of least resistance? \$\endgroup\$
    – Jack M
    May 11 at 18:37
  • \$\begingroup\$ Maybe this is a better question. Are the two circuits in this picture basically equivalent? Can I think of the line going to A0 as basically going to ground, with some kind of magical volt-reading component in the middle of it? \$\endgroup\$
    – Jack M
    May 11 at 18:53
  • \$\begingroup\$ No, putting a voltmeter over some component does not short it. If you measure a 9V battery it measures 9V, if it did short it then it would read 0V. Voltmeters have very high input impedance. Neither voltmeter input or Arduino analog input (which you can think as a voltmeter) do not connect anything to ground as they are not short circuits or pieces of wire. The impedance is so high you can think infinite, and infinite impedance means open circuit, not short circuit. So yes, your magical voltmeter does equal to Arduino analog input, just no current flows through the magic voltmeter. \$\endgroup\$
    – Justme
    May 11 at 19:00
1
\$\begingroup\$

If I understand you right, you are under the impression that the ADC is internally connecting some "probe point" directly to ground, forming a zero resistance current path. This is very wrong.

It's true that some current does flow into that ADC pin A0, but the idea is to make that current negligibly small, so that it doesn't upset the circuit's normal operating conditions. That is, the measurement should aim to pretend as if it's not even there.

The same goes for a multimeter (measuring voltage) between two points, which is essentially the same situation. You apply the probes at two points, and somehow read the difference in potential between them, the goal being to do so without the system under test even knowing that something else has been connected.

The requirement for a multimeter (or any ADC), then, is to have an extremely high electrical resistance between its probes (or pins), so high that the current actually passing via that new route is negligibly small. In the case of your Arduino, the path from A0 to GND (inside the IC) is extremely high, many megohms.

As I said before, some tiny current will flow, and this permits some minuscule amount of energy to be extracted from the circuit under test, for the actual measurement to take place, but it's only a tiny perturbation.

Therefore, since A0 is not "loading" the measurement point, not drawing significant current out of that point, or injecting any significant current into it, current is not diverted away from the intended path. The current through your chain of 220Ω resistors remains unchanged, and the voltage across each resistor therefore also stays unchanged. Almost.

If internally your ADC was a current hungry, low resistance path to ground, then clearly it would grossly upset the very conditions that it's trying to measure, as you correctly pointed out, and the measurement would be completely useless. It would be like stopping the car in order to measure its speed.

\$\endgroup\$
4
  • \$\begingroup\$ So in this picture that I posted elsewhere, the two pictures are basically equivalent as long as we add an extremely high-resistance resistor between the "magical voltmeter" and the rest of the circuit? \$\endgroup\$
    – Jack M
    May 12 at 9:33
  • \$\begingroup\$ @JackM I don't know what you mean by "add an extremely high resistance". The voltmeter and A0-GND are already extremely high resistances, no resistance needs to be "added". Otherwise those two are equivalent. Also, voltage is "across" things or "between" nodes, current is "through" things. \$\endgroup\$ May 12 at 12:33
  • \$\begingroup\$ Let me try to state it more clearly - in this diagram, the voltage between nodes A and B in the right-hand circuit is the same as the voltage measured by the A0 pin in the first circuit, is (by Kirchhoff's law?) the same as the voltage drop between node B and the ground would be if the branch with the red resistor on it weren't there. This would be true even if the red resistor was 0Ω, but in practice we make it high resistance so as to disturb the current in the main circuit as little as possible. Is that right? \$\endgroup\$
    – Jack M
    May 12 at 13:39
  • \$\begingroup\$ @JackM I think I get you - the red resistor influences the voltage between A and B. That voltage difference lowers somewhat with the red resistor present, down to 0V if that resistance were 0Ω. However, don't forget, A is ground, 0V. On the left, the ADC is measuring the potential at B, relative to ground. \$\endgroup\$ May 12 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.