Arduino w/ PWM expander and DC motor issue - Page 1
Forum section: electronics / general

author: pidgin
author_rank: Newbie
timestamp: October 30, 2020, 10:37:27 pm
content: Hi there.I am new here to EEVblog forums. so.. Hi everyone:)I am trying to control several DC 3-5v motor/pump with Arduino, using PCA9685 PWM expander.I have connected one such motor, with a rectifying diode (IN4007), to 5V using a BC337 transistor, 2.2K resistor, the PCA9685 module, Arduino Due and 3.3V and 5V sources (with common ground). as in the below attached diagram.The program on it runs a sweep on 0-100% and back on port 0.Now..IF I do NOT connect the motor, but instead put some random resistor load, everything works fine. I can measure across the load resistor a voltage going up from 0 to 5 and back down. All works 100% fine.HOWEVER..IF instead, I connected the motor where it should be, the program goes crazy as soon as the load across the motor gets to about 2-3 volts (or about 1.5V on the port 0 PWM).The PWM stops updating and the serial console debugging clearly shows that something drags down the Arduino (the console stats updating slowly instead of the regular speed), due to I2C communication issues apparently (which hints that the PWM expander module went crazy). The Arduino can't seem to communicate with it anymore.Disconnecting the motor at this stage doesn't help. Even then, the PWM doesn't update. The voltage on the 0 port remains stuck at the same level.. same for the motor. Things just get stuck.Resetting the Arduino doesn't help.If I disconnect the PWM module, the console logging goes back to regular speed (again, hinting that the PWM module went "crazy" and it is what is causing the console log drag).Also, plugging the PWM module back in, doesn't solve the issue right away all the time, even at the beginning. It sometimes needs to "rest" for a bit. Then, once plugged in again it resumes working again like before.. meaning, only for the first second or so, until it goes crazy again.I have no idea what is going on.At first, I thought it has to do with a voltage created by the engine.. so I've added the rectifying diode. But that didn't help. Same issue.I've also added a diode on the base, thinking maybe for some reason there is a current trying to flow back into the PWM module through the (orange) PWM port. But that also didn't help.I am kind of lost here :/Why would the PWM module go crazy like that?What causes it?How do I fix it?Would greatly appreciate any help.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 01, 2020, 01:25:37 pm
content: Power supply bypassing and layout issues. You are building a motor controller and you are seeing the results of non-engineering it. Power line voltage spikes cause enough disruption to crash the microcontroller.Start by this:1) Solder instead of using solderless breadboard.2) Use a schottky diode instead. 1N4007 is too slow.3) Add a beefy electrolytic capacitor, say 470-1000uF from your parts bin between the Vcc and GND. Not just any place where you have Vcc and GND: the physical connection is important: the Vccat the diode cathode, and the GND atthe transistor emitter.4) Make the resulting capacitor-transistor-diode physical loop small, by placing these three components right next to each other.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: November 07, 2020, 06:20:08 pm
content: You have to connect the GND of the 5V power supply to the GND of the 3V3 power supply to create a return path for the base current of the power transistor.