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:
- 2:486214873b2c
- Parent:
- 1:f2a8a330983b
--- a/main.cpp Wed Mar 16 01:51:38 2016 +0000 +++ b/main.cpp Wed Mar 16 01:53:22 2016 +0000 @@ -6,6 +6,7 @@ float Kd = 0.0; float interval = 0.1; //in seconds float outputPWM = 0.0; +int period = 1000; PID controller(Kp, Ki, Kd, interval); float currentVelocity; @@ -14,9 +15,9 @@ Ticker executeController; void control() { - controller.setProcessValue(currentVelocity); + controller.setProcessValue(currentVelocity); //need to input car's current velocity from encoder outputPWM = controller.compute(); - motorControl.pulsewidth_us(int(1000*outputPWM)); + motorControl.pulsewidth_us(int(period*outputPWM)); } int main() { @@ -26,7 +27,7 @@ controller.setBias(0.0); //no bias for controller to output controller.setMode(1); //AUTO mode - motorControl.period_us(1000); + motorControl.period_us(period); executeController.attach(&control, interval);