I am powering a 5V microcontroller (arduino clone, atmega328p) using a 9V block and a buck converter. Now I want to let the microcontroller occasionally measure the battery voltage, so I can get an idea of how full it is.

My first idea was to use a simple voltage divider:

I’ve chosen the resistor values so that:

  • the voltage at the measure output is < 1.1V, to be able to use the 1.1V internal reference of the atmega’s ADC
  • R1 || R2 < 10kΩ, since the atmega datasheet says “The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less”

This is great and all, but what bothers me is that this circuit will constantly draw ~100µA from the battery.

So, my next thought was to add a mosfet to the divider, to switch it on only while measuring:

This is obviously bad, because now when the mosfet is off, the ADC input sees the whole battery voltage.

To address that issue, I’ve added a second mosfet into the measure path:

This works, and it does not draw any current, except while measuring.

However, it’s quite a few parts. So I’m curious if anyone has an idea how to do this with just a single mosfet. It seems to me like it should be possible, but I haven’t figured out how.

Oh, and if I’m doing something stupid here, please tell me :)

  • nilclass@discuss.tchncs.deOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Hm, I don’t understand how this is supposed to work - is that a n-channel or p-channel FET?

    When I sketch it using falstad’s circuitjs, it looks like the FET (n-channel) is a little bit on all the time

    and fully on, when a pulse is applied

    • jjagaimo@lemmy.ca
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      It is an N channel FET. The concept is called “bootstrapping” since Vgs needs to be greater than Vth for the MOSFET to be on. When the FET is on the high side and you want the full 9V on the output, you use the diode to charge the capacitor, and the other side of the cap is 0V. Then, when the other side of the cap is connected to 9V, the charge on the cap can’t go anywhere so the voltage on the other side jumps to 18V. This creates a Vgs of 9V. Ideally you would have something better to drive the gate to fully turn off the FET, but I just used a quick and dirty driver where the bootstrap capacitor directly feeds the gate instead of being the input to the driver. Because if this, the Vgs doesn’t drop completely to 0

      • nilclass@discuss.tchncs.deOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Nice, than you for sharing!

        I won’t be using this for my measurement issue (the other options are much simpler, and i was aiming for less parts, not more), but I’ll do some experiments to familiarize myself with bootstrapping