Re: PIC onboard ADC Questions
From: John (jecottrell_at_sprynet.com)
Date: 3 Apr 2004 16:34:28 -0800
> I presume you've got a regulator for the PIC.
Yes, tentatively the Microchip MCP1701 @ 3v. (Which brings up another
problem that you allude to later....finding parts in small quantities
that are THE PART for THE PROBLEM. Any guidance is appreciated.)
> Well, you do know the limit on ADC source impedance for full
> accuracy/speed is 2.5K to 10K depending on the PIC model, yes?
Yes and no. I assumed that there was some limit, but in my initial
reading of the datasheets it wasn't stated in an obvious enough way
that I wouldn't miss it. Now that you have stated the fact and I have
gone back to the datasheet and found that precise statement, I get it.
> I would not suggest going much beyond the data sheet maximum impedance
> for the input. If you are willing to lose a lot of accuracy and have
> limited temperature range at the high end, you might be able to push
> it a bit, but.. at 10K source impedance and a 3:1 divider, 15K and 30K
> resistors, you'd be drawing 288uA from the battery.
No, I need a reasonable amount of accuracy, really I need to detect
the trend of the voltage drop at the end the battery's life (overall
health and estimate of the remaining life.) I also expect the
temperature range to vary significantly within the enclosure. Now that
the extremely high impedance input is out I have accepted the fact
that it will have to be switched. Not a problem.
> How about using a P-channel MOSFET and perhaps your open-drain PIC
> port pin (if appropriate) to switch the high side of your divider.
> .-. +7.2V
> | |
> 10K | | | S
> '-' ||-+
> | ||-> p-channel
> + -||-+ D
> | |
> | |
> | .-.
> To PIC open drain -----------+ | |
> | | | Rs
> | '-'
> OR --- | |
> | n-channel | +-------o
> ---> |D |
> ||-+ .-.
> ||<- | |
> To PIC -||-+ | | Rp
> port pin | D '-'
> | |
> === ===
> GND GND
> You can then use appropriately low values for Rs and Rp (source
> impedance will be Rs || Rp = (Rs * Rp)/(Rs+Rp), of course, and output
> voltage will be Rp/(Rp+Rs). If you want to, you can even choose
> a low value for Rs+Rp in order to load the battery to the desired
> You don't need the N-channel MOSFET if the open-drain output is
> available and rated for the maximum voltage. If you need both, you can
> get dual MOSFETs in SO-8 and smaller packages (see IRF).
> If cost is an issue, you could use an MMBT4403 and a couple of
> resistors with an open-drain port pin (eg. RA4 on the PIC16F628) for a
> total of about 3 cents. The slight drop across the BJT (about 10mV, or
> 3-4mV referred to the ADC input) is only about 1 ADC count and can be
> figured into your measurement if you like.
> | |
> .-. |
> 10K | | |
> | | |
> '-' |
> | |< MMBT4403
> | |\ 4K99 1%
> .-. | ___
> 10K | | -|___|-+------o
> | | |
> '-' .-.
> | | |
> o | | 2K49 1%
> Open drain PIC port '-'
I have initial shallow understanding of what's going on above. My
initial approach was this (it will probably highlight my fundamental
misunderstanding of MOSFETs):
+7.2v o-----------------+------------o to MCP1701
|__ | N Channel (enhancement)
|__ |-------+--o To PIC
+-+ | | Pull Down
| | | |
| | +-+
+----------o To PIC ADC
Bad idea? Good idea, poor execution?
> >Option 2: Isolate the current divider with a analog switch (MAX4514/5)
> >until it is time to read the battery voltage.
> Yes, you can turn this on for just a few tens of microseconds to make
> the reading, so even if the divider draws 1mA at 50usec/reading it
> will average out to just about nothing (50nA) at 1 reading a second.
> Be sure to turn the ADC module off inside the PIC when you are not
> using it.
> Yes, that would work the same as above with one part rather than two
> or three as shown above,but is a single-sourced part, and some have
> reported delivery issues with Maxim parts in particular. Your call.
I agree, this is a recurring problem and your solutions are well
within my requirements for current, cost, and simplicity.
> >Priorities are:
> >1. Low Current
> >2. Cost
> >3. Simplicity
> Okay, nothing there about actually being able to get the parts. ;-)
4. Availability (as mentioned above....)
Thanks one and all for the ideas and support.