biorobotics 2 motoren werkend, button verandert de richting en potmeter verandert de snelheid #shoutout naar jankoekenpan
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL Encoder FastPWM
Revision 7:be97dcdc1b8c, committed 2019-10-07
- Comitter:
- S1933191
- Date:
- Mon Oct 07 12:54:29 2019 +0000
- Parent:
- 6:fdf0974a33fc
- Commit message:
- "schone versie", Motor1: button1 en potmeter1(direction snelheid), Motor2: button2 en potmeter2(direction snelheid)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r fdf0974a33fc -r be97dcdc1b8c main.cpp --- a/main.cpp Mon Oct 07 12:48:02 2019 +0000 +++ b/main.cpp Mon Oct 07 12:54:29 2019 +0000 @@ -1,20 +1,21 @@ #include "mbed.h" #include "math.h" //#include "HIDScope.h" - +// ---- Alles met een 1(of geen getal) gaat over motor 1---- +// ---- Alles met een 2 gaat over motor 2---- // ------ Hardware Interfaces ------- -const PinName motor1dir = D7; -const PinName motor1PWM = D6; -const PinName motor2PWM = D5; -const PinName motor2dir = D4; +const PinName motor1dir = D7; //direction1 (cw,ccw) +const PinName motor1PWM = D6; //speed1 +const PinName motor2PWM = D5; //speed2 +const PinName motor2dir = D4; //direction2 (cw,ccw) DigitalOut motor1direction(motor1dir); PwmOut motor1control(motor1PWM); PwmOut motor2control(motor2PWM); DigitalOut motor2direction(motor2dir); -const PinName button1name = D10; //for some reason D8 does not seem to work. wtf! +const PinName button1name = D10; const PinName pot1name = A0; const PinName button2name = D11; const PinName pot2name = A1; @@ -89,11 +90,6 @@ float motorValue1 = feedForwardControl(referenceVelocity); setMotor1(motorValue1); - -//void measureAndControl2(void) { - // This function measures the potmeter position, extracts a - // reference velocity from it, and controls the motor with - // a simple FeedForward controller. Call this from a Ticker. float referenceVelocity2 = getReferenceVelocity2(); float motorValue2 = feedForwardControl2(referenceVelocity2); setMotor2(motorValue2);