Facking kut filter werkt EINDELIJK !311!!111!!1!!!!!!!!!!!!!!!!!!!

Dependencies:   HIDScope MODSERIAL Matrix QEI biquadFilter mbed

Fork of Turning_Motor_V6 by Brighton de Jong

Files at this revision

API Documentation at this revision

Comitter:
JurrienBos
Date:
Mon Oct 15 13:32:30 2018 +0000
Child:
1:4bf64d003f3a
Commit message:
Motor kan draaien in beide richtingen met aansturing van 1 pot meter. Dit implementeren in het eindscript. Geldt tot nog toe voor 1 motor

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Mon Oct 15 13:32:30 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#da0788f0bd77
--- /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;
+        }
+    }
+}
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 15 13:32:30 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file