-
Notifications
You must be signed in to change notification settings - Fork 5
Usage
Giuseppe Masino edited this page Jul 18, 2017
·
1 revision
The library is designed to be used in different hardware configurations:
This configuration in intended for use with a standalone L293 IC and breakout boards that expose the ENABLE pin and the two INPUTS, using 3 wires for each motor to control ( excluding the power supply ). The circuit must be like this:
This configuration is intended for use with a circuit like this:
Where only two wires are used to control the motor: the PWM signal and the direction signal ( excluding the power supply )
The library offers differentiated functions for different hardware configurations, but there are some common structures and behaviors
- Moving the motor
Method | Description |
---|---|
motor.forward( speed ); | makes the motor to go forward, **speed** can be a value beetween 0 and 255 |
motor.forward(); | makes the motor to go forward without modifing the speed |
motor.back( speed ); | makes the motor to go reverse, **speed** can be a value beetween 0 and 255 |
motor.back(); | makes the motor to go reverse without modifing the speed |
motor.stop(); | stops the motor |
motor.setPWMOffset( speedOffset ); | sets the offset value applied to the pwm signal value, **speedOffset** can be a value beetween -255 and 255 |
motor.getRawPWMDC(); | returns the current speed value whitout appling the speed offset |
motor.getPWMDC(); | returns the real current speed value |
motor.isForward(); | returns **true** if the motor is turning forward |
motor.isReverse(); | returns **true** if the motor is turning reverse |
motor.isStopped(); | returns **true** if the motor is stopped |
- Creating an istance
L293 motor(pwmPin, forwardPin, backPin);
L293 motor(pwmPin, forwardPin, backPin, speedOffset);
Parameter | Description |
---|---|
motor | the name of the object |
pwmPin | the pin that generate the pwm signal used to control the motor speed |
forwardPin | the digital pin used to tell the motor to go forward |
backpin | the digital pin used to tell the motor to go reverse |
speedOffset | the offset value applied to the pwm signal value, used to reduce the power given to a motor (can be a value beetween -255 and 255) (e.g. in a robot two motors must rotate at the same speed, but one is more powerful than other) |
- Moving the motor
Method | Description |
---|---|
motor.forceStop( handlingTime ); | stops the motor electrically braking it, handlingTime is the time in milliseconds during which the motor is braked, the recommended value is 100 |
motor.isForceStopped(); | returns **true** if the motor is electrically braked |
- Creating an istance
L293_twoWire motor(pwmPin, directionPin);
L293_twoWire motor(pwmPin, directionPin, speedOffset);
Method | Description |
---|---|
motor | the name of the object |
pwmPin | the pin that generate the pwm signal used to control the motor speed |
directionPin | the digital pin used to manage the motor direction |
speedOffset | the offset value applied to the pwm signal value, used to reduce the power given to a motor (can be a value beetween -255 and 255) (e.g. in a robot two motors must rotate at the same speed, but one is more powerful than other) |