With this program the buttons on the biorobotics shield can be used to move the arms. both buttons pressed means shoot. Also SW3 can be pressed to adjust controller constants via Serial connection
Dependencies: HIDScope QEI controlandadjust mbed
Diff: main.cpp
- Revision:
- 4:5243e66b1fea
- Parent:
- 3:bb7b6034bb7c
- Child:
- 5:be9f9dcbd9b0
--- a/main.cpp Thu Oct 08 14:04:55 2015 +0000 +++ b/main.cpp Wed Oct 14 15:22:49 2015 +0000 @@ -29,7 +29,7 @@ Timeout schieten_timeout; // controller values and errors -controlandadjust mycontroller; +controlandadjust mycontroller;//the value between () is the maximum value of the PWM signal send to the motors const float Kp=0.5; const float Ki=0.01; const float Kd=0.001; @@ -45,8 +45,8 @@ const float cpr=32*131; const float PI=3.1415; const float counttorad=((2*PI)/cpr); -const float radpersecbut=(PI/read_but_frequency); -const float schiethoek=0.5*PI; +const float radpersecbut=((0.1*PI)/read_but_frequency); +const float schiethoek=0.35*PI; const float schiettijd=0.5; //angle for motor @@ -101,7 +101,7 @@ error1=(desiredangle[0]-counttorad*encoder1.getPulses()); error2=(desiredangle[1]-counttorad*encoder2.getPulses()); mycontroller.PI(error1, error2, Kp, Ki, Ts_control, error1_int, error2_int); - + scopedata(); wait (Ts_control-(schiettimer.read()-Ts_control*pass)); // even wachten anders wordt de while loop te snel doorlopen en gaan de motoren wak pass++; } @@ -115,6 +115,7 @@ //////////////////////////////////////////////////MAIN/////////////////////////////////// int main() { + mycontroller.cutoff(0.5); pc.baud(115200); //tickers hidscope_ticker.attach(&scopedata_activate,1.0/hidscope_frequency);