1
\$\begingroup\$

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?

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Why not use the internal reference? \$\endgroup\$ Commented Jul 28, 2015 at 3:08
  • \$\begingroup\$ @IgnacioVazquez-Abrams, I thought of this, too. At least with the controllers I have worked with, the internal reference has been 1V1, so the best we can do is determine if the 3V coin cell is present or not. The presence of the coin cell is necessary but not a sufficient test to determine which supply is currently connected to the bus. Unless, of course, the coin cell is not present, then we have our answer. \$\endgroup\$
    – sherrellbc
    Commented Jul 28, 2015 at 3:12
  • \$\begingroup\$ Measure the reference in relation to the supply voltage. \$\endgroup\$ Commented Jul 28, 2015 at 3:13
  • \$\begingroup\$ Agreed with @IgnacioVazquez-Abrams - use the internal 1.1V ADC reference, and put measure VCC through a voltage divider on the ADC. The ADC can easily tell what the source voltage level is. \$\endgroup\$ Commented Jul 28, 2015 at 3:14
  • \$\begingroup\$ @IgnacioVazquez-Abrams, but would it not just return the max value? If we have 3V compared against 1V1 or 5/4.5V compared against 1V1 we will get the same conversion result. \$\endgroup\$
    – sherrellbc
    Commented Jul 28, 2015 at 3:14

2 Answers 2

1
\$\begingroup\$

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\$

\$\endgroup\$
2
\$\begingroup\$

You can use the ADC of a microcontroller. Leave the external AREF pin out of the picture and use the internal reference voltage (such as 1.1V for AVR chips), and feed the source voltage into the ADC channel by way of a voltage divider.

As noted by Brian Drummond, it would be a good idea to drive the voltage divider from an I/O pin (if you have any available). It will still be the full source voltage (or at least +95% of it). Then you can drive the pin HI, measure the voltage, and shut the pin off. This will prevent constant current flow, reducing power consumption.

The circuit shown will produce the following voltage levels:

  • 5V -> 1V
  • 3V -> 0.6V
  • 1V -> 0.2V

schematic

simulate this circuit – Schematic created using CircuitLab

Vout = Vin * R2 / (R1 + R2)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ For low power applications you probably want to source the voltage divider from an output pin, set to '1' to measure, and tri-state otherwise. As drawn, this circuit pulls more power than 20 sleeping MSP430s... \$\endgroup\$
    – user16324
    Commented Jul 28, 2015 at 11:54
  • \$\begingroup\$ Excellent Point. \$\endgroup\$ Commented Jul 29, 2015 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.