# Voltage measurement via MCU?



## mhud (Oct 19, 2009)

I'm not sure if this will answer your question or not, but I have a PakTrakr system and I know conceptually how it works. Each PakTrakr remote connects to the negative terminal of the negative-most battery in that remote's string. Thus, each of those connection does in fact share a common ground, being the negative post on the most negative battery. Each remote is responsible for up to 8 batteries, and the remotes daisy-chain together via serial. Each remote powers itself from the first battery in the string. The current draw is very low but non-negligible over time. 

I am hoping to build my own voltage logger with an Arduino or Basic Stamp. I want measurements more often than my PakTrakr's once per second. I also want to build a nice color display using a cell phone, iPod touch, or tablet. 

My next experiment is going to be taking measurements with an Arduino, and I was hoping to have it powered by an isolated source but measure voltages from one or two batteries in series. Looks like we both have some learning ahead of us!


----------



## mhud (Oct 19, 2009)

When you think about it, it has to be possible. Your run-of-the-mill voltmeter is powered by a 9V battery but it's able to show you voltage potential from any two arbitrary points in an unrelated circuit.


----------



## Overlander23 (Jun 15, 2009)

I've thought about the issue of multiple serial cells being measured by the MCU causing a problem of over-voltage. Imagine the 10-cell example. The issue of ever increasing steps of voltage occurs between the cells themselves (not necessarily to a common ground, essentially the first cell becomes the ground potential for all the attached cells). I know this is probably obvious to most...

I still don't know how the MCU determines voltage potential from an isolated circuit, though... given that only one input is polled by the ADC.

Now I understand the need for voltage tolerant parts. So in the case of a multiplexer, something like the Maxim MAX378 could be used for 8-cells since it handles 60-75v. But yeah, it gets expensive.

Don't mind my rambling...


----------



## mhud (Oct 19, 2009)

Overlander23 said:


> I've thought about the issue of multiple serial cells being measured by the MCU causing a problem of over-voltage. Imagine the 10-cell example. The issue of ever increasing steps of voltage occurs between the cells themselves (not necessarily to a common ground, essentially the first cell becomes the ground potential for all the attached cells). I know this is probably obvious to most...


I think the measuring device only has to tolerate the voltage of one cell. I got a rudimentary Arduino voltmeter running today, albeit with only one cell. 

If the mux works by connecting only one lead at a time, then it should be possible to construct a circuit that will iterate through each cell one at a time, so that the largest voltage potential is that of each individual cell. 

So say you have four batteries in series. From negative to positive, label the 5 terminals A (most negative/0V), B (+12V), C (+24V), D (+36V) and E (+48V). The positive post on the first battery and the negative post on the next battery are identical as far as the circuit is concerned, excepting the tiny amount of resistance from the cable connecting them. 

First, you connect A to your measuring circuit's ground, and use a voltage divider to connect B to the analog input that will measure the voltage potential. Next, you disconnect both of those leads. Next, you connect B to ground, and C to the voltage divider. 

As long as you disconnect all leads before connecting another, the total voltage potential should never be greater than the individual cells being monitored. I don't know the implications of rapid switching, but I'd expect to be able to poll hundreds of times per second without issue. 



Overlander23 said:


> I still don't know how the MCU determines voltage potential from an isolated circuit, though... given that only one input is polled by the ADC.


Here are some links that I was using today when trying to get my Arduino acting as a voltmeter for multiple cells. I was measuring a single AA battery accurately but I am having trouble coming up with the right combination of resistors for the voltage divider. it is weird, i measure the resistance on the resistor before adding it to the circuit, but when I put it in my project board it becomes less resistive. This is with the Arduino unpowered but connected. WTF!?

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1242577883

http://www.clarenceho.net:8123/blog/articles/2009/05/17/arduino-test-voltmeter


----------



## Overlander23 (Jun 15, 2009)

The MUX would indeed connect through to the ADC one lead at a time, so to speak. But you've still got to hook all the cell taps to the MUX. The MUX itself would need to be able to handle the voltage potential across all the cells connected to its inputs even if internally it isn't directing a signal to its output... I think...

If this is the case, there must be some way of adding FETs between each cell tap and the ADC or MUX. The FETs would be switched to allow only voltage from each discrete cell in the string through at any given time. This idea would only work if the measuring side of things could be done with two isolated cell inputs (for positive and negative). The ground thing still has me confused.

When you used your Arduino to successfully measure a single battery were you powering the MCU with a separately grounded source? Or were you using the battery you were measuring?

Does the ADC function of the MCU rely on a common ground between the MCU and the source it's measuring?


----------



## mhud (Oct 19, 2009)

Overlander23 said:


> The MUX would indeed connect through to the ADC one lead at a time, so to speak. But you've still got to hook all the cell taps to the MUX. The MUX itself would need to be able to handle the voltage potential across all the cells connected to its inputs even if internally it isn't directing a signal to its output... I think...
> 
> If this is the case, there must be some way of adding FETs between each cell tap and the ADC or MUX. The FETs would be switched to allow only voltage from each discrete cell in the string through at any given time. This idea would only work if the measuring side of things could be done with two isolated cell inputs (for positive and negative). The ground thing still has me confused.


You're right, I'm treating the mux as if it does not do anything at all with its input pins unless it's "time" for that one to be connected up and polled. That is a risky assumption on my part. 



Overlander23 said:


> When you used your Arduino to successfully measure a single battery were you powering the MCU with a separately grounded source? Or were you using the battery you were measuring?


The Arduino was powered from 5V USB. I could power it up, read its serial output on the screen (showing "min" aka 0v. Then just touch the leads to a battery to get a measurement. It seemed very accurate before I introduced my voltage divider to measure over 5V. 

The Arduino's ground connection MUST be connected to the measured battery's negative side to get a measurement. 

An alternative to FET circuitry would be a set of opto-isolators. But even in this opto-isolator example schematic, the grounds of the two "isolated" circuits are connected -- but in this case, I don't believe that's necessary (just convenient). The schematic on Wikipedia has no connection, so this might work. 



Overlander23 said:


> Does the ADC function of the MCU rely on a common ground between the MCU and the source it's measuring?


As far as I can tell, the Arduino's ADC absolutely does require this.


----------

