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 Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Online
Faraday Member
**
Karma: 91
Posts: 4198
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Online
Faraday Member
**
Karma: 91
Posts: 4198
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Offline
Edison Member
*
Karma: 33
Posts: 1307
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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!  smiley-wink    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 Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset 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 Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bump
Logged

Germany
Offline Offline
Faraday Member
**
Karma: 56
Posts: 2997
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 91
Posts: 4198
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, how about this then?  smiley

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

Germany
Offline Offline
Faraday Member
**
Karma: 56
Posts: 2997
View Profile
 Bigger Bigger  Smaller Smaller  Reset 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 smiley

 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Micheal! Fixed!  smiley

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

Pages: [1]   Go Up
Jump to: