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:
- 3:bb7b6034bb7c
- Parent:
- 2:91bf9f1765ef
- Child:
- 4:5243e66b1fea
--- a/main.cpp Thu Oct 08 13:15:23 2015 +0000 +++ b/main.cpp Thu Oct 08 14:04:55 2015 +0000 @@ -95,10 +95,15 @@ Timer schiettimer; schiettimer.reset(); schiettimer.start(); - while(schiettimer<=schiettijd) { + float pass=0; + while(schiettimer.read()<=schiettijd) { + // errors berekenen en naar de controller passen error1=(desiredangle[0]-counttorad*encoder1.getPulses()); error2=(desiredangle[1]-counttorad*encoder2.getPulses()); mycontroller.PI(error1, error2, Kp, Ki, Ts_control, error1_int, error2_int); + + wait (Ts_control-(schiettimer.read()-Ts_control*pass)); // even wachten anders wordt de while loop te snel doorlopen en gaan de motoren wak + pass++; } schiettimer.stop(); @@ -110,6 +115,7 @@ //////////////////////////////////////////////////MAIN/////////////////////////////////// int main() { + pc.baud(115200); //tickers hidscope_ticker.attach(&scopedata_activate,1.0/hidscope_frequency); control_ticker.attach(&control_activate,1.0/control_frequency);