motor drive libary to use speed control, coasting and dynamic braking. NOTE, dynamic braking my result in large currents. this may or may not set the motor driver on fire/break it/other undesired effects. so read the data sheet folks.
Fork of Motordriver by
Diff: motordriver.cpp
- Revision:
- 6:415f0e127063
- Parent:
- 5:3110b9209d3c
--- a/motordriver.cpp Thu Nov 25 13:34:15 2010 +0000 +++ b/motordriver.cpp Fri Jul 13 19:57:27 2018 +0000 @@ -32,9 +32,8 @@ Motor::Motor(PinName pwm, PinName fwd, PinName rev, int brakeable): _pwm(pwm), _fwd(fwd), _rev(rev) { - // Set initial condition of PWM - _pwm.period(0.001); + _pwm.period(0.00005); // PWM set to 20 kHz _pwm = 0; // Initial condition of output enables @@ -115,7 +114,7 @@ } else if ((_fwd == 0) && (_rev == 1)) { return -(_pwm);//reversing } else if ((_fwd == 1) && (_rev == 0)) { - return _pwm;//fowards + return _pwm;//foRwards } else return -3;//error }