1
\$\begingroup\$

This is my first post here and I'm new to electronics. I am trying to control a motor using an ESP32 Cam. See attached image for a rather crude schematic. The power supply is rated for 2.4A. I am using a 12v DC 5rpm worm gear motor like this DC 12V Worm Gear Motor .

When the motor starts, the ESP32 resets (I figured this out by making the ESP blink on startup). Meanwhile the motor continues spinning without interrupt (I have ESPHome on the ESP32 and treat 2 GPIO pins as interlocking switches [only one can be on at a time]).

From reading online, it seems like the surge on motor startup may be causing a voltage drop on the ESP32 (potentially called "brownout") causing a reset. How can I prevent this in a simple way?

I found that if I put the motor on a different power supply, the issue is fixed, but I'd rather not use two power supplies.

References of similar issues:

Possible solutions

  1. Different PSU for motor. I've tried this and it works, but I'd rather not have to use a second PSU. I think the ESP32 draws ~250mA and the motor ~100mA, so I think I'm well within spec of the 2.4A PSU.
  2. Schottky diode - I don't have one of these and don't want to wait for an order
  3. "Decoupling capacitors". I have a bag of assorted electrolytic capacitors. Which should I use and where do I put them?
  4. PWM - gradually apply pwm to bring motor up to speed. Would this work with my circuit, with pwm before the boost converter? Will the boost converter just boost it to 12v anyways, either just using capacitors or using PWM?

Note

  • The DRV8833 is rated to 10v, which is why I set boost converter to 10v and not 12v. The motor still seems to run fine on 10v.

schematic picture of circuit

Edit

Many thanks to the people who have posted here, @winny, @vir, @bobflux, and @thebusybee. I've implemented the PWM acceleration method, which works. There's a loud high pitched whining sound, at the mid-range PWM values that goes away once the motor comes up to speed. Audio available here: https://streamable.com/3xgxy0

\$\endgroup\$
18
  • \$\begingroup\$ Proper decoupling, a suitable freewheeling diode across the motor, bulk capacitor and good layout? Please show your schematic and layout. 2. Almost any diode will do. 3. No electrolytics, only ceramic or plastic film will do. \$\endgroup\$
    – winny
    Commented Mar 19, 2021 at 18:44
  • \$\begingroup\$ @winny - thanks for the response. I roughly drew my schematic and attached it. Can you see the image? I have a 470uF electrolytic capacitor. Do I just add that after the PSU with capacitor positive leg to +5v and negative leg to ground? \$\endgroup\$
    – maurera
    Commented Mar 19, 2021 at 18:53
  • 1
    \$\begingroup\$ Perhaps, but with the “inrush” current to the motor, your 5 V is probably sagging too low and you would need a diode in series to prevent the motor from robbing all charge from the MCU. 470 uF = bulk capacitance. What do you have straight connected to the MCU Vcc pin? Any 100 nF ceramic? \$\endgroup\$
    – winny
    Commented Mar 19, 2021 at 19:50
  • \$\begingroup\$ I don't have any ceramic capacitors or diodes, but will order an assortment for future projects. Silly question - I have LEDs "light emitting diode". Can I use an LED in place of a diode? The Vcc pin is just connected directly to usb's +5v \$\endgroup\$
    – maurera
    Commented Mar 19, 2021 at 19:54
  • 1
    \$\begingroup\$ Oh, the motor you linked has a stalled current of 1.8A, compare this to the current of 60mA with no load… This is the current it takes at startup, and even more at instant reversal. \$\endgroup\$ Commented Mar 19, 2021 at 20:27

2 Answers 2

0
\$\begingroup\$

These solderless breadboards have pretty high contact resistance, so if you run any serious current through that, voltage will drop.

So you should really be using wires for your high current power supply, and solder them to the boards. For the ESP32 it doesn't matter, but for the motor it does.

Different PSU for motor.

Using boost for a motor is asking for trouble. It would be more logical to have a 10V supply for the high current stuff, and a buck converter to power the Pi from that. Also if your 10V drops a few volts under load, it started from 10V so there's still enough to run the Pi. With 5V, less margin.

I think the ESP32 draws ~250mA and the motor ~100mA

The motor will draw 10x that when starting, and multiply by 2 since you're boosting from 5V. If the boost outputs 10V 1A, it will consume 2A from 5V. Output power comes from input power, and power=VxI, so if you want 2x more Volts on the output, you get 2x more Amps on the input. For a buck, same rule applies, output power comes from input power, but output voltage is the lower one, which means input current is lower than input current.

"Decoupling capacitors". I have a bag of assorted electrolytic capacitors. Which should I use and where do I put them?

There are plenty of small decoupling caps on your board, but you can put a large electrolytic on the power supply.

PWM - gradually apply pwm to bring motor up to speed.

Yes.

Would this work with my circuit, with pwm before the boost converter?

Nope

The boost should be always on, powering the DRV8833 board which controls the motor.

DRV8833 has a PWM input, this is the one you should use to gently start your motor.

\$\endgroup\$
8
  • \$\begingroup\$ Thanks very much for the explanation here. Interesting about the contact resistance being an issue. My hope was to prototype it before soldering, but there's clearly an issue with that. For the electrolytic capacitor, can I just put a 470uF with positive leg to +5v and negative leg to ground, right by the microusb breakout board? (I have a mixed bag of capacitors, with other values too). I'll look now into applying PWM from the ESPHome software \$\endgroup\$
    – maurera
    Commented Mar 19, 2021 at 19:48
  • \$\begingroup\$ @maurera Measure, measure, measure. If you don't have a good oscilloscope, experiment with different capacitors, and use finally some multiple of the smallest value that worked. \$\endgroup\$ Commented Mar 19, 2021 at 20:24
  • \$\begingroup\$ Working now! Just posted edit to the end of my original post. Thanks for the help! \$\endgroup\$
    – maurera
    Commented Mar 20, 2021 at 3:02
  • \$\begingroup\$ If the sound bothers you, change the PWM frequency to something inaudible like 25kHz (check the DRV supports it) \$\endgroup\$
    – bobflux
    Commented Mar 20, 2021 at 8:39
  • \$\begingroup\$ @bobflux, using supersonic PWM frequencies (above 20 kHz or so) to automatically make this motor silent is a technical myth (see electronics.stackexchange.com/a/243336/115257) \$\endgroup\$
    – TonyM
    Commented Mar 20, 2021 at 8:59
0
\$\begingroup\$

I suggest the PWM since you've got a micro running it anyway. You'll still need a capacitor but not a ludicrously-sized one. If you're trying to run it off of a USB converter with a probably 28AWG USB cable your starting surge is going to swamp it if you try to start up at full speed.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks for the answer. I'll need to look at the ESPHome software to see how to apply pwm for a gentle start. Why does wire gauge affect the starting surge? Is there a term for this that I can google? \$\endgroup\$
    – maurera
    Commented Mar 19, 2021 at 19:41
  • \$\begingroup\$ When I implemented a quick and dirty ramped PWM on an Arduino for a linear actuator, I just used nested for-loops that broke up the entire PWM period into on-time and off-time and linearly increased one at the expense of the other. I am sure there's a more elegant way to do it but that's the result you should be shooting for. Wire gauge affects the voltage drop you see when starting the motor since the voltage when it comes into your board is reduced by I*R. With the 2A surge that bobflux estimated, you'll see 2*2A*0.212 ohms (1m, 28AWG wire) which is 0.848V. \$\endgroup\$
    – vir
    Commented Mar 19, 2021 at 19:48
  • \$\begingroup\$ You could check the contact resistance on the solderless breadboard, I'm placing a bet on 0.2 ohms minimum \$\endgroup\$
    – bobflux
    Commented Mar 19, 2021 at 20:21
  • \$\begingroup\$ I just measured on got exactly 0.2 ohms (my multimeter probes are too fat to fit in the breadboard holes, so that's to 2 10cm jumpers in neighbouring holes) \$\endgroup\$
    – maurera
    Commented Mar 19, 2021 at 20:42
  • \$\begingroup\$ Working now! Just posted edit to the end of my original post. Thanks for the help! \$\endgroup\$
    – maurera
    Commented Mar 20, 2021 at 3:02

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.