L293D motor driver and SN754410 motor driver
Support for the L293D and SN754410.
These devices have exactly the same pin-outs and so you can swap between them without any hardware/code changes. The only difference is that SN754410 can supply 1A versus 0.6A for the L293D. Both devices can supply double the current for a fraction of a second.
The SN754410 is a more modern device and so tends to be cheaper to buy. "More current and cheaper" = "No brainer"! If you decide to go with the L293D then make sure you buy one with the 'D' at the end as this has the internal diodes fitted meaning that you don't need to add any external components.
There are two different ways to use each motor: 3 pin mode or 2 pin mode. Each has advantages and disadvantages. If you have lots of available IO pins then my recommendation would be to use '3 Pin Mode'.
If you want then you can use a mixture of both 3 pin and 2 pin modes.
3 Pin Mode
This requires one hardware PWM pin plus 2 general purpose digital output pins per motor. The benefit of this mode is that it can support all the possible motor drive states required by WebbotLib ie: forward, reverse, brake and coast. Variable speed is achieved by alternating between 'full speed' and 'coast'.
2 Pin Mode
This requires one hardware PWM pin plus 1 general purpose digital output pin. The drawback of this mode is that it doesn't support the 'coast' motor drive state. Consequently to achieve variable speed settings the motor alternates between 'full speed' and 'brake' via the PWM pin. This places the motor under some stress and will 'wear out' the motor more quickly than the 3 Pin Mode.
- connect - Connect the actuator to the drive system.
- disconnect - Disconnect the actuator from the drive system. Once an actuator is disconnected it will stop responding to other commands until it is connected once again.
- getSpeed - Returns the value you specified in your previous call to setSpeed.
- isConnected - Test if an actuator is connected
- isInverted - Test if an actuator is inverted
- setConnected - Connect or disconnect the actuator from the drive system.
- setSpeed - Set the required speed to a value between DRIVE_SPEED_MIN and DRIVE_SPEED_MAX.