ADC0831 Based Battery Monitor - Doesn't work! Help!
everest
Posts: 141
I just updated the title because it turns out the voltage divider wasn't the problem. . .looks like I've got the ADC0831 wired up incorrectly at the current time. I'd REALLY appreciate any help with this. . .I'm lost and dealing with high currents here, so I don't want to blow anything up (including myself!) Thanks!
Original Message ******
I know fully well that this has to be trivial question, and once again I've searched and searched and found multiple schematics, none of which seem to work properly! I've built the voltage sensor outed in the "Stamps in Class" and now I need to reduce a car battery to a voltage that's measurable by the program. . .the first step is to reduce the voltage flowing into the ADC 0831 so that 15v = 5v. And I have absolutely no idea how to do that. . .I've got buckets of resistors but I can't figure this one out [noparse]:([/noparse]
Can someone help me out?
-Jeff
Post Edited (everest) : 3/12/2009 5:39:54 PM GMT
Original Message ******
I know fully well that this has to be trivial question, and once again I've searched and searched and found multiple schematics, none of which seem to work properly! I've built the voltage sensor outed in the "Stamps in Class" and now I need to reduce a car battery to a voltage that's measurable by the program. . .the first step is to reduce the voltage flowing into the ADC 0831 so that 15v = 5v. And I have absolutely no idea how to do that. . .I've got buckets of resistors but I can't figure this one out [noparse]:([/noparse]
Can someone help me out?
-Jeff
Post Edited (everest) : 3/12/2009 5:39:54 PM GMT
Comments
Google "Voltage Divider"
http://en.wikipedia.org/wiki/Voltage_divider
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Here's the problem though, I have wired up my ADC0831 just like the example in "Analog to Digital Conversion" Stamps in Class .pdf available here, except that I've rewired pin 2 (vin+) to connect in between the pair of 10-1k resistors and the 22k resistor. I also connected pin 3 (vin-) to the battery ground (I removed both from the stamp circuit obviously). I'd expect to get 4.25volts reported by the program, but instead it's bouncing around wildly from 3.6 to 4.0 or so. . .it's just all over the place.
Any suggestions on what I've done wrong? I think I actually have the voltage reduction part correct. . .so my problem must be elsewhere. . .?!?
-Jeff
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
-Jeff
Oh, and at this point I'm literally running the BS2 code right out of the ADC "Stamps in Class" lesson:
'
[noparse][[/noparse] Title ]
' Basic Analog and Digital - PL3_1R0.bs2
' Program Listing 3.1 Revision 0.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Declarations ]
adcBits VAR Byte
v VAR Byte
r VAR Byte
v2 VAR Byte
v3 VAR Byte
'
[noparse][[/noparse] Initialization ]
CS PIN 0
CLK PIN 1
DataOutput PIN 2
DEBUG CLS 'Start display.
'
[noparse][[/noparse] Main Routine ]
DO
GOSUB ADC_Data
GOSUB Calc_Volts
GOSUB Display
LOOP
'
[noparse][[/noparse] Subroutines ]
ADC_Data:
HIGH CS
LOW CS
LOW CLK
PULSOUT CLK, 210
SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
RETURN
Calc_Volts:
v = 5 * adcBits / 255
r = 5 * adcBits // 255
v2 = 100 * r / 255
v3 = 100 * r // 255 '.. new line
v3 = 10 * v3 / 255 '.. new line
IF (v3 >= 5) THEN v2 = v2 + 1 '.. new line
IF (v2 >= 100) THEN '.. new line
v = v + 1 '.. new line
v2 = 0 '.. new line
ENDIF '..
RETURN
Display:
DEBUG HOME
DEBUG "8-bit binary value: ", BIN8 adcBits
DEBUG CR, CR, "Decimal value: ", DEC3 adcBits
DEBUG CR, CR, "DVM Reading: " '.. new line
DEBUG DEC1 v, ".", DEC2 v2, " Volts" '.. new line
RETURN
Post Edited (everest) : 3/12/2009 3:26:41 PM GMT
The jitter in the ADC reading indicates that you have noise in the system and this is typical in an automotive application. Add a filter capacitor and this should solve the problem.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Craig Eid
www.TriadRD.com
This is not an automotive application, I'm monitoring a charged AGM battery right now with no load attached. . .it should be extremely clean. I think the issue is that I may have Vref wired incorrectly. I believe it may need to tie into the 12v side, but I'm not exactly sure how. . .that pin is used to "bias" the IC, so maybe it needs to be attached to the positive terminal of the 12v battery. I need to figure this out before I try that though, otherwise I'm sure I'll release the magic blue smoke. . .
-Jeff
I assume the "220K" in the picture is really a 22K ?
You have the resistors reversed. You need the 1K and 10K on the LEFT side (connected to the - terminal) and the 22K on the right side (connected to the + terminal).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
Shoot. . .yea, sorry those are mistakes in my schematic, not my actual circuit. I checked everything with my volt meter before hooking it up. Attached is an updated schematic that should be correct (in terms of what I'm actually doing).
Note that this does not work at all as I expect. . .how can I get this darn thing to read the voltage off that battery?!?! Help!
-Jeff
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
So I need to connect all of those directly to the 12v system? I have a strong fear that that would blow something up, but let me know if I'm wrong on that please. I thought that the ADC0831 needed 5v in power, also I though the STAMP pins needed to be connected to the STAMP VDD to work properly. . .this looks like it would ground out the pins against the 12v system rather than the 5v STAMP power system. Can I mix power like that?
Help! I really really need to get this working by the weekend so I can install this sucker in my observatory. Thanks!
-Jeff
The - side of the battery should be connected to the ground (VSS) of the Stamp, and the GND and -Vref on the ADC should be connected to ground (VSS). The positive side of the battery should go to your voltage divider and the input side of the voltage regulator for the Stamp.
EDIT: Just to make sure, and to answer your question, the ADC does need a regulated 5V.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Post Edited (Jonathan) : 3/12/2009 7:05:49 PM GMT
Thanks again for your help with this! I've taken what you've said and re-worked my schematic to look like the attached. Basically this combines the STAMP 5v ground and the 12v battery ground, so that it's a common ground. The power voltage for the ADC0831 come from the STAMP circuit (+5v) but all grounding is now done to the combined STAMP/battery common ground.
Could I get you to have a look at the attached schematic and tell me if I've gotten it right this time? I'm dealing with sufficient power to explode my components, so I can't afford to get this wrong and smoke $100 worth of equipment. Thanks!
Let me know if this schematic implements your note. Thanks!
-Jeff
Double check the datasheet.... looks like Vref should go to +5V. Are you confusing Vref with -Vin by chance?
I would go with the "ratiometric" reference example located on page 14 of the PDF sited below.
Reference:
http://eshop.engineering.uiowa.edu/NI/pdfs/00/55/DS005583.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
That looks good. I assume that the Stamp is powered from the 12V battery via a regualtor? If it is through another battery or a wall wart, make sure to tie it's ground in too.
Also, google up grounds, particularly note the "star" ground configuration. ADC's are sensitive to ground loops.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
We crossed posts above. I don't have the pinout, and I think I misread the schematic above. You are right that +vRef should be to +5v. If there is a -vRef (which I dunno, don't have the sheet) it would go to ground. Good catch!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I'll re-work the schematic and post it shortly. I really need experienced eyes on this because I don't have time to destroy everything and start over. . .I've got a weekend pass to work on the observatory and I've got to use it! Thanks!
-Jeff
I've just read several articles on star grounding and while my schematic doesn't show this working that way, I could easily pull all the grounds from the 9v, 5v, and 12v to a single point and break them out to all the various connection points from there. . .which seems to be the recommended method.
Anyways, how does this look? If I wire this up am I going to blow up anything?
Thanks!
Post Edited (everest) : 3/12/2009 8:28:32 PM GMT
The main thing is to make sure that all grounds are common, and that the VIN to the ADC never exceeds 5V. Make sure your voltage divider can handle it. If the battery is ever going to have an equalizing charge placed on it, that can go to 15.5V or even a little higher depending on the charger.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
THANK YOU for all your help. . .this is starting to make sense to me now and I'm confident in re-wiring this sucker. The 9v battery is directly attached to the Board of Education and there is a 5v regulator soldered right on to the board, so that takes care of the STAMP, and as such the ADC will also get the regulated 5V.
The charger I'm using right now is a simple two stage charger, it doesn't have an equalization cycle so no worries there. . .what would happen though if the input on the ADC went to 5.5v or so? Would it really destroy it?
I ask because I *ahem* actually threw more voltage at it a couple of times and it seems like it just maxes out it's reading, but it didn't damage it. . .
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When your problem seems insurmountable, read the forum for a while.
Solve someone else's problems and yours won't seem so bad.
Anyways, I don't anticipate going over 15 volts. . .I'll just see how it goes. THANKS EVERYONE! This is the best support forum I've ever been on. . .and you are even very tolerant of stupid questions. Bonus!
-Jeff
Thanks again for the help, I just wired up the new schematic and it's working perfectly. . .actually it's reading just a tad high, but I adjusted the code slightly to accommodate for that. . .8 bits only provides so much accuracy I guess!
Anyways, it's all working perfectly! Thanks again!
-Jeff