Adding a motor controller

A project log for Colour sorting machine for Lego

Automatically sort random Lego pieces by colour!

robgRobG 02/17/2024 at 16:050 Comments

Using a bench supply to control the current (and therefore speed/vibration frequency) of the vibrating feeder was getting a bit annoying, so I finally took the plunge and added an H-bridge driver and PWM control. Initially I tried an L9110S-based module (very cheap on the 'bay) but it wasn't up to it and kept overheating. Plus it doesn't support 'coasting' so ended up being quite noisy and inefficient.

I swapped it out for an L298N-based module (almost as cheap) which is much better. By driving the ENABLE line with PWM, and holding the IN1/IN2 inputs H/L for fixed direction, it's possible to employ coasting, which keeps the motor happier.

However, the Arduino's built in PWM frequency (977Hz) is very noisy, and changing the prescaler to get other values is no better (3.9kHz is also noisy, 31kHz is too fast for the driver). So ended up with a bit of code to set it at about 15kHz, which is perfect. Pretty much silent (to my deaf ears anyway) but with smooth power control and no overheating.

Plus, the L298N has dual outputs, so I've still got a spare channel I can use to control the drum feeder's motor, when I get to that stage.