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:
- 10:1637fce7ef1e
- Parent:
- 9:45ae94cf5e23
- Child:
- 11:475b412bbc3c
--- a/main.cpp Tue Nov 19 13:01:34 2019 +0000 +++ b/main.cpp Tue Nov 19 15:09:24 2019 +0000 @@ -76,8 +76,6 @@ //Reset timer and Start timer.reset(); timer.start(); - timer1.reset(); - timer1.start(); //********************************************************************* //FIRST TIME - SYNCHRONISE (YOU SHOULD NOT NEED THIS ONCE IT's RUNNING) //********************************************************************* @@ -124,11 +122,17 @@ dis = timer1.read_us(); float mm = ((TA*3)*20.8)/175.9; - trav = dis/(mm); + trav = dis/mm; float fA = 1.0f/ (TA *(float)3.0E-6); terminal.printf("Average A2 Shaft: %6.2fHz \t Wheel: %6.2f \t trav: %6.2f\n", fA, fA/20.8f, trav); } +void reset() +{ + timer1.reset(); + time(); +} + int main() { @@ -159,7 +163,8 @@ //Wait - give time to start running wait(1.0); - + timer1.reset(); + timer1.start(); //Main polling loop while(1) { @@ -168,31 +173,36 @@ PWMA.write(dutyA); //Set duty cycle y PWMB.write(dutyB); time(); - } + } + reset(); while(trav <= 330) { PWMA.write(dutyA); PWMB.write(0.0f); time(); } + reset(); while(trav <= 1457) { PWMA.write(dutyA); PWMB.write(dutyB); time(); } + reset(); while(trav <= 268) { PWMA.write(dutyA); PWMB.write(0.0f); time(); } + reset(); while(trav <= 750) { PWMA.write(dutyA); PWMB.write(dutyB); time(); } + reset(); while(trav <= 200) { PWMA.write(dutyA);