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
Revision 6:415f0e127063, committed 2018-07-13
- Comitter:
- apriljunio
- Date:
- Fri Jul 13 19:57:27 2018 +0000
- Parent:
- 5:3110b9209d3c
- Commit message:
- Changed PWM period to be 20kHz;
Changed in this revision
motordriver.cpp | Show annotated file Show diff for this revision Revisions of this file |
motordriver.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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 }
--- a/motordriver.h Thu Nov 25 13:34:15 2010 +0000 +++ b/motordriver.h Fri Jul 13 19:57:27 2018 +0000 @@ -79,13 +79,11 @@ PwmOut _pwm; DigitalOut _fwd; DigitalOut _rev; - int Brakeable; // cna the motor driver break + int Brakeable; // can the motor driver break int sign; //prevents throwing the motor from full foward to full reverse and stuff melting. }; - - #endif