Author Topic: Generic question on measuring voltage level  (Read 4877 times)

0 Members and 1 Guest are viewing this topic.

Offline fabiodl

  • Regular Contributor
  • *
  • Posts: 107
Generic question on measuring voltage level
« on: November 23, 2014, 05:07:36 pm »
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?
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Generic question on measuring voltage level
« Reply #1 on: November 23, 2014, 06:17:10 pm »
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.
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1455
  • Country: us
Re: Generic question on measuring voltage level
« Reply #2 on: November 23, 2014, 06:29:09 pm »
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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: Generic question on measuring voltage level
« Reply #3 on: November 23, 2014, 07:51:20 pm »
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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 3567
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Generic question on measuring voltage level
« Reply #4 on: November 23, 2014, 08:16:07 pm »
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)
 

Offline fabiodl

  • Regular Contributor
  • *
  • Posts: 107
Re: Generic question on measuring voltage level
« Reply #5 on: November 26, 2014, 12:44:18 pm »
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
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Generic question on measuring voltage level
« Reply #6 on: November 26, 2014, 07:33:15 pm »
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.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Generic question on measuring voltage level
« Reply #7 on: November 29, 2014, 01:12:27 am »
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.
« Last Edit: November 29, 2014, 10:22:46 am by Paul Price »
 

Offline hans12

  • Contributor
  • Posts: 6
Re: Generic question on measuring voltage level
« Reply #8 on: November 29, 2014, 01:21:08 am »
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.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Generic question on measuring voltage level
« Reply #9 on: November 29, 2014, 01:35:56 am »
Use an optoisolator. No current when not strobed.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Generic question on measuring voltage level
« Reply #10 on: November 29, 2014, 02:13:45 am »
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.
« Last Edit: November 29, 2014, 02:42:16 am by Paul Price »
 

Offline JDubU

  • Frequent Contributor
  • **
  • Posts: 334
Re: Generic question on measuring voltage level
« Reply #11 on: November 29, 2014, 02:16:18 am »
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.

 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2194
  • Country: au
Re: Generic question on measuring voltage level
« Reply #12 on: November 29, 2014, 02:18:18 am »
Assuming you are willing to make a simple calibration by your MCU in software for small voltage errors due to resistive and diode voltage drops and 5% approx. of Charger Vin accuracy or better is OK.

Complete isolation, like the other circuits I proposed, no MCU turn-on.

This plan looks good, except 100 ohm is way too small, right?
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Generic question on measuring voltage level
« Reply #13 on: November 29, 2014, 02:22:43 am »
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.
« Last Edit: November 29, 2014, 02:43:55 am by Paul Price »
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Generic question on measuring voltage level
« Reply #14 on: November 29, 2014, 02:26:32 am »
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.
« Last Edit: November 29, 2014, 02:41:11 am by Paul Price »
 

Offline JDubU

  • Frequent Contributor
  • **
  • Posts: 334
Re: Generic question on measuring voltage level
« Reply #15 on: November 29, 2014, 04:38:21 pm »
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..

Yes, 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."   :)


 

Offline fabiodl

  • Regular Contributor
  • *
  • Posts: 107
Re: Generic question on measuring voltage level
« Reply #16 on: December 16, 2014, 11:52:07 am »
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
?

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.
« Last Edit: December 16, 2014, 01:01:16 pm by fabiodl »
 

Offline JDubU

  • Frequent Contributor
  • **
  • Posts: 334
Re: Generic question on measuring voltage level
« Reply #17 on: December 18, 2014, 07:32:41 pm »
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
?

Either one can be used for this straightforward, low frequency switching application.
Google: "bipolar vs mosfet switch" for lots of information comparing their different characteristics.
« Last Edit: December 18, 2014, 10:09:05 pm by JDubU »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf