Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Motor.cpp
- Revision:
- 6:a9ab4e153009
- Parent:
- 3:8f4f4d3a91bc
- Child:
- 7:b76e530f94f0
- Child:
- 10:573cd4808d91
--- a/Motor.cpp Sat Apr 25 02:42:23 2015 +0000 +++ b/Motor.cpp Thu May 21 06:33:47 2015 +0000 @@ -97,12 +97,20 @@ float iLimit, volatile float ki, volatile float kp, - PwmOut *motor) + PwmOut *motor, + DigitalOut *brake) { float delta_spd = target_spd - actual_spd; //if delta_spd large, brake this cycle. + if(delta_spd < -0.35){ + motor->write(0.0); + *brake = 1; + return; + } else{ + *brake = 0; + } (*iState) += delta_spd; if ((*iState)*ki > iLimit) {