# How to monitor voltages safely?

Hey there!

I have been asked to come up with a solution to measure the voltage of a regular 12 Volt lead acid car battery (actually three batteries in parallel). I know that I have to use a simple voltage divider to break down the voltage for the analog input of the Arduino.

The problem I have is that those batteries power four three massive DC motors (120A maximum peak combined) and I have absolutely no clue if they have any integrated circuitry to prevent likely voltage spikes. I guess they do but I really don't want to trust that (since they are some cheap-ass motors from China as far as I know).

A way of protecting the analog input was discussed in this thread, but I am really not sure if it will endure potentially huge voltage spikes.

Also, I would like to know how to choose the right components. For the voltage divider, bigger values might probably be better (something like 1MOhm and 200kOhm for a voltage range of 0 to 30 Volts). But how do I choose the right schottky diodes? I have plenty of BAT43 diodes at hand but I am really uncertain if they are the right choice. As for the capacitor, something small like 3.3µF or even smaller might be okay since I just want to avoid overly quick changes in my readings.

Maybe someone can help me out with a little bit of advice. Thanks!

P.S.: Yes, I should clarify the situation with those motors and I will. But until then I could really learn something by designing this thing with very high voltage peaks in mind.

Edit: I found out that it is a 24V MY1020 motor running at 12V. I've read that it can also be used for generating electricity so I guess it has nothing to prevent from spiking into the system. Meh.

Just to reassure you, 100V across 10K is 1 Watt. So, 100V continuous would burn-up a 1/4W resistor. But it would be OK with occasional 100V spikes. With higher value resistors you'll get less current & power. Of course, the diodes aren't going to "see" any significant voltage, and the current will be small.

Your capacitor isn't critical either. If R2 were in the megohm range, you might have to be concerned with leakage through an electrolytic capacitor (and you might want to use a different type of capacitor), but with your resistor values you'll be fine.

Oh, okay, thanks for your thoughts.

Actually, I haven't looked into R3 yet. From what I've seen so far, usually a 1k resistor is used there. But since this will cause a voltage drop: How do I compensate for that? Just measure the drop and then add it to what my code calculates?

Edit: I do have some high power resistors here (9 Watts). Wouldn't be a 22k-4k7 divider be an option?

If these motors have brushes on the armature, and they probably do, you need some capacitors across the power to the brushes to control the sparking at the brushes. Otherwise the brushes will wear out quickly.

Paul

Your circuit will not work without a ground connection from the battery negative to the Arduino ground.

C1 does not need to be large, 100 nF is fine. R3 should be less than 10K.

All those circuits are gross overkill.

Just use a ~120k resistor between battery and Arduino pin, and a 10k resistor from pin to ground.
That will reduce battery voltage to ~1volt, that you can measure with the more stable internal ~1.1volt Aref.
Add a 100n cap from Arduino pin to ground to kill spikes and smooth motor ripple.
The ~120k resistor can be split into two resistors (for safety), e.g. 27k near the battery and 100k near the Arduino.

By using a divider to 1volt, battery voltage can spike to more than ~75volt before it reaches the 5volt limit of the Arduino pin. Above that the internal pin clamping will take over. Safe to hundreds of volts.
Leo..

Hi,
Like this;

Tom..

Yes, but D1 and D2 are not really needed, because they don't conduct unless battery voltage increases to >70volt.
Which is highly unlikely.
Leo..

This might be overkill, it might not. There has been mention of spikes of 10's of volts: 70V, 75V, 100V.
But that's probably a huge underestimation. If you have 3 120A DC motors you could easily have 1,000's of volts.

The diodes to protect overshoot are a mixed blessing... if they conduct, they conduct the spike into the 5v rail of the processor. Just relying on input protection diodes is simply cowboy design.

To protect against nasty stuff, you want to conduct it in the external circuit, not route it with diodes into your CPU circuit. So...
Diagram:

Here the bi-directional TVS diode conducts over-voltage spikes in the battery-R1-TVS circuit, the rest is pretty straight forward.

Yours,
TonyWilk

Hey there! Thanks for all your thoughts on this topic!

So now this is how the circuit will look like:

TonyWilk had BAT54 Schottky diodes in his schematic which I replaced with BAT85 Schottky diodes since I am aiming for THT components. The TVS diode I chose is a 1N6279CA. I am not really familiar with TVS diodes so maybe someone could tell me if this is or is not a suitable type of diode for this project.

Regarding the GND connection: Of course, jremington is right; there has to be a ground connection between the Arduino and the battery. It will be there, since the same battery has to power the Arduino - probably via some sort of switching reglulator. (Yeah, I know, linear regulators would do just fine here, but I have a bunch of Murata OKI 78SR at hand whereas I'd have to buy some L7805).

I still have some more thoughts on the ADC part... Will the ADC of the Arduino be "good enough" for the voltage range I am trying to cover? I know it is only 12V but with safety margins I am aiming for a range of 0 to 30 volts (that's why I chose a 10/2 ratio for the voltage divider). The 'real' range will probably be somewhere between 8 to 20 volts. Also, doesn't the protection circuit cause some kind of voltage drop (especially R4 in my case)? How would I compensate for that? Measure the drop and add the difference in code later on?

Greetings,
Vulpecula

Vulpecula:
snippets
BAT85
1N6279CA.

Look like fine choices to me.

Will the ADC of the Arduino be "good enough" for the voltage range I am trying to cover? I know it is only 12V but with safety margins I am aiming for a range of 0 to 30 volts (that's why I chose a 10/2 ratio for the voltage divider).

Correct with the divider... the TVS limits the voltage to ~30V at the junction of R1,R2. If that happens, R2/R3 = 5V at the ADC.
Your total divider (R1 + R2) - R3 means that 12V on the battery = 1.09V at the ADC

It depends on what accuracy you need to measure the battery voltage to.
With 1024 ADC steps at 5V Vref, 1V = 205 steps ~= 60mV/step, so you could measure your battery voltage in 60mV steps.

The other consideration is the ADC reference. Just using the 5V rail (the default) depends, of course, on the accuracy of the 5V. There will be a big difference between some cheap chinese eBay 5V power supply and one provided by a precision regulator.

For best 'quantifiable' accuracy, you should look at a voltage reference part and provide external Vref. e.g. MCP1541T-I/TT
Note the ADC input limit is now reduced a bit to 4.096V. Overall accuracy a lot better, and resolution approx 46mV/step reading your 12V

Don't use the Arduino internal "1V-ish" reference, it's a bit crap.

doesn't the protection circuit cause some kind of voltage drop (especially R4 in my case)

R4 is only a 'potential divider' with the input impedance of the ADC pin, the input impedance is relatively high so you can effectively ignore it.

Yours,
TonyWilk

TonyWilk:
It depends on what accuracy you need to measure the battery voltage to.
With 1024 ADC steps at 5V Vref, 1V = 205 steps ~= 60mV/step, so you could measure your battery voltage in 60mV steps.

That would mean I could just use the ADC as is, just like in all the simple example projects for reading analog signals, right? But what would be necessary to achieve 1mV steps? (Or at least 10mV steps so I have at least two digits after the decimal point like #.## Volts)

I could use an Adafruit ADS1115 breakout board (since I have one here) but it might be a bit overkill.

I would also add a series fuse on the 12V positive rail just after the batteries to protect your system from a short-circuit in your circuit or related wiring.
These batteries can provide a significant current and a short circuit could easily start a fire.

Vulpecula:
what would be necessary to achieve 1mV steps?

I could use an Adafruit ADS1115 breakout board (since I have one here) but it might be a bit overkill.

Yes... it does have an internal reference. Haven't read the datasheet tho.

Very generally: no use in having more 'bit' resolution unless your ADC reference is accurate enough. You could calibrate the setup to get better absolute accuracy. (e.g. provide really accurate input voltage, read the ADC, do some math).

Yours,
TonyWIlk

Watcher:
I would also add a series fuse on the 12V positive rail

Damn fine suggestion... 3 x 12V Lead Acids could vaporize stuff real quick :o

Yours,
TonyWilk

Watcher:
I would also add a series fuse on the 12V positive rail just after the batteries to protect your system from a short-circuit in your circuit or related wiring.