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: main.cpp
- Revision:
- 0:f641e7f8973f
- Child:
- 1:f2a8a330983b
diff -r 000000000000 -r f641e7f8973f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 16 01:44:23 2016 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "PID.h" + +float Kp = 30.0; +float Ki = 0.0; +float Kd = 0.0; +float interval = 0.1; //in seconds + +PID controller(Kp, Ki, Kd, interval); +float currentVelocity; +PwmOut co(p26); + +Ticker executeController; + +void control() { + controller.setProcessValue(currentVelocity); + outputPWM = controller.compute(); +} + +int main() { + controller.setInputLimits(0.0, 6.0); //max input speeds in m/s + controller.setOutputLimits(0.0, 1.0); //PWM outputs from 0% to 100% + controller.setSetPoint(3.0); //reference velocity is 3.0 m/s + controller.setBias(0.0); //no bias for controller to output + controller.setMode(1); //AUTO mode + executeController.attach(&control, interval); + +}