1
\$\begingroup\$

I have made a WiFi controlled car using NodeMCU. It works fine if I connect the NodeMCU to a separate 5 V supply.

If I use the same power supply for both the motors and the NodeMCU, it resets automatically sometimes when the load is high and I lost my WiFi connection with the mobile.

I am using an L298 motor driver to drive 4 plastic-geared motors and two 18650 batteries (8 V approx).

Reset happens when I use the built-in 5 V supply from the L298 to power up the NodeMCU. I also tried a separate 7805 regulator for the NodeMCU, but same problem.

I believe this problem happens due to high load on the motors. I don't want to use a separate power supply for the NodeMCU since the space is very small.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
9
  • \$\begingroup\$ Welcome to EE.SE! Please draw a block diagram or even better a schematic. There is a built in schematic editor here if you click on edit and the schematic symbol. It sounds like you are suffering from the very common lack of decoupling and/or bad layout. Please show your layout. Also, please note that there is no voltage load from motors (in any normal sense), only current load, or just load in normal speaking terms. \$\endgroup\$
    – winny
    Commented Jun 5, 2020 at 8:03
  • \$\begingroup\$ Schematic added. \$\endgroup\$ Commented Jun 5, 2020 at 8:56
  • 1
    \$\begingroup\$ Hi! Can you describe when exactly does your MCU reset? Is it all the time, only when the drivers are connected, or only after it enables the motors? Does your MCU also have ceramic (i.e. 100nF) decoupling capacitors besides the big ones shown in the schema? \$\endgroup\$
    – akwky
    Commented Jun 5, 2020 at 9:09
  • 1
    \$\begingroup\$ Please explain how many cells are in your 8 volt battery. \$\endgroup\$
    – Andy aka
    Commented Jun 5, 2020 at 9:37
  • 1
    \$\begingroup\$ Some people who are more familiar with this problem may know better than me, but it strikes me that when the motor starts, it can drain C1 as well as causing the battery to dip. Would a (Schottky) diode between the battery and C1 help? \$\endgroup\$
    – Simon B
    Commented Jun 5, 2020 at 12:26

2 Answers 2

1
\$\begingroup\$

I would say you could use some larger capacitance next to nodemcu. Also, make sure the battery is OK with current spikes you want. Don't forget the more current you draw, the greater the voltage drop on the output due to internal resistance of the battery (battery is always a voltage source + resistor in series, that resistance varies from battery to battery a lot). If your voltage converter doesn't allow you to have large output capacitance, which can be the case, I would probably try to put a beefy diode on buck converter's output in the direction of NodeMCU and then a large capacitor after the diode. If you care about voltage drop, maybe some beefy schottky. Some 1n5817/1n5818/1n5819 from ebay diode sets should do the trick, they have like 0.15V-0.2V voltage drop, which you probably won't care about(?). Try some smaller electrolytic capacitor first (make sure it's correctly polarized). And of course your little decoupling cap must stay there, it plays a different functional role.

\$\endgroup\$
1
\$\begingroup\$

There are several possible causes.

  1. The current loop formed by the batteries and motors is a big electromagnet. Every time motor current rises or falls, that loop's changing magnetic field couples to absolutely every other loop nearby. That includes every signal line in the vicinity, such as the reset line of your MCU. There are some things you must do to minimise this coupling.

    • Concerning the loop formed by the batteries, motors and associated wiring, Keep the physical loop area as small as possible. To that end, keep all conductors as close as possible to each other. Keep this loop as physically distant as possible from other stuff, and certainly keep other stuff physically outside of that loop.

    • Motor wiring, between the L298 and the motors themselves is also critical, for the same reasons. Keep loop area low by twisting the cables together, or at least keeping them running parallel and close together.

    • Ensure that power supply decoupling for the motor section is as close to the point where current switching occurs, that is, the L298. Use a large electrolytic capacitor, and a smaller ceramic capacitor across the power supply to the L298. They will accommodate sudden increases and decreases in current demand, being a power source more local to the L298. This will dampen the rising and falling of current in the wiring between the batteries and L298, and mitigate magnetic coupling to other nearby elements.

  2. Power supply decoupling for other elements in your system is also essential. Use a ceramic capacitor (whose value will depend of the current requirements of the element, but 100nF is typical) across the supply rails for every element in the circuit. Decoupling provides a more local voltage/current source, with two consequences. Firstly the element being decoupled is somewhat protected from the changing current demands of the rest of the system. Secondly that same decoupling protects the rest of the system from whatever crap this particular element spits out onto the supply.

  3. If these two approaches are not sufficient, one more thing to consider is that the 7805 is terrible at preventing fast transients at its input (which may result from motor current switching) from getting through to its output. You may have to filter the input to the 7805, to attenuate transients before they even get to that regulator. Your options include:

    • Better capacitive decoupling at the regulator input. A single ceramic 1μF capacitor physically close to the regulator, between IN and GND could be all you need (in addition to the 470μF one you already have).

    • An inductor between the batteries and regulator input, to suppress fast current transients.

    • A capacitiance multiplier in parallel with the physical 470μF capacitor, both of which should be very close to the regulator, between IN and GND.

  4. (Edit) Don't share long wires from the battery between the MCU side and the motor side. Those wires will carry lots of current, or very little, and the fluctuating voltage drop along them can give the 7805 a hard time. The following look the same, but in the second circuit, the low current stuff has its own supply cabling right up to the battery, relieving the 7805 of a lot of work:

schematic

simulate this circuit – Schematic created using CircuitLab

While this setup better isolates the supplies for the two sections, it introduces another complication, which is that the L298 and MCU may have different ideas of what 0V (ground) is. There can be a lot of current through the blue wire, and a corresponding voltage drop along it, which separates the ground potentials of the two systems.

One way to mitigate this is to use a really beefy ground conductor (and while you're at it, may as well beef up the other motor wire, too), to minimise the voltage it drops while passing all that current:

schematic

simulate this circuit

Really this is all just a communication issue, between the MCU and L298, which you might not even suffer from, and isn't directly related to your MCU "resetting" or "crashing". Just make sure your cables carrying motor current are heavy enough, and routed properly, and be aware that the signaling levels between the MCU and the L298 can get messed up if grounding is poor.

  1. Less likely, but maybe your motors are horribly noisy, electromagnetically, enough to mess with Wifi and a few other things. If you have DC motors with brushes, try connecting a 100nF capacitor from each motor connector to the motor casing, and the motor casing to circuit ground (check that the casing is isolated from both terminals first, to avoid a short circuit). Another check might be to encase all the MCU stuff in a metallic enclosure, connected to circuit ground. Take care with short circuits again. That might upset Wifi to the MCU, but if your MCU stays alive and well, at least you know you have an EMI issue.
\$\endgroup\$

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.