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: FastPWM mbed QEI biquadFilter HIDScope MODSERIAL
Diff: main.cpp
- Revision:
- 21:363271dcfe1f
- Parent:
- 20:695140b8db2f
- Child:
- 22:71524e4fd1f2
- Child:
- 24:d255752065d1
- Child:
- 46:7c14fc3caf52
diff -r 695140b8db2f -r 363271dcfe1f main.cpp --- a/main.cpp Mon Oct 22 14:29:37 2018 +0000 +++ b/main.cpp Mon Oct 22 14:50:31 2018 +0000 @@ -7,9 +7,30 @@ #include "BiQuad.h" // Input +AnalogIn pot1(A1); +AnalogIn pot2(A2); +InterruptIn button1(D0); +InterruptIn button2(D1); +InterruptIn emergencybutton(SW2); /* This is not yet implemented! +The button SW2 on the K64F is the emergency button: if you press this, +everything will abort as soon as possible +*/ + +DigitalIn pin8(D8); // Encoder 1 B +DigitalIn pin9(D9); // Encoder 1 A +DigitalIn pin10(D10); // Encoder 2 B +DigitalIn pin11(D11); // Encoder 2 A +DigitalIn pin12(D12); // Encoder 3 B +DigitalIn pin13(D13); // Encoder 3 A // Output - +DigitalOut pin2(D2); // Motor 3 direction +FastPWM pin3(D3); // Motor 3 pwm +DigitalOut pin4(D4); // Motor 2 direction +FastPWM pin5(D5); // Motor 2 pwm +FastPWM pin6(D6); // Motor 1 pwm +DigitalOut pin7(D7); // Motor 1 direction +//float u1 = pot1; // Utilisation of libraries MODSERIAL pc(USBTX, USBRX); @@ -37,7 +58,7 @@ angle2 = ((float)counts2*2.0*pi)/4200.0; angle3 = ((float)counts3*2.0*pi)/4200.0; - pc.printf("Counts1: %i Angle1: %f Counts2: %i Angle2: %f\r\n",counts1,angle1,counts2,angle2); + pc.printf("Counts3: %i Angle3: %f Counts2: %i Angle2: %f\r\n",counts3,angle3,counts2,angle2); } void draaibuttons() @@ -59,6 +80,7 @@ { u3 = 1.0f; } } +} void draai() /* Function for the movement of all motors, using the potmeters for the moving @@ -100,7 +122,20 @@ int main() { pc.baud(115200); + + pin5.period(1.0/10000); + button1.rise(&draaibuttons); + button2.rise(&draaibuttons); + pin3.period_us(50); + motor.attach(draai, 0.001); + + pin5.period_us(50); + motor.attach(draai, 0.001); + + pin6.period_us(50); + motor.attach(draai, 0.001); + while (true) { Encoderinput();