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-dsp mbed
Fork of motor1aansturing by
Diff: main.cpp
- Revision:
- 25:9ab3123c2b15
- Parent:
- 24:543c8ee9bca1
- Child:
- 26:02170c78ac2f
--- a/main.cpp Fri Oct 10 12:46:22 2014 +0000 +++ b/main.cpp Fri Oct 17 07:09:41 2014 +0000 @@ -41,7 +41,8 @@ Ticker looptimer; looptimer.attach(setlooptimerflag,TSAMP); - while(1) { + while(1) + { float setpoint; float new_pwm; while(!looptimerflag); @@ -52,18 +53,18 @@ toestand = WACHTEN; } - if (EMG(readbiceps, readtriceps) != 0 && toestand = WACHTEN) //door de ifs uit elkaar te halen en && condities toe te voegen kan het minder snel fout gaan! + if (EMG(readbiceps, readtriceps) != 0 && toestand == WACHTEN) //door de ifs uit elkaar te halen en && condities toe te voegen kan het minder snel fout gaan! { toestand = SLAAN; - if ( EMG(readbiceps, readtriceps)=3) + if ( EMG(readbiceps, readtriceps)==3) { setpoint = v3; //experimenteel bepaald, snelheid(?)>>>=pulsewidthmodulation! geclampt tussen -1/1. om bovenste goal te raken } - else if ( EMG(readbiceps, readtriceps)=2) + else if ( EMG(readbiceps, readtriceps)==2) { setpoint = v2; //experimenteel bepaald, snelheid om middelste goal te raken } - else if (EMG(readbiceps, readtriceps)=1) + else if (EMG(readbiceps, readtriceps)==1) { setpoint = v1; //experimenteel bepaald, snelheid om bovenste goal te raken } @@ -90,15 +91,14 @@ else motordir = 1; pwm_motor.write(abs(new_pwm)); - if(motor1.getPosition()>= ANGLEMAX && toestand=SLAAN) + if(motor1.getPosition()>= ANGLEMAX && toestand==SLAAN) { toestand = TERUGKEREN; //setpoint = 0 //misschien -5 oid... (hij moet 0 wel echt berijken) // pc.printf ("Toestand = terugkeren!"); } - } - -} + } // eind while (1) +} //eind int main void clamp(float * in, float min, float max) {