Pages: [1]   Go Down
 Author Topic: Calculating input voltage beforehand [Newbie question]  (Read 769 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 7
 « on: May 14, 2013, 05:11:40 am » Bigger Smaller Reset

Being new to electronics I'm trying to wrap my head around the arduino and how to calculate what readings I will get using a pin to read the voltage. But I have no idea how to do the math. I even tried using circuit lab but to no prevail.

The reason why I'm confused is that I thought you could only measure voltage between to points and the potential difference between them. But the arduino measures at a specific point; the pin. How can I calculate that beforehand?

It would also be nice to know how I could then simulate the arduinos readings in circuit lab

Thanks
 Logged

Johannesburg. UTC+2
Online
Karma: 91
Posts: 4198
 « Reply #1 on: May 14, 2013, 05:19:08 am » Bigger Smaller Reset

I'm not 100% sure what you're getting at, but this might answer your question.

The Arduino does use two pins to read an input: there's a ground as well as the pin you're using. So if you had 3xAA cells giving out about 4.5v, and you poked the +ve with a wire from an Arduino pin, you would get no reading. But if you connected the Arduino ground to the -ve of the battery, then you would get a reading: a digital pin would read a high, and an analog would give you about 0.9 of the 1023 max reading, ie about 920.
 Logged

Roy from ITCrowd: Have you tried turning it off an on again?

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #2 on: May 14, 2013, 06:09:27 am » Bigger Smaller Reset

Thanks, that makes my mental model better.

But if I added a resistor to that circuit then the voltage readings would be the same, correct?
So if I wanted to vary the voltage to an analog pin depending on the resistance of a wire.
How would I then hook it up and calculate the voltage to the pin it?
 Logged

Johannesburg. UTC+2
Online
Karma: 91
Posts: 4198
 « Reply #3 on: May 14, 2013, 07:52:14 am » Bigger Smaller Reset

Ah, then what you want is to look at a voltage divider, where the output voltage (which I guess then becomes your input voltage) depends on the ratio of the two reseistances.

In fact, a potentiometer is exactly that, where the "mid-point" actually moves along a long resistor. Pots have 3 connections: the "top" being the input voltage, the "bottom" being ground, and the "moving mid-point" is your variable output. Have a look at this tutorial.

 Logged

Roy from ITCrowd: Have you tried turning it off an on again?

0
Offline
Shannon Member
Karma: 206
Posts: 12048
Arduino rocks
 « Reply #4 on: May 14, 2013, 09:16:50 am » Bigger Smaller Reset

Thanks, that makes my mental model better.

But if I added a resistor to that circuit then the voltage readings would be the same, correct?
So if I wanted to vary the voltage to an analog pin depending on the resistance of a wire.
How would I then hook it up and calculate the voltage to the pin it?

Since the Arduino ADC has an extremely high input resistance (10^10 ohms or more) then a
series resistance isn't going to change the reading perceptibly.  Your multimeter might be
affected (since it probably has a 10Mohm input resistance - and thus takes current from
the circuit it measures.

The reason for this in multimeters is specifically because they have resistor dividers to allow
different ranges - a resistive divider has finite resistance.

The Arduino ADC doesn't actually measure voltage at all, it measures the ratio of voltages, namely
the ratio of  (pin - ground) / (Vcc - ground).  So when powered at 3.3V it reads differently than
if powered at 5V.
 Logged

[ I won't respond to messages, use the forum please ]

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #5 on: May 14, 2013, 06:15:24 pm » Bigger Smaller Reset

Ah, then what you want is to look at a voltage divider, where the output voltage (which I guess then becomes your input voltage) depends on the ratio of the two reseistances.

In fact, a potentiometer is exactly that, where the "mid-point" actually moves along a long resistor. Pots have 3 connections: the "top" being the input voltage, the "bottom" being ground, and the "moving mid-point" is your variable output. Have a look at this tutorial.

Interesting! But how do I go about calculating this? I would be great to have a general rule to calculate the voltage to the input pin. No matter the resistance and the amount of paths the current can flow in.
 Logged

Offline
Edison Member
Karma: 33
Posts: 1307
 « Reply #6 on: May 14, 2013, 07:05:22 pm » Bigger Smaller Reset

Quote
I would be great to have a general rule to calculate the voltage to the input pin. No matter the resistance and the amount of paths the current can flow in.
There is!      Ohm's Law describes the relationship between voltage, resistance, and current.    kirckhoff's Laws describe how voltages & currents are distributed in series & parallel circuits.   (i.e. How a voltage divider works.)

Those things aren't necessarly that easy to understand.. it's a good part of your 1st semester in a basic electronics class.

In most real-world applications, the high impedance (resistance) of the Arduino input, means that the Arduino itself essentially has no effect on the voltage...   It depends on the external circuit.

The exception is if you try to put-in more than 5V, or a negative voltage.   In those cases, the Arduino's internal protection diodes start conducting, and you suddenly have very low impedance.  And, if too much current flows through those protection diodes they will fry, and you will kill your Arduino...

 Logged

the land of sun+snow
Offline
Karma: 159
Posts: 2916
 « Reply #7 on: May 14, 2013, 08:47:43 pm » Bigger Smaller Reset

Quote
The reason why I'm confused is that I thought you could only measure voltage between to points and the potential difference between them. But the arduino measures at a specific point; the pin.
The Arduino ADC readings are always with respect to ground (being the 2nd point).
 Logged

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #8 on: May 15, 2013, 10:18:46 am » Bigger Smaller Reset

Thanks for all the replies.

Is this the correct set-up then?

 « Last Edit: May 17, 2013, 05:14:21 am by MrDumle » Logged

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #9 on: May 16, 2013, 04:17:34 am » Bigger Smaller Reset

bump
 Logged

Germany
Offline
Karma: 56
Posts: 2997
 « Reply #10 on: May 16, 2013, 04:28:38 am » Bigger Smaller Reset

no, vOut and GND are at the same level in your drawing.
 Logged

Johannesburg. UTC+2
Online
Karma: 91
Posts: 4198
 « Reply #11 on: May 16, 2013, 05:21:33 am » Bigger Smaller Reset

no, vOut and GND are at the same level in your drawing.

MrDumle, I think it's best if you lose all the lines inside your dotted Arduino, leaving that as a "black box" and not try to visualise what happens inside. If you do that, and mark the dot you have marked as Vout as PinX just to indicate some Arduino i/o pin or other, then you'll be good. If you want the drg to be complete, move the Vout label to the dot between the resistors.

What you'll have then, is this tutorial
 Logged

Roy from ITCrowd: Have you tried turning it off an on again?

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #12 on: May 17, 2013, 03:25:57 am » Bigger Smaller Reset

 « Last Edit: May 17, 2013, 05:15:25 am by MrDumle » Logged

Germany
Offline
Karma: 56
Posts: 2997
 « Reply #13 on: May 17, 2013, 04:21:50 am » Bigger Smaller Reset

We usually identify ourselves with the Arduino, so "Vout" and "Vin" sound rather strange.

But from the voltage divider point of view its perfect

 Logged

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #14 on: May 17, 2013, 05:13:03 am » Bigger Smaller Reset

Thanks Micheal! Fixed!

>If anyone want to modify the circuit<
 « Last Edit: May 17, 2013, 05:17:41 am by MrDumle » Logged

 Pages: [1]   Go Up