Firstly I should say I'm not sure how feasible this is, and that if someone has a better solution I would love to hear it.

I have the following situation. I have a microcontroller which draws an average of about 80mA (could be up to 300mA for a very short time during boot). It operates on 3.3V. I'd like it to read the state of several 24V DC lines. No more than one line will be on at a given time. Said line may blink on and off, however.

I'd like to power my microcontroller from these same lines I'm reading. Here's a very rough solution I thought of. I'm not an EE so please point out any glaring errors. :)


Is this a reasonable approach or am I going down the completely wrong path? I'm also considering adding a lithium ion battery, but I worry I'd stress it a lot by not being able to provide a constant charge source and instead I'd be charging in really small increments at semi-random intervals.

Edited for clarity.


2 Answers 2


It's a reasonable approach if: 1) you have a good idea of how long the power will be out, and 2) if power is out too long, your system must reset itself and restart gracefully when power returns, and 3) repetitive resetting will not damage the system (sort of same as 2)

You can use with a large capacitor with the numbers you provided. Here's one way to work out the size of the capacitor.

There are two simple formulas you can use:

  1. Q = CV is the electrical charge stored for capacitance C with voltage V in unit of Coulombs
  2. Definition of Coulomb: 1 Coulomb = 1 Ampere * 1 second, or the amount of charge transferred if a current of 1 Amp flowed for 1 second.

So if your MCU circuit must be powered for 1/2 second at 80 mA, that is 0.08A * 0.5s = 0.04 Coulombs of charge transferred during that time.

For now let's assume your DC-DC converter has 100% efficiency, and let's say it can run down to 6V input and still maintain 3.3V output. So when the power cuts, the capacitor starts at 24V and discharges down to 6V before the DC-DC converter cuts out and we want enough capacitance at the input so that this takes 0.5 seconds.

Using Q=CV, we have 0.04 = C*(24 - 6). Solving for C, we get C = 2,222 microFarads.

So let's say our DC-DC converter is 85% efficient, so we bump this up: 2222/.85 = 2614 uF.

So you need a large capacitor but it is within reason.

One other important thing to consider is charging a 2,700 uF capacitor. There will be very high inrush current when the 24V comes back on. This current will be limited by the diode resistance, supply + wire impedance, and capacitor impedance. Read the datasheets for the diode, capacitor, and your power supply. Diodes and capacitors will have limits on surge current and how long the surge can last. Capacitors have a repetitive peak current spec. Your 24V supply may not handle the heavy load gracefully (e.g. if it has foldback current limiting it may restart several times).

So yes your approach is feasible but issues such as high inrush current, MCU's reset circuit, and ability of downstream circuits to handle power cycling will require great consideration.

  • \$\begingroup\$ Would putting a limiting resistor between the diodes and cap be a reasonable way to mitigate the inrush current problem? I don't have a hard number on what the 24V supply can handle, but I can probably experiment and get a reasonably close number. \$\endgroup\$
    – brenzo
    Jan 24, 2017 at 15:41

While it is likely that at least one of these lines will be active at any time, it is not guaranteed. It is safe to assume, however, that no more than one will be active at any given time.

you cannot have two conflicting statements next to each other.

Is this a reasonable approach

it is generally not a good idea to power a device, including a mcu, on a power source that may disappear.

to the extent that power may be gone for a short period of time, there are ways to get around it. but without you articulating the nature of the outage, it is hard to recommend any particular approach.

sensing the 24v lines however, can be done easily.

  • \$\begingroup\$ The lines might be out for a half a second or so at a time. Otherwise the machine is off and I don't need to be powered anymore at that time. I'm already sensing the lines with photo-couplers. \$\endgroup\$
    – brenzo
    Jan 21, 2017 at 23:34

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.