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.
Dependencies: EMG1 PIDController1 compute mbed InBetweenController PinDetect QEI
Diff: main.cpp
- Revision:
- 3:0634f55c2021
- Parent:
- 0:5f9d8f2142b6
- Child:
- 4:e021dacffa24
--- a/main.cpp Tue Oct 20 09:05:47 2015 +0000 +++ b/main.cpp Tue Oct 20 09:44:30 2015 +0000 @@ -1,16 +1,35 @@ #include "mbed.h" #include "emg.h" -#include "compute.h" +#include "inbetweencontroller.h" +#include "pidControl.h" + +// Define Objects +Ticker sample_timer; +double lastA; +double lastB; -void tick() -{ - sample(); +void tick() { + // EMG Reader + double output0 = sample(0); + double output1 = sample(1); + double output2 = sample(2); + + // In Between Controller + double nexta, nextb; + newPos(output0, output2, output2, lastA, lastB, nexta, nextb); + + lastA = nexta; + lastB = nextb; + + move(nexta,nextb); } int main() { - while (true) { - tick(); - wait(1); - } + init(); + initialize(); + // Attach a timer to the function 'Sample' which fires every 0.002 seconds. + sample_timer.attach(&tick, 0.002); + + while(1) { } } \ No newline at end of file