Measuring battery voltage
mosquito56
Posts: 387
·The input of the adc chip is 5v. How do I measure the voltage on the 9v battery. Will a simple divider work?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "If you can't say something nice, don't say anything at all"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
Post Edited (mosquito56) : 1/16/2008 10:16:15 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "If you can't say something nice, don't say anything at all"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
Post Edited (mosquito56) : 1/16/2008 10:16:15 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "If you can't say something nice, don't say anything at all"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
for those who haven't used a ADC or divider before... Me. could you explain how it actually works? what is the out put of the ADC. is it a pulse or is it resistance I though the way to read voltage was by measuring the time to charge a cap?
thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Like I said, we'll talk on MSN.
A voltage divider is one of the most simple circuits. It consists of basically, 2 resistors connected in series. One end of this "chain" of resistors is connected to ground, while the other is connected to the voltage you want to "divide". The output of this is located in the middle, between the two. If the resistors are equal values, e.g. 1K and 1K, the output will be about half of the input voltage. I say "about half" because when you put any measuring device up to the ouput, it pulls off some current from the divider, which causes the voltage to drop. A common analogy is water pipes. Let's say you have a narrow pipe with a pressure gauge right in the middle(or where ever, but in the middle for this). If you connect the input of a pump to one end, and the ouput of the pump to the other, you will have water flowing through the pipe. Let's say this pipe is surgical tubing... The pump is a 500HP industrial water pump that "can" deliver 5000 gallons per minute. you're probably only taking 1/2 a gallon per minute and the pressure is 50PSI at the input of the pipe(relative to the exit end). Te pressure at the exit end, relative to the exit end, is obviously zero. Now, the pressure difference is because there is a flow through the pipe, but the pipe walls cause friction on the water flow, which causes a resistance to the water flow. This resistance turns into a pressure. If you think about it, if one end of the pipe is 50PSI, and the other is 0PSI, then at some point inside the pipe, the pressure is 25PSI(and every value between 0 and 50 for that matter). Because the tubing is uniform, then the pressure decreases at a uniform rate from one end to the other. Since it's uniform, then the middle of the pipe will "drop" half the pressure. The gauge on the pipe will read "25PSI".
Now, suppose you give the water an alternate route to flow from at the middle of the pipe by the gauge. Let's say you give it another piece of tubing to flow through. Now, the gauge should read less than 25 PSI because it has less resistance after it gets to the gauge. This is how a voltage divider works.
If you have two resistors and the first one is connected to the voltage source, and then connected to the second, which is connected to ground, you will get current flowing like the water. Only so much current can flow through the first resistor, even if IT is connected to ground as well. As the current flows from the first, into the second resistor, it creates a slight back pressure(voltage) at the point where they join. This voltage is the result of the ratio of the two resistances. If you want to find the voltage produced by a set of resistors, it's like this...
V_out = V_in * (R2/(R1 + R2) )
That is, with R1 being connected to the input, and R2 connected to ground and both joined at the ends. That's a voltage divider. Simple.
As for ADC's, there are many different types and methods of how they do it, but an ADC is just a chip that converts a voltage reading into a binary value. Some have a bajillion pins and functions and even it's own crystal and micro processor, while others are simple 8 pin devices that just need a chip select, data line, and a clock line. You can get a pretty good 12bit ADC from TI as a free sample(5 max per order... don't abuse it). This is the one I use and I've written some code as a "driver". No cog required. Just hook it up, and call the "getvalue" command and it returns the value(0-4096). In code, you then just convert this to a 0-5v scale if you need to.
·Since i got my first adc working today i guess i can give it a shot at what they are. The adc chip takes an analog signal(voltage) and converts it to binary numbers that the prop can understand.
· You have to read the datasheet to find out what signals need to do what to talk to the chip. This is an example from my 0831 from parallax.
·· 1. Send hi then low signal to CS. This turns the chip on
· 2. Send a clk signal to another pin. When the pulse of the clock goes neg or pos depending on the chip. The adc chip sends a binary 1 or 0 that the prop is looking for on another input pin. This pin is the DO "data out"
· 3. you repeat number 2·the required times. 8 bit=8 times, 12bit=12times, etc.
· 4. you "read the data", msb first in this case.
·repeat 8
··· ·if ina[noparse][[/noparse]pin]:=1
····· ··calculate=1
···· else
······ ·calculate=0
· calculated:=calculated+calculate
··calculated=calculated*2·· 'or just shift the bits 1 left.
print.bin(calculated)
Now convert this number to something that makes sense: I.E. temperature, salinity, etc. This is a book in itself.
Read the tutorials and do as many as you need to until you understand what is going on. Try to find the "Basic analog to digital" tutorial. It's written for stamp but the electronics will be alot of help. They cover the adc0831 which is a very primative chip. I say primative because the parallax store says they are on their last run and will be discontinuing the chip.
Hope this helps. I am sure someone will elaborate and critique this but that is my hope as that is how you learn.
Have a great proping day!!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hmm, "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········"What happens in Vegas ends up on the Internet"
Technologically challenged individual, Please have pity.
Post Edited (mosquito56) : 1/17/2008 6:18:11 PM GMT
*Peter*
The max1270 does have resistors to ground but the diagram shows that this presents around 21K of load which is no real load anyway. Another way to look at this is to factor in the input resistance as part of the external divider in that it forms the lower divider so that you just feed a resistor (around 100k) from the battery directly into the input. I would still add a capacitor of at least 0.1uf or so.
*Peter*