Code for the Poolinator
Dependencies: mbed QEI HIDScope Pulse biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 4:8113394bed1b
- Parent:
- 3:d319bc2b19f1
- Child:
- 5:33133ebe37fd
--- a/main.cpp Mon Oct 14 10:21:10 2019 +0000 +++ b/main.cpp Mon Oct 14 10:41:49 2019 +0000 @@ -1,3 +1,16 @@ +/* + The Poolinator - A pool playing robot for people with DMD + +GROUP 10 +Sjoerd de Jong - s1949950 +Joost Loohuis - s1969633 +Viktor Edlund - s2430878 +Giuseppina Pinky Diatmiko - s1898841 +Daan v.d Veen - s2003171 +*/ + +// THE PINOUT IS SHOWN IN THE 'PINOUT' DOC ON THE DRIVE!! // + #include "mbed.h" #include "HIDScope.h" #include "QEI.h" @@ -6,8 +19,6 @@ #include "FastPWM.h" #include "Servo.h" -// PLEASE USE THE PINOUT AS SHOWN IN THE PINOUT DOC ON THE DRIVE - MODSERIAL pc(USBTX, USBRX); AnalogIn pot(A1); @@ -112,11 +123,37 @@ { pc.baud(115200); pc.printf("\r\nStarting...\r\n\r\n"); + motor1_pwm.period(1.0 / frequency_pwm); // T = 1 / f + motor2_pwm.period(1.0 / frequency_pwm); + motor3_pwm.period(1.0 / frequency_pwm); while (true) { - // stepper_move(1); - // wait_ms(1.5); + /* + SOME EXAPLE CODE + + * MOTOR + setMotor(..., ...) // which motor (1,2,3), and speed (-inf, +inf) + + * PID + double currentPos1 = encoder1.getPulses(); + double targetPos1 = 10000; + double error1 = targetPos1 - currentPos1; + float PID_speed1 = pid(error) * PID_gain; + setMotor(1, PID_speed1); - // myservo = ... (value between 0.0 and 1.0) + * STEPPER + stepper_move(1); // direction (0 or 1) + wait_ms(1.5); // requires some time between steps + + * SERVO + myservo = ... // value between 0.0 and 1.0 + + * SOLENOID + setSolenoid(0); // shooting + wait(1000); + setSolenoid(1); + + */ + } }