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:
- 1:f2a8a330983b
- Parent:
- 0:f641e7f8973f
- Child:
- 2:486214873b2c
--- a/main.cpp Wed Mar 16 01:44:23 2016 +0000 +++ b/main.cpp Wed Mar 16 01:51:38 2016 +0000 @@ -5,16 +5,18 @@ float Ki = 0.0; float Kd = 0.0; float interval = 0.1; //in seconds +float outputPWM = 0.0; PID controller(Kp, Ki, Kd, interval); float currentVelocity; -PwmOut co(p26); +PwmOut motorControl(PTD5); Ticker executeController; void control() { controller.setProcessValue(currentVelocity); outputPWM = controller.compute(); + motorControl.pulsewidth_us(int(1000*outputPWM)); } int main() { @@ -23,6 +25,9 @@ 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 + + motorControl.period_us(1000); + executeController.attach(&control, interval); }