Coding

Updating Motor Controller code

We created a python class to drive the L298N Motor Driver’s used in a previous robot. Each of the L298N’s could drive 2 channels, but how it did the driving is different to the new MDD10A’s. This task was to modify that class for the new boards.

The existing motor driver had a pin for forwards and another for backwards. This was duplicated for the two channels.

Driving the motor forwards was setting the forwards pin to high. To change the speed of the backwards or forwards motion the relevant pin had PWM applied to it.

The new boards behave differently. The have a single pin for backward and forward depending on whether it is 1 or 0. There is a second pin that has a PWM input to control the speed of the movement.

The instructions provide a truth table showing how this works.

Please follow and like us: