Searching \ for '[PIC] Input on RA3 power the unit?' 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/microchip/ios.htm?key=input
Search entire site for: 'Input on RA3 power the unit?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Input on RA3 power the unit?'
2005\12\19@154438 by Padu

face picon face

Hi,

I'm doing some tests with the PIC (18F452) internal ADC on port RA3. Although everything is working perfectly, I noticed something that I found very curious.

I'm using the RA3 as an ADC to measure voltage levels on a battery pack (typical 14.4V). Between the battery pack and the PIC port, there is a resistor divider circuit and a unit gain opamp working as a voltage buffer.
When the unit is on, I set one of the PORTB pins up to turn a LED on, and I notice that when I turn my device off, the "ON LED" is still lit, though not as bright as when the unit is powered on. I measure the VDD pin and there is some voltage there (around 2.5V when RA3 is around 4V).

Is this bad for the uC? Should I have some kind of switch to disconnect the voltage measurement circuit when device is turned off?

Cheers

Padu

2005\12\19@163928 by Jesse Lackey

flavicon
face
Hi - I had to deal with the same problem recently.
As for uC damage - I'd guess no, but I'm not sure.
As for how to deal with it - if possible a mechanical switch is easiest,
so when the unit is turned off the battery voltage line is disconnected
as well.
Note that if you leave things as-is the PIC is never fully turned off,
and there will be a constant battery drain even when "off".

For the design I have, for various reasons I couldn't just measure the
voltage after the on/off switch, and I couldn't use the other pole on
the on/off switch.

So what I did: I put a PFET on the battery voltage line to where my
divider is, and the PFET gate is pulled up w/100K to the battery
voltage.  The PFET gate is also connected to an NFET to ground, the NFET
gate is pulled down to ground with a 10K and goes to a PIC pin.

Now when the PIC is off, the NFET is pulled down (off), and the PFET is
pulled up (off).  When the PIC is on, and the PIC pin control line is 0,
the NFET gate is grounded (off), and pfet is off.  When the PIC pin
control line is 1 (3.3V in my case), the NFET is on, which connects the
PFET gate to ground, turning on the PFET, so the battery voltage is now
put across the resistor divider (2.2K and 1K in my use) and an A/D
measurement is made.  This happens in about 1msec every 300msec or so,
so the drain on the battery is slight.

Anyway, it works.  No opamp needed, but a bunch of (small, cheap) parts.
 And essentially zero battery drain when the PIC is off.

J


Padu wrote:

{Quote hidden}

2005\12\19@164551 by Bob Axtell

face picon face
Padu wrote:

>Hi,
>
>I'm doing some tests with the PIC (18F452) internal ADC on port RA3. Although everything is working perfectly, I noticed something that I found very curious.
>
>I'm using the RA3 as an ADC to measure voltage levels on a battery pack (typical 14.4V). Between the battery pack and the PIC port, there is a resistor divider circuit and a unit gain opamp working as a voltage buffer.
>When the unit is on, I set one of the PORTB pins up to turn a LED on, and I notice that when I turn my device off, the "ON LED" is still lit, though not as bright as when the unit is powered on. I measure the VDD pin and there is some voltage there (around 2.5V when RA3 is around 4V).
>
>Is this bad for the uC? Should I have some kind of switch to disconnect the voltage measurement circuit when device is turned off?
>
>Cheers
>
>Padu
>  
>
VDD is rising because each input has protective diodes, so when  a
positive voltage is applied to almost any pin, the  voltage will cause
voltage to
be applied to the device.

It is not a good idea to allow this to occur, because the PIC will not
reliably reset at powerup.

--Bob

--
Note: To protect our network,
attachments must be sent to
spam_OUTattachTakeThisOuTspamengineer.cotse.net .
1-520-777-7606 USA/Canada
http://beam.to/azengineer

2005\12\19@165057 by Mike Hord

picon face
> Is this bad for the uC?

You're putting current in places it maybe shouldn't be.

There are diodes connecting each pin to Vdd and
ground such that the voltage on those pins is clamped
to within one diode drop of Vdd or ground.  If Vdd = 0
(it is unpowered) and a voltage is present on a pin, it
will flow through the protection diode to the Vdd rail,
and into the rest of the circuit.

Where is this leakage coming from?  The battery in
the battery pack?  Or do you have something turning
the PIC off while the rest of the circuit is powered?

Mike H.

2005\12\19@165203 by Jinx

face picon face

> Is this bad for the uC? Should I have some kind of switch to
> disconnect the voltage measurement circuit when device is
> turned off?

Hi Padu. It might not be "bad" for the uC but it's not a very
"professional" way to leave the circuit. You could have problems
at a later time because of a battery/equipment/brain fault

http://www.piclist.com/techref/power/parasitic.htm

One simple way might be to increase the resistors in the voltage
divider to limit current available from the battery. Or an in-line
FET controlled by a uC pin, perhaps between the junction of the
divider to the i/p of the op-amp. Or better, a s/w-controlled
analogue switch (4066/4051) at the battery terminal to disconnect
the divider altogether. This would have to be powered from the
battery (but it's CMOS) and you'll have to boost the logic drive
to get the "1" control. Unless you use a 74C type

2005\12\19@171929 by Jinx

face picon face
part 1 207 bytes content-type:text/plain; (decoded 7bit)


> So what I did: I put a PFET on the battery voltage line to
> where my divider is, and the PFET gate is pulled up w/100K
> to the battery voltage

Like this ?


part 2 1110 bytes content-type:image/gif; (decode)


part 3 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2005\12\19@182156 by Andre Abelian

flavicon
face
Padu,

not enough info to determine where the problem might be.
It sounds like when your device is off  pic gets power from some where
and it looks like portb internal pullup is enabled.
Are you turning led on by applying 1 ? if yes then swap the led
then drive Low to see if it goes a way.

another possibility is you are driving portb led pin under interrupt
that causes to dim. Check led pin see if there is any pulse if yes
then that is software bug.

Andre Abelian



Padu wrote:

{Quote hidden}

2005\12\19@183250 by Jesse Lackey

flavicon
face
Hi - exactly.  Thanks Jinx, I didn't realize I could post attachments to
piclist, else I would have put in an image grab from the schematic.

Several minor points about the circuit... pls. correct me if I've got
something wrong.

The PIC A/D input sees 2.2K in parallel with 1K, so it is being driven
with a sufficiently low impedance to be reasonably accurate.

The PIC runs at 3.3V in this design, and 2.2K and 1K will scale a 9V
battery (about 9.4V with light load brand new) to below 3.3V.

The 2.2K and 1K in series is enough to discharge any parasitic
capacitance or leaky diodes used for reverse-battery protect and
multiple battery power "OR"-ing.  In my design there are two 9V battery
and a DC inputs, and I found some nice low Vf diodes (MBRM130LT1OSCT-ND)
to "OR" them all together for the main power bus, but they leak lots and
so what originally wound up happening is if there is DC input, and no
battery, the diode leakage would make it look like there was a battery
with my original design of 1M / 500K divider to opamp follower to A/D.

The current draw of the 2.2K + 1K divider on a fresh 9V battery is about
2.8mA, but since measurement time is around 1msec every 300msec in my
use the overall drain is pretty small.

One can add more battery inputs (or whatever) to be measured, one needs
a pfet, 100K, nfet, 10K and PIC pin for each.

About the only downside is the board space used up by this small pile of
parts.

I've been using this nfet w/pulldown to control pfet w/pullup in a
number of places.  It would be fab to find a chip that has a couple
copies of this arrangement to reduce the number of parts.  I looked
briefly in digikey, didn't see much.  Anyone?

Anyway ... hope it helps.
J



Jinx wrote:

{Quote hidden}

2005\12\19@192422 by Jinx

face picon face


> I didn't realize I could post attachments to piclist, else I
> would have put in an image grab from the schematic

It's mostly OK if small. I think there's a size limit but not sure
what it is. Many an untrimmed post (GRRRR) is way bigger
than a schematic gif anyway, probably 20-30kB



2005\12\19@195032 by olin piclist

face picon face
Jesse Lackey wrote:
> The PIC A/D input sees 2.2K in parallel with 1K, so it is being driven
> with a sufficiently low impedance to be reasonably accurate.

Way lower than neccessary.  You are draining 2.8mA from the batter thru this
divider.  The PIC A/D needs about 10Kohms for most 16F varieties to measure
accurately.  Your impedence is nearly 15 times lower.  You could at least
scale the resistors by 10 and cut down the wasted battery current
accordingly.

> The PIC runs at 3.3V in this design, and 2.2K and 1K will scale a 9V
> battery (about 9.4V with light load brand new) to below 3.3V.

Yes, to 2.8 volts.

> The current draw of the 2.2K + 1K divider on a fresh 9V battery is about
> 2.8mA, but since measurement time is around 1msec every 300msec in my
> use the overall drain is pretty small.

How are you powering down the divider?


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2005\12\19@200920 by Jesse Lackey

flavicon
face
Hummm, I'm using 18F parts, and the datasheet for the A/D calls for 2.5K
source impedance maximum in order for it to meet specs.  However
accuracy isn't very important here.

The divider gets powered down when the PIC sets the nfet gate to ground.
 Then the pfet pullup turns it off.

Tx
J


Olin Lathrop wrote:

{Quote hidden}

2005\12\19@205023 by Jinx

face picon face

> The divider gets powered down when the PIC sets the nfet gate
> to ground.  Then the pfet pullup turns it off.

BTW an NPN transistor would do instead of the N-ch FET, if
that saves a few c

2005\12\20@064644 by olin piclist

face picon face
Jesse Lackey wrote:
> Hummm, I'm using 18F parts, and the datasheet for the A/D calls for 2.5K
> source impedance maximum in order for it to meet specs.

Some PICs require a lower source impedence.  The normal value for most PIC
16 is 10Kohms which is what I used in the calculations since you didn't
specify.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2005\12\20@064741 by Gerhard Fiedler

picon face
Jesse Lackey wrote:

> I've been using this nfet w/pulldown to control pfet w/pullup in a
> number of places.  It would be fab to find a chip that has a couple
> copies of this arrangement to reduce the number of parts.  I looked
> briefly in digikey, didn't see much.  Anyone?

Not exactly the same, but the 4066 or some analog switch like this comes
pretty close, no?

Gerhard

2005\12\20@092121 by Mike Hord

picon face
> Way lower than neccessary.  You are draining 2.8mA from the batter thru this
> divider.  The PIC A/D needs about 10Kohms for most 16F varieties to measure
> accurately.  Your impedence is nearly 15 times lower.  You could at least
> scale the resistors by 10 and cut down the wasted battery current
> accordingly.

There is something to be said for adding a little dummy load to the
battery during voltage sense.  If you have a micropower circuit which
is drawing mere microamps, pulling a milliamp or two from the
battery gives a clearer view of the true remaining capacity.

I'm using a very similar circuit for battery check in a system which
will have much higher peak currents for a few seconds at a time
than it does during battery check times.  By loading the battery
with the battery check circuit, I can simulate the peak current draw
and know whether I need to be worried.

Mike H.

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