Searching \ for '[PIC]: F872 ADC - Reading Battery Voltage ?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/power/batterys.htm?key=battery
Search entire site for: 'F872 ADC - Reading Battery Voltage ?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: F872 ADC - Reading Battery Voltage ?'
2002\04\16@133100 by PICLIST

flavicon
face
Hi,
I am building a Battery Charger and am not sure about
reading the Battery Voltage with the ADC of the F872.
I have it set up in code and if I hook my ADC to
ground I read 0-3 using the 10 bit ADC (0-1023).
If I hook to my supply I read 1021-1023.
So far so good. I have the 8xAA battery pack grounded
to my protoboard with a 2k Resistor and 1k Resistor
in serires tied between V+ and GND. If I measure
the voltage with my DMM I get 3.5volts, which is
a third of the pack voltage, but if I read the
voltage with my ADC I get 25-27 when I am expecting
to see about 136. Also when I plug the wire of the ADC
in the resistor ladder, the DMM drops from 3.5V to
135millivolts.
Could someone enlighten me as to what I am doing wrong.
I have seen this simple circuit on a number of chargers.

Thanks,
Kevin

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\04\16@150853 by Olin Lathrop

face picon face
> I am building a Battery Charger and am not sure about
> reading the Battery Voltage with the ADC of the F872.
> I have it set up in code and if I hook my ADC to
> ground I read 0-3 using the 10 bit ADC (0-1023).
> If I hook to my supply I read 1021-1023.
> So far so good. I have the 8xAA battery pack grounded
> to my protoboard with a 2k Resistor and 1k Resistor
> in serires tied between V+ and GND. If I measure
> the voltage with my DMM I get 3.5volts, which is
> a third of the pack voltage, but if I read the
> voltage with my ADC I get 25-27 when I am expecting
> to see about 136. Also when I plug the wire of the ADC
> in the resistor ladder, the DMM drops from 3.5V to
> 135millivolts.
> Could someone enlighten me as to what I am doing wrong.
> I have seen this simple circuit on a number of chargers.

I'm a bit confused by your description, but make sure no A/D input exceeds
Vref+.  I've noticed that when this happens, the high input can actually
source current out the other analog ports.  Perhaps a similar situation
exists with Vref-.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2002\04\16@185805 by PICLIST

flavicon
face
<snip>
I have the 8xAA battery pack grounded
to my protoboard with a 2k Resistor and 1k Resistor
in serires tied between V+ and GND.
<snip>

>I'm a bit confused by your description, but make sure no A/D input exceeds

>Vref+.  I've noticed that when this happens, the high input can actually
>source current out the other analog ports.  Perhaps a similar situation
>exists with Vref-.

OK, maybe this picture will help my description
http://members.dca.net/kben/misc/batt.html

I left off the charger circuit.
I just have AN0 tied to the resistor ladder which
should keep the voltage the PIC pin sees to < Vref+.
When I measure with my voltmeter I read 3.5volts between
the 2K & 1K resistor. My Pic is running from 5Volts.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2002\04\16@223117 by Dwayne Reid

flavicon
face
At 01:25 PM 4/16/02 -0500, .....PICLISTKILLspamspam.....MITVMA.MIT.EDU wrote:

>  Also when I plug the wire of the ADC
>in the resistor ladder, the DMM drops from 3.5V to
>135millivolts.
>Could someone enlighten me as to what I am doing wrong.
>I have seen this simple circuit on a number of chargers.

What you have described sounds like the a/d pin is set as an output and is
LO.  Check your trisa register and make sure the appropriate a/d pins are
set as inputs (1).

dwayne


Dwayne Reid   <EraseMEdwaynerspam_OUTspamTakeThisOuTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2002\04\17@034138 by Alan B. Pearce

face picon face
>I just have AN0 tied to the resistor ladder which
>should keep the voltage the PIC pin sees to < Vref+.
>When I measure with my voltmeter I read 3.5volts between
>the 2K & 1K resistor. My Pic is running from 5Volts.

Huh?
Do you mean that you measure 3.5V between AN0 and Vss?

I take it that you are using internal Vref+ and Vref-.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\17@040301 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

I presume these are NiCd or NiMH batteries?  In which case the battery
votage will be  8*1.2=9.6 volts approximately.  You are sampling one third
of this voltage, and it sounds very much as though you are using the PIC's
Vss and Vdd for a reference which I'm guessing is at 5 volts?

So, ((9.6 * 0.33) / 5) * 1023 = 648 which should be what you are expecting,
not 136.  The fact that you are so far off this suggests to me that you have
not properly configured either the TRISA register or the ADCON1 register,
and the pin you are using is set as an output.

Regards

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\17@094453 by Olin Lathrop

face picon face
> OK, maybe this picture will help my description
> http://members.dca.net/kben/misc/batt.html
>
> I left off the charger circuit.
> I just have AN0 tied to the resistor ladder which
> should keep the voltage the PIC pin sees to < Vref+.
> When I measure with my voltmeter I read 3.5volts between
> the 2K & 1K resistor. My Pic is running from 5Volts.

OK, you've got a resistor divider on the battery pack which feeds 1/3 the
battery voltage into RA0.  You are reading 3.5 volts coming out of the
resistor divider, which is also RA0.  That means your battery pack voltage
is 3.5 * 3 = 10.5 volts.  That comes out to 10.5V / 8 cells = 1.3 V/cell
average.  I don't see a problem here.  It all seems quite plausible.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\17@100900 by PICLIST

flavicon
face
>> OK, maybe this picture will help my description
>> http://members.dca.net/kben/misc/batt.html
>>
>> I left off the charger circuit.
>> I just have AN0 tied to the resistor ladder which
>> should keep the voltage the PIC pin sees to < Vref+.
>> When I measure with my voltmeter I read 3.5volts between
>> the 2K & 1K resistor. My Pic is running from 5Volts.
>
>OK, you've got a resistor divider on the battery pack which feeds 1/3 the
>battery voltage into RA0.  You are reading 3.5 volts coming out of the
>resistor divider, which is also RA0.  That means your battery pack voltage

>is 3.5 * 3 = 10.5 volts.  That comes out to 10.5V / 8 cells = 1.3 V/cell
>average.  I don't see a problem here.  It all seems quite plausible.
>
I guess I wasn't clear enough in my post. The voltmeter reads 3.5 volts.
RA0 is reading 25. what I would expect RA0 to read is 1024/15 volts = 68.27.

So, 10.5 volts X 68.27 = 716.84.
However, Dwayne and Mike suggested I check TRISA to make sure RA0 is
set for output, which I will do ASAP.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\17@134427 by Dwayne Reid

flavicon
face
At 10:07 AM 4/17/02 -0500, spamBeGonePICLISTspamBeGonespamMITVMA.MIT.EDU wrote:

>However, Dwayne and Mike suggested I check TRISA to make sure RA0 is
>set for output, which I will do ASAP.

You may have just written it wrong but what you want to do is make sure
that RA0 is set to be an INPUT.  If RA0 is set to be an output, you will
have problems.

dwayne



Dwayne Reid   <TakeThisOuTdwaynerEraseMEspamspam_OUTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\17@145510 by PICLIST

flavicon
face
>>However, Dwayne and Mike suggested I check TRISA to make sure RA0 is
>>set for output, which I will do ASAP.
>
>You may have just written it wrong but what you want to do is make sure
>that RA0 is set to be an INPUT.  If RA0 is set to be an output, you will
>have problems.
>
>dwayne

Yes, I said it wrong, I meant INPUT, but I also SET it wrong !
I had set it as an input, but later set the whole port to
output ! Dumb Mistake of the week.

The thing that confused me was that if I connected RA0 to VSS,
I read between 0 and 3. If I connected it to VDD I read between
1021 and 1023, which is what I would expect with the 10 bit ADC
reading VSS and VDD. However when I read the resistor divider,
I read 25, which should have read about 715. I got these readings
even with RA0 set as an OUPUT ?

I have since set it to INPUT, and am getting the readings I should
be getting. IE 3.5 volts is giving me a reading of about 715.
(1024/5 volts) * 3.5 volts = 717.

Thanks to all those that responded.
Kevin

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\18@041053 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

The reason for this is that by directly connecting RA0 to Vss, you could
push enough current into the port to overcome the PIC's relatively strong
ouput drivers, i.e. you were forcing a 1 on an output port set to
zero....not too good for the PIC's health!  When you connected the potential
divider, you had a much higher source impedance which only raised the
voltage of the port a few mV.

Regards

Mike

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...