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: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of PID_controller_Motor by
Diff: main.cpp
- Revision:
- 3:581c5918b590
- Parent:
- 2:6bef5397e8a9
- Child:
- 4:6524b198721f
diff -r 6bef5397e8a9 -r 581c5918b590 main.cpp
--- 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){
