Filter werkt eindelijk, echter zijn alle kanalen hetzelfde

Dependencies:   HIDScope MODSERIAL Matrix QEI biquadFilter mbed

Fork of Turning_Motor_V3 by Thom Kuenen

Revision:
0:4591ba678a39
Child:
1:4bf64d003f3a
diff -r 000000000000 -r 4591ba678a39 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 15 13:32:30 2018 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+MODSERIAL pc(USBTX, USBRX);
+DigitalOut DirectionPin1(D4);
+PwmOut PwmPin1(D5);
+DigitalIn Knop1(D2);
+AnalogIn pot1 (A5);
+
+Ticker mycontrollerTicker;
+Ticker printTicker;
+Ticker Velo;
+volatile bool printer;
+const float maxVelocity=8.4; // in rad/s
+volatile float referenceVelocity = 0.5; //dit is de gecentreerde waarde en dus de nulstand
+
+void velocityref_print()
+{
+    printer = true;
+}
+    
+void velocity()
+    {
+            if (pot1.read()>0.5f)
+                {
+                // Clockwise rotation
+                referenceVelocity = (pot1.read()-0.5f) * 2.0f; 
+                }
+            
+            else if (pot1.read() == 0.5f)
+            {
+                referenceVelocity = pot1.read() * 0.0f; 
+            } 
+            
+            else if (pot1.read() < 0.5f)
+                {
+                // Counterclockwise rotation      
+                referenceVelocity = 2.0f * (pot1.read()-0.5f) ;
+                }
+        
+    }
+    
+    void motor()
+    {  
+        float u = referenceVelocity;
+        DirectionPin1 = u < 0.0f;
+        PwmPin1 = fabs(u);
+    }
+
+
+int main()
+{
+    pc.baud(115200);    
+    PwmPin1.period_us(120); //60 microseconds pwm period, 16.7 kHz 
+    mycontrollerTicker.attach(motor, 0.002);//500Hz
+    printTicker.attach(velocityref_print, 0.5);
+    Velo.attach(velocity, 0.002);
+    while(true)
+    {        
+        if (printer)
+        {
+        pc.printf("%f   \n",referenceVelocity);
+        pc.printf("%f   \n",pot1.read());
+        printer = false;
+        }
+    }
+}
+