View Full Version : Battery Voltage with mpc3208 and Prop
01-18-2009, 05:12 AM
Ive seen a couple other people asking about battery voltage monitors and im messing myself... So here is what i have.
Im getting the basics but a ot of the·details escape me. Ive got it·"working" but im guessing it needs·some diode protection or some caps i dont know really.
Im using a voltage divider and measuring battery voltages up to around 15 volts...
Im using an extra pin i have free on my mcp3208 ADC.. my ref voltage is 3.3 volts on it....
my R1 Value is 10K
my R2 Value is 2700
Ignoring the %error in resistors this gives me a Vout of 3.3v when the Vin is 15.5222·and the amps are .0012
Question #1: Are those values ok... mainly is the amperage ok. Im just guessing you want it as low as the adc can take which i couldnt make out on the spec sheet for the mcp3208 a lot of it is still greek to me.
Now ive got it all working on the prop using some simple math. I can hook differnet batteries up and·I display the voltage pretty accurately when no load is on. It matches my multimeter etc.
Question #2: When i hook up a motor to the batter i drop from about 12.6 volts to 12.4 what exactly is happening here. Do i need caps to buffer or something? Ive got 0.1uf caps on the other side of the adc but dont know how to pick which caps if any to use on other.
Question #3: Im guessing·I need some sort of diode for protection because a couple times when connecting·the load and disconnecting my program glitched out. which im guessing im lucky didnt fry anything.·FYI this is for an rc applcation and will be used to monitor battery voltages for rc cars/ planes /heli etc
Thanks guys once i figure it all out hopeuflly with your help ill post a complete rundown on how to do this from a newbs perspective to save you pros from some of these basic questions in the future·:)
01-18-2009, 06:41 AM
If you use a 10k and a 1.11 that calculates to divide by 10 by my figures. You would then need to use a 2.048 voltage reference. To use 3.3v as your reference I believe you need to use a 1.92k resistor. The reason I would do this is for ease of figuring your voltage. What this figures is the 4096 = your full scale voltage of 20.48v. I show a zener diode here as protection but a tvs might be better. You definitely need a clamping diode on the motor also. I'll let the professionals on the forum recommend you something there.
01-18-2009, 07:02 AM
Id rather keep the 3.3vref because im also sensing other things with the adc on other pins...
with this math the voltage results seem right on the money...
batt:= fMath2.FDiv((fMath2.FMul(fMath2.FFloat(vout), 15.5222·)), 4096.0)··
my biggest concern is just...if and what proection it needs as well as caps... also why they are needed etc :) I still just dont grasp that end of it yet and i would LOVE to :)
01-18-2009, 11:14 AM
I didn't show the caps. I would put a .1uf cap near the input pin on the mcp3208. It won't be that critical with the resolution you need. I'd follow the recommended ones on the supply.
When voltages change rapidly there can be high voltage spikes. You need a diode to funnel these spikes to the power rail. If you look up google "clamping diode" I think you may find sufficient info to implement it.
If you are using floating point I guess it doesn't matter. I just find floating point so cumbersome in spin that it seems easier to me to avoid it if possible. Setting the max to 20.48 volts means all you have to do is divide by 2 and you have the voltage in hundredths. It is a simple matter to display a virtual decimal point.
Post Edited (Erik Friesen) : 1/18/2009 3:19:53 AM GMT
01-19-2009, 03:16 AM
ok great so i see. Basicaly the spike will cause the the diode to pass through backwards once it reaches its breakdown voltage..(in this case 3.3v rating of the zener) and it will take the path of least resistance which will be through the diode and not through the rest of the circuit.
I know this is an extremely general follow up question but what type of voltage etc are we talking about with emf with motors etc.
01-19-2009, 06:31 AM
Actually in the case of the motor when the spike is .6( or the breakdown voltage of the diode) above the positive power rail the diode shunts it to the power rail. The zener as shown is for the protection of the mcp3208 only. I have little experience driving motors but I would hazard a guess of 100V when the field collapses.
You can also use a zener or a tvs to clamp these voltages. In the case of emf I am not sure what steps are needed. I believe there is another thread with quite a bit of detail on emf started by phildaphil.
01-20-2009, 04:59 PM
Question #2: When i hook up a motor to the batter i drop from about 12.6 volts to 12.4 what exactly is happening here.
Question #3: Im guessing·I need some sort of diode for protection because a couple times when connecting·the load and disconnecting my program glitched out.
Q2 -- What's happening is that the voltage at the terminals of the battery dropped a little, as expected, when you applied a load.· That's normal.· Your admirable measuring system, working properly, saw the change.· Nothing wrong there.
Q3 -- Probably when you connected the load you created a transient that got into the power supply to your measuring setup.· A capacitor, say 100 microfarads, on the Vdd might prevent that.
· -- Carl, firstname.lastname@example.org (mailto:email@example.com)
01-21-2009, 10:17 AM
Ok so one more shot heres a more completed schem of the sensor circuit...
with additional allegro acs756 current monitoring chip.....
Im assuming that it will out put 0v at -100 amps and 3.3v at 100amps i couldnt really tell from the spec sheet for sure but thats what i gathered...
Is the 100uf cap in the right spot there?
any other glaring mistakes?
fyi this is for monitoring rc batter voltages and current.. the batt goesin the top plug and speed control on the lower plug.
thanks a ton
There was another recent thread with some discussion of battery voltage/current monitoring: http://forums.parallax.com/forums/default.aspx?f=25&m=319268
I have always used a shunt with an opamp for current, and a divider for higher voltages. Any reason you prefer the halleffect approach? When I've looked in the past, the hall efect sensors were a little pricey. This recent board from sparkfun closely approximates the setup I have used (except I used different an cheaper components): http://www.sparkfun.com/commerce/product_info.php?products_id=9028
the circuit for the board can be viewed on the linked datasheet Max(51.8V, 89.4A) and it is scaled for a 3.3V output - it is advertised for monitoring RC batteries
Not sure if this is helpful since I wasn't sure if you had a reason to use a halleffect sensor...
01-22-2009, 06:42 AM
chose it cause it seems easy to use and also its only 130µΩ not to mention i dont get the concept of measuring it with a shunt :) (looking into it right now )