Electronic – Determining which power supply is connected to our circuit

powersensingvoltage

I am designing a small dongle that will have features either enabled or disabled as a function of the supply voltage. I want the device to be low-power and run, for the most part, off a 3V coin-cell battery. However, I am provisioning the design such that the bus may be powered by one of three sources: the 3V coin cell, 4.5V external battery pack, or VUSB.

The motivation for requiring that we know which source is powering the bus is that, to increase operating lifetime, certain features (like seven-segment indication) should be disabled if we are not using one of the two higher-power options (VUSB, or external 4.5V). So, the real problem to solve is how to determine if the 3V coin cell is selected, otherwise we can assume the supplement features can be enabled.

My first thought was to include a difference amplifier in the design. The implementation would have one op-amp input on the bus and the other on the 3V coin-cell rail. Although this should work, it would add a few extra dollars to the overall design cost which, of course, I would like to avoid if possible.

Another options could be something with an on-board ADC by using the 3V as the Analog Reference (AREF). But things begin to overcomplicate at this point and we begin to create unnecessary restrictions on the use-cases of the device (like always requiring the 3V cell be present).

Any suggestions?

Best Answer

There's likely no need to use a voltage divider; plenty of MCUs are capable of using the internal reference as the input and the supply as the reference. For instance, on the ATmega328P:

ADMUX &= ~(_BV(REFS1) | _BV(MUX0));
ADMUX |= _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);

Then you can reverse the equation for the ADC count and solve for voltage:

\$ADC = {{1.1\text{V} \cdot 1024} \over V}\$

\$V = {{1.1\text{V} \cdot 1024} \over ADC}\$

Or if you don't need an exact value then you can set thresholds and compare directly:

\$ADC_{th} = {{1.1\text{V} \cdot 1024} \over 3.4\text{V}}\approx 331\$

Related Topic