CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ADC accuracy degrades quickly with battery

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zonemikel



Joined: 13 Oct 2007
Posts: 53
Location: Texas

View user's profile Send private message Visit poster's website Yahoo Messenger

ADC accuracy degrades quickly with battery
PostPosted: Wed Oct 31, 2007 8:54 am     Reply with quote

Hello ppl,
Thanks again for your previous help. I have a nice module that reads a analogue value and transmits it via serial and displays it on a screen.

I wanted to test to see how long it would last on a 9v battery, the 9v goes to a 5v regulator and to the pic/7 seg/ leds/ etc. I bought the cheepest batteries they were 2 9v for $1. I got the cheep ones because i was just going to run them till they ran out.

Anyway it reads the ADC conversion fine for about a hour then the adc conversion starts climbing. It will just slowly continue to go up. The reading should be about .80v and it gets up to like 1.19v. At this point if i plug in a good battery it works fine. If you guys need the code ill post it.

What im thinking is since the conversion goes from 10 bit adc it assumes that 5v = 1023 so when this value decreases the value of whatever your reading gets inflated. I believe the vref is the power that goes into the pic.

One more thing, the module stayed on for a good 12hours then i turned it off. So it will continue to function for a very long time, but the ADC reading is off.

tia
-zonemikel
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

Regulator output?
PostPosted: Wed Oct 31, 2007 10:12 am     Reply with quote

What PIC are you using?
Did you monitor the output of the regulator? If that is still a constant 5 volts you shouldn't have a problem. Using a 3.3V PIC and LDO style regulator with the 9V input would allow for much longer operating time IMO.
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Wed Oct 31, 2007 11:15 am     Reply with quote

There's a way to compensate for the falling supply rail. Create a zener diode voltage reference circuit (say approx 2.5V or something like that) and monitor this voltage with a spare A/D input on your PIC.

Just before you take an A/D reading (of whatever you are reading), read the voltage from the zener reference. When that reading starts to rise, the Vdd supply rail is falling. Based on the full power zener reading and the amount it has risen from that value, you can calculate what the actual supply rail is. You can use this value to compensate your other reading.

You can also put a FET in the zener reference circuit and use the PIC to turn the FET on/off to conserve battery power.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 31, 2007 12:28 pm     Reply with quote

Quote:
the 9v goes to a 5v regulator

Read some articles on the quiescent current of voltage regulators.

See ckielstra's post in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=26907

See Ttelmah's post in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=26275
zonemikel



Joined: 13 Oct 2007
Posts: 53
Location: Texas

View user's profile Send private message Visit poster's website Yahoo Messenger

Re: Regulator output?
PostPosted: Thu Nov 01, 2007 8:29 am     Reply with quote

Quote:
There's a way to compensate for the falling supply rail. Create a zener diode voltage reference circuit (say approx 2.5V or something like that) and monitor this voltage with a spare A/D input on your PIC.

Just before you take an A/D reading (of whatever you are reading), read the voltage from the zener reference. When that reading starts to rise, the Vdd supply rail is falling. Based on the full power zener reading and the amount it has risen from that value, you can calculate what the actual supply rail is. You can use this value to compensate your other reading.

You can also put a FET in the zener reference circuit and use the PIC to turn the FET on/off to conserve battery power.


I really like this idea I dont know why i didnt think of it. If i have a known voltage and put that to a pin then i can use it to get the difference. For instance if i set up a known 1v circuit to RA1 then i would know that this should always be 1v so before i take my reading i would read RA1 and if it isnt 1v i would take the difference between 1v and whatever reading I get then subtract/add that to whatever I'm reading on RA0.

I'm not to worried about conserving battery power. I left the thing running for a good 12 hours on a .50c battery and it ran but did not accurately display the right ADC conversion. All i was trying to do is get it to be accurate for more of its life, if it stays on for 12hrs+ i want it to work correctly for at least part of that.

With y'alls tips I'm sure I'll be able to work something out, thanks.

bwhiten wrote:
What PIC are you using?
Did you monitor the output of the regulator? If that is still a constant 5 volts you shouldn't have a problem. Using a 3.3V PIC and LDO style regulator with the 9V input would allow for much longer operating time IMO.


Its a 877- 04 in 44pin plcc socket. I have to take a real close look at the regulator, it might be failing and/or it might be pulling a lot of current.[/quote]
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 01, 2007 9:05 am     Reply with quote

Quote:
I really like this idea I dont know why i didnt think of it. If i have a known voltage and put that to a pin then i can use it to get the difference. For instance if i set up a known 1v circuit to RA1 then i would know that this should always be 1v so before i take my reading i would read RA1 and if it isnt 1v i would take the difference between 1v and whatever reading I get then subtract/add that to whatever I'm reading on RA0.
Nice idea, but why do it in software if you can do it in hardware? By default the A/D converter of the PIC16F877 uses Vdd as the reference voltage. You can also choose to supply your own (zener generated) reference voltage to pin A3 and than the hardware will do the calculations for you.
bwhiten



Joined: 26 Nov 2003
Posts: 151
Location: Grayson, GA

View user's profile Send private message

Regulator output
PostPosted: Thu Nov 01, 2007 9:23 am     Reply with quote

Most importantly to me is you don't want the output from the regulator to be dropping below it's rated output. If it is that means you are no longer operating the device within it's specifications. At that point, most of the rest of it's specs are also out the window, such as ripple, load regulation, operating temperature, power dissipation, etc. An LDO regulator will let your input voltage drop much closer to the rated output before failing. I don't know what else is running on the regulator output but an unstable (drooping) output will have a negative impact on most circuitry.
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Thu Nov 01, 2007 9:55 am     Reply with quote

Be careful with the calculation. It's not an add or subtract issue, it's a scaling issue (multiply/divide).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group