1
\$\begingroup\$

I'm actually developing a way to control, digitally, the speed of brushed motors with a Raspberry Pi.

To do so, I use the following diagram where:

The raspberry controls the shift registers (purple) for which:

  • pin 0 & 1 control the motor direction
  • pin 2 to 7 control the motor speed (0 to 63) through a R/2R DAC (+2 potentiometers of adjust the output to the triangular wave)

The comparator (blue) receives:

  • on one side the R/2R network output
  • On the other, a "triangular waveform" (green)

The triangular waveform (green) is produced by the RC filter which receives a square wave from the Raspberry Pi. The comparator resulting PWM is sent to the "enable" pin of the L298N H bridge and the outputs are at right with the needed diodes.

As the L298N has 2H bridges, I want to use it to control 2 motors.

My setup works very fine on one side, but absolutely not on the other.

Schematic

Here are some oscilloscope traces:

On the working side, the triangular wave and the R/2R output. Working side signals

On the not working side, same signals with the same values but all messed up with some sort of parasites. Not working side signals

Note : It shows 10V/ square when in fact it's 1V. Both these traces have been taken at the same moment.

If I make the "working side" motor run alone, it works fine, but as soon as I start the other one, everything is parasited... And if I try to run the "not working side" motor alone, it struggle to turn whatever speed I want. I obviously exchanged the data inputs and the motors, but it really seems to come from the electronics I really don't get it...

Here is the PCB layout: PCB layout

And the actual PCB top side: real PCB top

Edit : The traces of the 5V VCC power supply taken on the comparator +5V (most accessible pin ;) )

enter image description here

Edit :Ground layers of the actually missworking PCB and the one I intend to use (for Winny): Ground layers of old and new PCB

Thanks by advance for your help :)

PCB Update after "John Birckhead" comment/answer : (The bottom layer is highlited)

I re-did everything by hand and I'd like confirmation before making it as it is a long process with my small tools :)

I added the 5V and 9V capacitors as displayed. The 5V one should fit between the heat-sink fins ;)

  • In white, the GND routes, separated between "power" (left) and "signal" (right), but both linked by the connector in the middle.
  • I tired to do the same thing for the +5V
  • I'll add a GND plane on the bottom face, I did not display it for readability reasons

enter image description here

Update following all the advices

Following @winny and @JohnBirckhead advice plus my few requirements, I've come to this :

  1. No soldering pads on top side for components hiding them with their body to be able to solder them (variable resistors or connectors)
  2. Ground plane on the bottom part only on the "command side"
  3. As few as possible tracks cutting the ground plane
  4. Tracks as short as possible.
  5. 10µF SMD capacitors on every IC and the L298N 5V
  6. 100µF SMD capacitor on the 9V close to the L298N

enter image description here

After confirmation of the viability of this PCB, I'll produce it.

Hoping this don't hurt the experts eyes ;)

\$\endgroup\$
17
  • 2
    \$\begingroup\$ Probably due to lack of ground plane and decoupling capacitors. Probe Vcc under load and post oscillogram. \$\endgroup\$
    – winny
    Commented Jun 17, 2022 at 19:10
  • \$\begingroup\$ @winny I have a ground plane on the other side ;) (btw, the ground tracks are separated from the ground plane, but the pads are linked to it, which is strange to me). I'll add the VCC oscillogramme in a few minutes \$\endgroup\$
    – zepeu
    Commented Jun 17, 2022 at 19:14
  • 2
    \$\begingroup\$ I dont see any capacitors at the supply inputs of the L298N chip. This is a big problem, block the 9 V line with 100 µF and the 5 V line with 10 µF using pin 8 as GND for all. \$\endgroup\$
    – Jens
    Commented Jun 17, 2022 at 19:21
  • \$\begingroup\$ @winny I added the traces. \$\endgroup\$
    – zepeu
    Commented Jun 17, 2022 at 19:31
  • \$\begingroup\$ As @Jens said, there is no filtering on the 9V and 5V on the L298N, I'll try to solder some capacitors there for testing purpose and if it solves it, I'll be good to make a new PCB for the 4th time :) \$\endgroup\$
    – zepeu
    Commented Jun 17, 2022 at 19:31

1 Answer 1

3
\$\begingroup\$

This is a really nice effort, and your schematic will work with a couple of tweaks to your layout. The only issue are your design's current paths.

Take a look at your layout below. You have a ground plane but it must make way for the traces. I have chosen one of your ground paths as an example, indicated by the yellow arrows.

enter image description here

You can see that the ground for your R-2R network and comparator has to share the same path as that required by the motor power. When the motor switches on or off, the instantaneous current, coupled with the resistance and inductance of your traces, means that the instantaneous voltage on the ground can differ at different places along the path. Since the power ground is also your reference, your comparator input signal is not clean and you get the results you have shown.

So you were on the right track when you made the comment about the ground pads being attached to the ground plane. You never want your low-power grounds to carry high currents. To solve your problem, lay out the board to route the return path with a heavy trace directly to a single point - the ground pins of the LM192. All of the diode grounds should have a separate path from this point, not shared with any of the other circuitry. if you use a ground plane, do not attach any of these pads to the plane. A separate ground trace should go to everything else in the circuit. It wouldn't hurt to sprinkle in some decoupling capacitors - it's not the best practice to use a power rail as a reference voltage, so if you do, decouple the heck out of it.

You might experiment with cutting the offending traces and adding jumper wires from your power line to confirm this diagnosis. Good luck!

\$\endgroup\$
7
  • \$\begingroup\$ Thanks for this explanation. I have a ground plane covering the whole bottom surface, I did not show it for readability purpose. If I understand right, I should separate the "high" (9V) power ground from the "low" power ground? But they will meet on the GND pin... So, one on one side, the other on the other side and a clear separation between (except GND pin), or should I put a capacitor in series to split them? \$\endgroup\$
    – zepeu
    Commented Jun 18, 2022 at 9:16
  • \$\begingroup\$ I updated the PCB and edited the question, could you give it a small look? :) \$\endgroup\$
    – zepeu
    Commented Jun 18, 2022 at 13:30
  • \$\begingroup\$ Btw, the side where you draw your arrows is the side that worked... It's the other side that was not working properly :( \$\endgroup\$
    – zepeu
    Commented Jun 18, 2022 at 19:10
  • 1
    \$\begingroup\$ Definitely an improvement. I might suggest that if you can make a split or partial plane, that you do not extend your ground plane to the left half of the board. You might also add a large value (electrolytic?) capacitor between the +5 and ground and a ferrite bead in series, and place a larger 0.1 decoupling cap at each of the 5-V IC's. This will help because no matter what you do to your board you still have the problem of the drop in the return line from your power supply. To improve the design, put in a regulator and derive the 5V from the 9V, which will solve the power supply problem. \$\endgroup\$ Commented Jun 20, 2022 at 12:45
  • 1
    \$\begingroup\$ I would do the latter - there is no need for a ground plane for the motors. Your L298 would be the dividing line. \$\endgroup\$ Commented Jun 21, 2022 at 20:31

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.