2
\$\begingroup\$

I have very little background in electronics, I'm from software background.

I'm interested to design a system in which there is an 8-bit micro-controller which should get powered from two different sources:

  • From a battery (in Field mode) and
  • From a USB port (in Factory mode)

Further, the software running on the micro-controller when it gets powered, on the basis of the power source, should enter into respective modes of operation. When powered from battery the algorithm should in run in Field mode and when from USB in Factory mode.

If there are simple ways to do this, then it will save a ton of my efforts to find out other ways of detecting where the device is.

Can anybody help me understand how to achieve this?

Thank you.

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

One very simple way is to use diodes (use Schottky diodes for smaller voltage drops) for each power source, and have a pull-down resistor on the source side. You can then use an IO pin per supply source on your MCU to detect which is plugged in.

For example, say you have a 3V battery and 3.3V MCU. This circuit will reduce the 5V from the USB to an acceptable level for the IO pins.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 1
    \$\begingroup\$ Suggest to replace D2 with a P-channel FET gated by the leftmost "To MCU" signal to get same functionality without losing power in the diode when running from the battery. \$\endgroup\$ – PkP Jan 7 '15 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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