mag niet van hendrik D:

Dependencies:   mbed MatrixMath QEI HIDScope Matrix biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
Hendrikvg
Date:
Fri Sep 20 12:52:00 2019 +0000
Parent:
12:6aabdca32aee
Commit message:
L3: Assignment 3

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 20 09:43:53 2019 +0000
+++ b/main.cpp	Fri Sep 20 12:52:00 2019 +0000
@@ -1,64 +1,37 @@
+#include "QEI.h"
 #include "mbed.h"
 #include "HIDScope.h"
+#include "MODSERIAL.h"
 
 Serial pc(USBTX,USBRX);
-HIDScope scope(4);
-Ticker AInTicker;
-InterruptIn BUT1(D1);
-PwmOut lichtje(D3);
-AnalogIn   ain(A0);
-AnalogIn   bin(A1);
+HIDScope scope(2);
+QEI encoder(D12,D13,NC,64,QEI::X4_ENCODING);
+Ticker RW_scope;
+DigitalOut direction_m1(D4);
+DigitalOut speed_m1(D5);
 
-float getal;
-int n=5;
-
+int degrees;
 volatile float x;
-volatile float x_prev=0; 
+volatile float x_prev=0;
 volatile float y;
-volatile float xb;
-volatile float xb_prev=0; 
-volatile float yb;
 
-void ReadAnalogInAndFilter()
+void ReadEncoderAndWriteScope()
 {
-    x = ain;   // Capture data
-    scope.set(0, x);   // store data in first element of scope memory
-    y = (x_prev+ x)/2.0;   // averaging
-    scope.set(1, y);// store data in second element of scope memory filter
-    x_prev= x; // Prepare for next round
-
-    xb = bin;   // Capture data
-    scope.set(2, xb);   // store data in first element of scope memory
-    yb= (xb_prev+ xb)/2.0;   // averaging
-    scope.set(3, yb);// store data in second element of scope memory filter
-    xb_prev= xb; // Prepare for next round
-
-    scope.send(); // send what's in scope memory to PC
-}
-
-void plus()
-{
-    n++; // n=n+1
-    if (n>10) {
-        n=10;
-    }
-}
-
-void min()
-{
-    n--;
-    if (n<0) {
-        n=0;
-    }
+    degrees = 5.625*encoder.getPulses();
+    x = degrees;
+    scope.set(0,x);
+    y = (x_prev + x)/2.0;
+    scope.set(1,y);
+    x_prev=x;
+    scope.send();
 }
 
 int main() {
     pc.baud(115200);
-    lichtje=1;
-    pc.printf("Maak me dood svp\n\r");
-    AInTicker.attach(&ReadAnalogInAndFilter, 0.01);
+    pc.printf("Hello World!\n\r");
+    RW_scope.attach(&ReadEncoderAndWriteScope, 0.1);    
     while(true)
-            {
-       
+    {
+        
     }
 }
\ No newline at end of file