MySensors in a NERF gun - a question about capacitors


  • Plugin Developer

    So I have this huge NERF gatttling gun that I was trying to have some fun with. I wanted to be able to lock or unlock the trigger remotely based on face recognition, which is handled by a mobile phone at the front of the gun.

    The problem I ran into is that whenever the gun's motors spin up then cause a power loss to the arduino. Now I could add a separate power supply for the Arduino, but it would obviously be much cleaner if it looks like a normal gun from the outside.

    So I figured I needed some kind of "electrcity buffer" that would continue to provide the Arduino with stable power whenever the motors spin up.

    I realised I know very little about capacitors.

    • Which type do I need? Some are "aluminium high frequency". Are motors high frequency? Should I get those? Do they charge up faster?
    • Is there any risk that a capacitor makes the situation worse? E.g. if it's empty and it sucks up electricity that should be going to the Arduino?
    • Some go up to 400 volts. Some seem a perfect match at 5.5 volts. How do you choose what voltage rating to get? Is there a trade-off? Is it wise to go a few volts above the voltage in your system?
    • I figured I wanted as many Farads as possible? So I found these capacitors with 4F. But I realised I have no idea if that's a lot. How can I compare it to, say, batteries? How long can a 4F 5.5v capacitor run an Arduino nano + radio?
    • Is there a downside to having a lot of Farads, other than the cost?
    • How do I make sure the energy in the capacitor is "reserved" for the Arduino? After all, the motors are on the same circuit, and could perhaps suck it dry instead?


  • @alowhum small rechargeable battery across arduino supply rail with checking diode in neg side of main supply rail to arduino? Also might try cap across rechargeable battery to filter main rail pulses?



  • I think capacitors with a blocking diode would be the right call. How long does it need to supply power to the Arduino for? And are you running anything else off of this, or only the Arduino?

    Basically, knowing how much power draw (current) that you need, and how long you need it for, and then also how much of a voltage droop is acceptable will tell you how big the capacitors need to be. I'm going to use a bunch of round numbers for easy math, but hopefully you can see how to adapt for your project.

    Let's say you're at 5V, and you're drawing 100mA (a lot for just an Arduino, but not so much if you're also running LEDs and a radio, or a servo, or whatever).

    If the voltage droop from the batteries due to the motors spinning up lasts for 1 second, then we just need to calculate how much charge that is, and how big the capacitor needs to be to keep it within a certain range.

    The total charge, in Coulombs, is 100mA x 1 second = 100mC.

    The voltage on a capacitor is: V = charge (in Coulombs) / capacitance (in Farads)

    So say you want the voltage drop on the capacitor to be less than 0.5V. Then that's 10% of the initial voltage, so 10x on the capacitor (1/10%) gives you the ballpark. Which means 1F capacitor should be the ballpark you need.

    Of course there's simplifications here. (And it's been a while since I did this formally - hopefully I didn't make any big mistakes.) Also real capacitors will not act the same as an ideal one, and tolerances on capacitors are HUGE. Of course the real voltage drop is an exponential, and the current draw will also have part that changes with voltage, but not the same as a resistor, so it would take a bunch of math to calculate exactly.

    However, if you can get a ballpark answer and then double it or so, for tolerances, you'll probably be good enough. Heck, for a hobby level project maybe simply going 10x for a few pennies more would be a good idea.


  • Plugin Developer

    I think capacitors with a blocking diode would be the right call..

    Cool!

    That calculation clears up so much. Really great explanation, thank you!

    It seems a diode is needed either way.

    The power supply runs both the Arduino the blaster itself, which means the two motors it uses. One motor spins the barrel (purely as an optical effect), and other one actually shoot out the darts.

    for a hobby level project maybe simply going 10x for a few pennies more would be a good idea

    Glad to hear that (other than cost) there is no problem with using a way too big capacitor. That also simplifies building up a stock 🙂



  • Probably the only problem with a too-big capacitor is how quickly it might want to charge when everything is connected. You might need to build in some kind of rate limiting for that.


  • Plugin Developer

    @ejlane Could a resistor be used for that?



  • Sure, a resistor could, but then it's always burning power. There are current-limiting circuits that use semiconductors, but I'm not sure how efficient they are.

    I'm not sure how pros would do it. There must be good ways to go about it without losing much/any power. Again it comes down to how much power it will burn vs. the practically $0 cost of a resistor vs. other choices.


  • Plugin Developer

    Thanks. I'll look into it.


  • Plugin Developer

    I thought I'd give an update.

    I added four .470 capacitors in paralel, but the gun was still turning itself off. Then I added the diode, and.. it worked! The gun remains stable.

    ...at least.. while it was on a beefy lab power supply. It indicates that when firing the gun uses about .6 amps, and it prefers to be around 8.5 volts (6 AA batteries). 9 volts seems to be too much.

    I tried to switch it to the intended portable design, with a USB PD decoy feeding into a 4A up-down adjustable buck converter.

    But then it crashes again.

    For example, I tried this:

    • 55W steam deck USB-C PD power supply ->
    • adjustable decoy set to 15 or 20 volt.
    • down-converting that to 8.5v with the buck converter.

    Maybe all this power converting means that it can't provide the sudden increases in power when the motor spins up?

    Perhaps using a linear DC-DC converter work better? Or maybe the USB-PD decoy just can't handle it? It's a mystery.


Log in to reply
 

Suggested Topics

15
Online

11.2k
Users

11.1k
Topics

112.5k
Posts