
MODSERIAL PID controller edit
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of PID_controller_Motor by
Revision 3:581c5918b590, committed 2016-10-13
- Comitter:
- MBroek
- Date:
- Thu Oct 13 15:05:35 2016 +0000
- Parent:
- 2:6bef5397e8a9
- Child:
- 4:6524b198721f
- Commit message:
- Hidscope toegevoegd om functie mee te gaan testen
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 13 11:28:14 2016 +0000 +++ b/main.cpp Thu Oct 13 15:05:35 2016 +0000 @@ -7,6 +7,10 @@ #include "MODSERIAL.h" #include "QEI.h" #include "math.h" +#include "HIDScope.h" + +// Definieren van de HIDscope ---------------------------------------- +HIDScope scope(1) // Definieren van de Serial en Encoder ------------------------------- @@ -26,8 +30,8 @@ //Definieren van bord-elementen -------------------------------------- -InterruptIn kill_switch(D7); -InterruptIn test_button(D6); +InterruptIn kill_switch(D8); +InterruptIn test_button(D9); AnalogIn pot1(A1); // Dit is de gesimuleerde emg1 AnalogIn pot2(A2); // Dit is de gesimuleerde emg2 @@ -83,10 +87,16 @@ double get_reference_position_m1(double aantal_rad, double aantal_meter){ ref_pos = pot1.read - pot2.read; // De reference position als output (zit tussen -1 en 1, -1 is maximaal links en 1 is maximaal rechts) return ref_pos * aantal_rad; // Aantal rad is hoeveelheid radialen van middelpunt tot minima - return ref_pos * aantal_meter // Aantal meter is de helft van de lengte die het karretje kan bewegen + return ref_pos * aantal_meter; // Aantal meter is de helft van de lengte die het karretje kan bewegen } - + +// HIDScope functie ---------------------------------------------------------------------- +void set_scope(double input){ + scope.set(0, input); + scope.send(); +} + // De PID-controller voor de motors ------------------------------------------------- double PID_controller(double ref_pos, double mot_pos, double &error_prev, double &error_int){