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: Encoder MODSERIAL mbed
Fork of DEMO by
Diff: main.cpp
- Revision:
- 3:120fbef23c17
- Parent:
- 2:9f343567723c
- Child:
- 4:836d7f9ac0ca
diff -r 9f343567723c -r 120fbef23c17 main.cpp --- a/main.cpp Thu Nov 02 09:43:40 2017 +0000 +++ b/main.cpp Thu Nov 02 10:00:46 2017 +0000 @@ -26,8 +26,8 @@ double pi = 3.14159265359; double SetPx = 38; //Setpoint position x-coordinate from changePosition (EMG dependent) double SetPy = 30; //Setpoint position y-coordinate from changePosition (EMG dependent) -volatile double q1 = 0; //Reference position q1 from calibration (only the first time) -volatile double q2 = (pi/2); //Reference position q2 from calibration (only the first time) +double q1 = 0; //Reference position q1 from calibration (only the first time) +double q2 = (pi/2); //Reference position q2 from calibration (only the first time) const double L1 = 30; //Length arm 1 const double L2 = 38; //Length arm 2 double K = 1; //Spring constant for movement end-joint to setpoint @@ -80,15 +80,19 @@ if (Potmeterwaarde2>0.6) { SetPx++; // hoe veel verder gaat hij? 1 cm? 10 cm? } - if (Potmeterwaarde2<0.4) { + else if (Potmeterwaarde2<0.4) { SetPx--; } + else + {} if (Potmeterwaarde1>0.6) { SetPy++; } - if (Potmeterwaarde1<0.4) { + else if (Potmeterwaarde1<0.4) { SetPy--; } + else + {} //pc.printf("Setpointx = %f, Setpointy = %f \r\n", SetPx, SetPy); }