Generic question on measuring voltage level - Page 1
Forum section: electronics / general

author: fabiodl
author_rank: Frequent Contributor
timestamp: November 23, 2014, 05:07:36 pm
content: I am using a microcontroller (specifically SAM D20, but it doesn't matter that much).My circuit has a charger input which charges a lithium battery through a MCP73831. The battery is followed by a 3.3 voltage regulator. The microcontroller is able to disable the voltage regulator (which has an enable pin).To measure the voltages at the charger input and at the battery I use a simple voltage divider that reduces the voltage of the battery / charger to a voltage compatible with the mc i/o. I then measure this voltage with the microcontroller's adc.However, this gives a problem: even if I disable the voltage regulator, the microcontroller is powered through the measuring pins. Its vcc pins even power other devices (i2c sensors) on the board.I could make a voltage divided that brings the voltage down to a point where the the microcontroller is not able to power up anymore, but I would loose sensitivity in the measured voltage.I also thought about putting a mosfet between the charger / battery input and the voltage divider, but still I would need to put a pull up resistor for the gate, which would create the same problem.What is the correct way to solve this problem?

author: paulie
author_rank: Frequent Contributor
timestamp: November 23, 2014, 06:17:10 pm
content: The values in your divider are too low. Using higher resistance between the source and the inputs will not be able to power the MCU but can preserve sensitivity.

author: suicidaleggroll
author_rank: Super Contributor
timestamp: November 23, 2014, 06:29:09 pm
content: You could use a P/N mosfet combo on the top side of the divider. P to switch power on/off to the divider, N so your uC can control the P without being pulled up to Vcc. P gate is pulled high and connected to N drain, N gate is pulled low and connected to uC pin. uC pin is high Z or low, N is off, P is off, voltage divider is off. uC pin is high, N is on, P is on, voltage divider is on.

author: dannyf
author_rank: Super Contributor
timestamp: November 23, 2014, 07:51:20 pm
content: The proper way is to switch on the high side. It does add to complexity.The improper way is to use a large serial resistor to limit the current.It does increase signal output impedance, which can be alleviated via a capacitor.To further reduce current through the ADC pin, put a small resistor on the mcu gcc line. However, it only works if you don't mind current consumption.

author: Jeroen3
author_rank: Super Contributor
timestamp: November 23, 2014, 08:16:07 pm
content: Disconnection Vcc (or gnd) from a microcontrollers (or any chip that doesn't support that) renders the ESD diode in each pad useless, and you will start phantom powering the chip using these diodes.Add a opamp voltage buffer in your measurement circuit, this allows you to increase the impedance of the measurement. You're using a few kilo ohms now?Thus saving energy that was otherwise wasted in the resistors. (Get an opamp with a Enable pin)

author: fabiodl
author_rank: Frequent Contributor
timestamp: November 26, 2014, 12:44:18 pm
content: The voltage divider I am using now is 47K + 56K resistors. I do not know if I should go higher. I think I will go with the 2 mos in one package like Si1555DL

author: paulie
author_rank: Frequent Contributor
timestamp: November 26, 2014, 07:33:15 pm
content: It's unlikely your MCU and connected devices are being "powered through the measuring pins" via 47k resistor. Obviously something else is going on and another remedy besides changing divider values is needed.

author: Paul Price
author_rank: Super Contributor
timestamp: November 29, 2014, 01:12:27 am
content: Use a P-Chan MOSFET as shown below or else use a BJT optoisolater. No current drain at all when not strobed by the MCU.Choose a lo-thres (<2V) power P-Chan MOSFET for this circuit.From Farnell, cost quan 1 = $1 Fairchild type FDD4141 is a good choice.

author: hans12
author_rank: Newbie
timestamp: November 29, 2014, 01:21:08 am
content: Try to add a resistor from the tap point to the input pin which measures input voltage to avoid your uC from being powered.In your software take in account of the voltage drop over that resistor.

author: Paul Price
author_rank: Super Contributor
timestamp: November 29, 2014, 01:35:56 am
content: Use an optoisolator. No current when not strobed.

author: Paul Price
author_rank: Super Contributor
timestamp: November 29, 2014, 02:13:45 am
content: Use a PNP transistor that is strobed. No current when not strobed. MCU must correct for slight mV Von voltage drop of PNP if high accuracy is desired.

author: JDubU
author_rank: Frequent Contributor
timestamp: November 29, 2014, 02:16:18 am
content: Maybe I am not understanding your circuit design but if your uC is powered by the 3.3V regulator, you should never use the uC to turn off that regulator.Looking at the D20 data sheet, it has an internal 1V bandgap voltage reference that can be enabled in software as the reference for the ADC.Now use a voltage divider for each point that you want to measure using resistor values that produce a maximum output of 1V for the largest expected input voltage at that point. This will give maximum ADC resolution.

author: rs20
author_rank: Super Contributor
timestamp: November 29, 2014, 02:18:18 am
content: Quote from: Paul Price on November 29, 2014, 02:13:45 amThis plan looks good, except 100 ohm is way too small, right?

author: Paul Price
author_rank: Super Contributor
timestamp: November 29, 2014, 02:22:43 am
content: 100 ohms is not a problem, MCU VDD must be higher voltage than Charger Vin for it to work with diode only isolation. Unlikely, in most circuits, circuit withdrawn.

author: Paul Price
author_rank: Super Contributor
timestamp: November 29, 2014, 02:26:32 am
content: JDubu says,"you should never use the uC to turn off that regulator."The P-Chan circuit proposed above can be used also for power on/off, to completely cut power to the MCU by cutting off power to its 3.3V regulator without any problem..I have used a MCU to turn itself off completely by software with this circuit, 0-power drain when off, but a momentary Power On/Reset switch is necessary for turn on that momentarily applies current to the NPN base strobe input through a diode and a current limiting resistor. Upon MCU reset/turned on, MCU then latches power on.

author: JDubU
author_rank: Frequent Contributor
timestamp: November 29, 2014, 04:38:21 pm
content: Quote from: Paul Price on November 29, 2014, 02:26:32 amYes, I should have said: "you should never use the uC to turn off that regulator -- unless you have an external mechanism to turn it back on and you are not trying to use the uC to make voltage measurements while its source of power is turned off."

author: fabiodl
author_rank: Frequent Contributor
timestamp: December 16, 2014, 11:52:07 am
content: Thank you very much and sorry for the late reply.Is there any reason for which transistor+mos is better than n-mos + p-mos like ?http://docs-asia.electrocomponents.com/webdocs/1300/0900766b81300c3a.pdf?Quote from: JDubU on November 29, 2014, 02:16:18 am

author: JDubU
author_rank: Frequent Contributor
timestamp: December 18, 2014, 07:32:41 pm
content: Quote from: fabiodl on December 16, 2014, 11:52:07 amEither one can be used for this straightforward, low frequency switching application.Google: "bipolar vs mosfet switch" for lots of information comparing their different characteristics.