So I have an arduino micro and a parallax 3-axis gyro, and my overall goal is to make a module that I can put into a medium scale (5 foot wingspan) RC airplane to control various functions.
Since I have very minimal background in EE and arduino, I'm starting small. For now, I'm just trying to prototype the fuel gauge. My overall plan with this is to have the arduino read the voltage of the battery pack, and adjust the color of a string of LEDs that will be fitted to the bottom of the airplane. That way as I'm flying around, I have some measure of how much "fuel" I have left in the airplane. I have ended dozens of flights thinking that the battery was going to start running low, only to check it once I got home to find I had another 5 minutes of flight time!
So with that goal in mind, I've started fiddling with some concepts. I was able to successfully use a voltage divider to measure the voltage of a 9v battery and my RC airplane batteries. Then I figured I would try setting up a system for the LED's (I have one of those 3 color LED's I'm going to prototype with). I thought that I could put a potentiometer in between the voltage divider and the arduino, which I could use to vary the actual voltage going to the arduino, just to see if I could get the LED to change color based on the incoming voltage (I'm really trying to take baby steps since I have no idea what I'm doing...)
The thing I noticed is that while I'll have a voltage reading of say 4.98V on the circuit without the potentiometer; adding the potentiometer lets me vary the voltage between 0V and 3.33V. In general this relationship stays, so that I'm able to use the potentiometer to vary the input voltage between 0% and ~66% of the incoming voltage. Is that something inherent with the potentiometer, or am I doing something wrong?
Sorry for making anybody who might want to assist a newbie read a book here, but I wanted to explain all of what I'm doing instead of saying something like "why isn't my circuit working?" and hoping people understood what I meant...
Much better to have too much than too little, that's for sure. You're off to a very good start.
What you are seeing is in fact an inherent property of your circuit, which is why you shouldn't use it like that. I'll attempt to explain as best as I can.
One thing that's often missing from tutorials and discussions about voltage dividers is loading effects. Voltage dividers work fine as long as you aren't drawing much current away from the divider point. This has to do with an electrical engineering concept known as a Thevenin's Theorem, also known as Thevenin's Equivalent Circuit.
Briefly, any circuit consisting of just voltage sources, current sources, and resistors, no matter how complex, can be reduced to a single voltage source in series with a resistor. In the case of a simple voltage divider, the equivalent series resistance is the value of the two resistors in parallel. I've attached a picture to illustrate the equivalence. (Excuse the crudity of the Paint job)
A potentiometer is basically a resistor, so when you add a resistor to the Vout terminal, you are effectively creating another voltage divider, which will cause the Vout voltage to "sag" due to loading effects. This is not obvious when looking at the voltage divider schematic, but is much easier to see when looking at the Thevenin's equivalent.
For the solution, instead of using a potentiometer on the output of the voltage divider, make the potentiometer part of the original voltage divider, as in the second attached image.
Ok, I'll have to give your new schematic a try and figure some stuff out.
Is there a way to figure out what the overall resistance of the potentiometer is? I assume it goes from very high to some lower value (which I previously assumed was 0). My concern is that if I replace the second resistor with the potentiometer, I would have to make sure I knew what the resistance values were since I plan on using this for a 3s LiPo battery (11-12V) and don't want to accidentally let more than 5V pass to the arduino pins.
This might be something I can figure out on my own via experimentation. For the initial testing, I was only using the higher voltage sources when I was sure that it was only passing safe voltages to A0, and that it was running the calculations and displaying them correctly. I had just wired the arduino 5V pin to both V1 and V0 on the voltage divider (the term self-licking ice cream cone comes to mind). So I could do the same thing to see how the circuit behaves with the potentiometer in place of a resistor
For more clarification, the below drawing is what I had put together and was using in my first post. Sorry for combining circuit diagrams style and real world style, I just thought this might remove some ambiguity.
Is there a way to figure out what the overall resistance of the potentiometer is?
The datasheet for you potentiometer should tell you the value. Do you have a link to the datasheet or where you bought the pot from? If you don't have a datasheet, just measure the resistance between the two outside terminals using a DMM. It's probably around 10k ohms, that's a common value for pots.
I assume it goes from very high to some lower value (which I previously assumed was 0).
You would be incorrect. A potentiometer is basically a variable voltage divider. There is constant resistance between the two outer pin, with a "wiper" connected to the third terminal that moves along the resistive material to change the Vout point of the voltage divider.
My concern is that if I replace the second resistor with the potentiometer, I would have to make sure I knew what the resistance values were since I plan on using this for a 3s LiPo battery (11-12V) and don't want to accidentally let more than 5V pass to the arduino pins.
You would have to know the resistance value anyway, since the Arduino's ADC requires a certain maximum input impedance (around 10k ohms) or else it won't work properly.
I don't have the datasheet. All the parts I currently have came with an starter kit I bought. I could try digging a bit and probably find it.
So basically, if I follow your circuit diagram, all we're doing with that potentiometer is replacing those discrete resistors R1 and R2 with a this potentiometer that lets us vary the values for R1 and R2 that go into the equation Vo = Vin*R2/(R1+R2), correct?