Tristan Vlogman / Mbed 2 deprecated locomotion_pid_action_refactor_EMG

Dependencies:   FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics

Fork of Minor_test_serial by First Last

Files at this revision

API Documentation at this revision

Comitter:
tvlogman
Date:
Tue Sep 19 15:25:42 2017 +0000
Parent:
8:0067469c3389
Child:
10:e23cbcdde7e3
Commit message:
Screwed it up nicely; Work in progress

Changed in this revision

QEI.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Tue Sep 19 15:25:42 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aberk/code/QEI/#5c2ad81551aa
--- a/main.cpp	Tue Sep 19 14:50:53 2017 +0000
+++ b/main.cpp	Tue Sep 19 15:25:42 2017 +0000
@@ -1,11 +1,12 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
 #include "HIDScope.h"
+#include "QEI.h"
 
 HIDScope scope(2);
 
 Ticker AInTicker;
-AnalogIn aIn1(A0);
+AnalogIn button1(A4);
 
 volatile float x;
 volatile float x_prev =0; 
@@ -14,7 +15,7 @@
 
 void ReadAnalogInAndFilter()
 {
-        x = ledBrightness;   // Capture data
+        x = button1;   // Capture data
         scope.set(0, x);   // store data in first element of scope memory
         y = (x_prev + x)/2.0;   // averaging filter
         scope.set(1, y);  // store data in second element of scope memory
@@ -27,7 +28,7 @@
 float pwmPeriod = 1.0/5000.0;
 
 AnalogIn pot(A5);
-DigitalIn button1(D3);
+
 DigitalIn button2(D6);
 
 
@@ -40,20 +41,15 @@
     pc.baud(115200);
     AInTicker.attach(&ReadAnalogInAndFilter, 0.01);
     ledPwm.period(pwmPeriod);
+    pc.printf("Hello world");
+    int counts;
+
+    QEI Encoder(D12,D13,NC,32);
     
     while (true) {
-        if(!button1){
-            if(ledBrightness >= 0.05){
-                ledBrightness = ledBrightness - 0.05;                
-                }
-            }
-        if(!button2){
-            if(ledBrightness <= 0.95){
-                ledBrightness = ledBrightness + 0.05;
-                }
-            }
-        ledPwm = ledBrightness;
-        wait(0.1f);
+        counts = Encoder.getPulses();
+        pc.printf("Number of pulses is %i", counts);
+        wait(0.5);
         
     }