United Kingdom
Asked — Edited

Battery Voltage Monitor

This is really a question aimed at DJ but if anyone else knows the answer please chip in, i want to know how i can use an ADC port to monitor the battery voltage on my 6v battery, my idea is to write a script that will for now just say that the battery voltage is low, by speaking through my laptop, my eventual aim is so that when the roborealm module is done he will sense the battery is low and head for a home base by using the navigation module in roborealm.

Thanks Kurt


ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

United Kingdom
#1  

Kurt don't connect an ADC port directly to your 6v battery it will blow up the port. You just need a couple of resistors say 10k in series to ground from the + of the battery and connect the ADC port to the centre of the resistors. Then you can read the ADC port and calibrate at what voltage you need to start a go and get charged script. Thats the way I would do it any others?

United Kingdom
#2  

Hmm not to sure i get that, you got a wiring diagram i can see ;-)

Thanks Kurt

United Kingdom
#3  

Here's a thrown together pic if you want I will wire it up tomorrow and see if the impedances are about right

User-inserted image

United Kingdom
#4  

Ok tested it works fine. You will get 1/2 the 6v battery voltage applied to an ADC port. You would need to adjust the resistor values if using a higher battery voltage than 10 volts or say 7 dry cells.

Then run a script like this

IF (ADC(ADC0) < 3)

The EZ-B will excute the next line if the battery voltage falls below 3 (ie 6volts). Adjust this value to see what works best. The total current drawn off the battery with this arrangement using ohms law would be only 0.0003 amps or 0.3 ma

#5  

Winstn60 --

Please pardon my ignorance as I'm totally new to circuitry. It looks like the ADC port utilizes a 3 wire connection. Your diagram only shows one wire. Which one is it and what did you do to the other two? And just to be clear, this setup is place between the battery and the EZ-B, right?

I'd like to utilize this along with a simple script for an LCD screen which could display a low battery warning.

Thanks in advance!

United Kingdom
#6  

Hi Choyster

You are correct the EZ-B has 3 wires to any port +5 volts, ground and the signal wire. Yes and it does go between the battery and the EZ-B

In this case we aren't powering anything like a servo so we don't need the +5v and GND wires, just the input lead sensing the voltage level on the main battery I have called it PSU in my diagram before it gets regulated by the EZ-B board. On the V3 board its the outer pin of any input port A0 to A7 that gets connected to the resistors if you use a servo lead just snip the other 2 off :)

United Kingdom
#7  

So forgive my stupidity but i am connecting the + and - together with the two resistors inline correct ? then comming from the middle of the two resistors to the input signal wire of the ADC ? Just checking dont wanna blow my ezb up lol

Thanks Kurt

United Kingdom
#8  

The two resistors are wired inline (series) across your battery + and - terminals and then as you say the middle of the 2 resistors go to the EZ-B ADC signal pin.

Hence the high value of the resistors they won't drain your battery are they are in effect shorting it out

OK now?

#10  

Thanks so much for the clarification. Now I've got another question: Is there an easy way to add ammeter functionality? I'm trying to come up with cool stuff to push to an LCD panel tiggered by a voice-activated "Status Report" command.

#12  

@bret.tallent

so......i want one of those....i see it has a 3 pin connector. can you maybe post up some pics on your set up once you get it going. this would look perfect in front of my wall-e

Canada
#13  

@winstn60 I searched and came across this older question, and hoped you would be able to assist again. I would like to do the same thing for voltages up to the maximum that the EZ-B would take (18v). On the EZ-B there are four pins that provide 5v, GND, GND, and Vin (the voltage powering the EZ-B).

I am already using the 5v pin to AD0 and using ACD READ to show me what the voltage load is like when I am testing things out.

I would like to do the same thing for the Vin to AD1 and add another ADC READ showing me the incoming voltage to the EZ-B. How would I go about determining the value of the resistors I would use for say 12v-18v?

Or perhaps, someone could tell me what is the technical term for this circuit and I could Google it to check out myself. Thanks

Canada
#14  

Hmmm, well I think I answered my own question... sometimes just taking the time to ask gets my brains a function'n;) It is called a resistor ladder (I think) and after playing around with a neat electronics simulator app called EveryCircut for my Android, I was able to take my limited electronic comprehension into a practical level. I need to do more then change resistor values, in fact I don't need to change them at all, rather I need to add a 2nd "rung" to drop the voltage again to within 5v (from 18v).

User-inserted image

It might even be simpler then this... If someone knows more, please enlighten me... sometimes I know just enough to be dangerous :P

United Kingdom
#15  

@Gunner not been around so didn't see your post til now

The 2 resistor circuit is called a potential divider which in your circuit is neatly cascaded into two potential dividers. Although I would expect 18v to be divided by 2 so instead of 7.2v you would get 9volts and then 9 divided by 2 you would get 4.5volts. So within tolerance for the EZ-B. The current flowing through the resistors should be the same though in each arm. Best to build it and see what you get with a voltmeter before you connect it all up. Great way of learning stuff))

Canada
#17  

@winstn60 You answered quickly, no complaints here :)

Thanks for checking it out... I need to purchase the resistors and, yes, breadboard them before committing to the EZ-B... must keep the magic smoke in:P I think the lower voltages are due to something called Loading Effect. The simulator shows differing voltages as I add or remove a "rung". There is aperently math involved eek but I want to keep it fun, so I just ignore that and test away :P

@pittom It is a handy little app isn't it... so easy to use and visual... I love visual, soaks into the grey matter easier :)

Canada
#18  

Science prevails again...

I rigged up a test curcut using the highest value resistors I had on hand, 510 Ohm, And matched the real world results with the simulated ones. User-inserted image Then I tied the curcut into the EZ-B on ADC7 and fiddled with the Unit Multiplier untill the resulting value matched my multimeter. I am sure DJ has a formula that is to be used, but I ended up with 0.09693 User-inserted image Now I can monitor my battery level within ARC. User-inserted image Such a simple thing... but makes me happy to have worked it out :)

United Kingdom
#19  

Well done you

I didnt know there was a unit multiplier on the ADC control thats handy

Interesting to know if the measurement tracks correctly your battery voltage? I guess it must do and you should be ok to safely measure voltages up to 20 volts

Canada
#20  

So far it has matched my multimeter with anything I have used for power, 12v, AA battery pack and regulated bench supply (the voltage shown in previous pic).

Here it is all soldered up and shrink wrapped. User-inserted image

Canada
#21  

Ah, but when I think I have it all figured out... It seems to display the voltage source correctly at a standstill, but when I run the H-Bridge the voltage counter goes UP while the multimeter goes DOWN ?

BIG EDIT blush I had set the port number to ADC7 when it should be ADC1... now it reads properly all around. But it is interesting that other ports should have such "quasi correct" but fluctuating readings when they aren't even hooked up to anything confused