Ramon Waninge / Mbed 2 deprecated Milestone1

Dependencies:   FastPWM mbed QEI biquadFilter HIDScope MODSERIAL

Revision:
18:ca084c362855
Parent:
17:0ae9e8c958f8
Child:
20:695140b8db2f
Child:
45:53c4fca47ed4
diff -r 0ae9e8c958f8 -r ca084c362855 main.cpp
--- a/main.cpp	Fri Oct 19 12:43:58 2018 +0000
+++ b/main.cpp	Mon Oct 22 14:00:42 2018 +0000
@@ -12,22 +12,39 @@
 
 // Utilisation of libraries
 MODSERIAL   pc(USBTX, USBRX);
-QEI         Encoder1(D10,D11,NC,4200);      // Counterclockwise motor rotation is the positive direction
-QEI         Encoder2(D8,D9,NC,4200);        // Counterclockwise motor rotation is the positive direction
+QEI         Encoder1(D11,D10,NC,4200);      // Counterclockwise motor rotation is the positive direction
+QEI         Encoder2(D9,D8,NC,4200);        // Counterclockwise motor rotation is the positive direction
+QEI         Encoder3(D13,D12,NC,4200);      // Counterclockwise motor rotation is the positive direction
 
 // Global variables
+const float    pi = 3.14159265358979;
+
 
 // Functions
+void Encoderinput()
+{   int counts1;
+    int counts2;
+    int counts3;
+    float  angle1;
+    float  angle2;
+    float  angle3;
+    counts1 = Encoder1.getPulses();
+    counts2 = Encoder2.getPulses();
+    counts3 = Encoder3.getPulses();
+    angle1 = ((float)counts1*2.0*pi)/4200.0;
+    angle2 = ((float)counts2*2.0*pi)/4200.0;
+    angle3 = ((float)counts3*2.0*pi)/4200.0;
+         
+    pc.printf("Counts1: %i  Angle1: %f      Counts2: %i  Angle2: %f\r\n",counts1,angle1,counts2,angle2);
+}
 
 // Main program
 int main()
-{
+{   
     pc.baud(115200);
+    
             
     while   (true)
-    {     
-        int counts1 = Encoder1.getPulses();
-        int counts2 = Encoder2.getPulses(); 
-        pc.printf("Counts1: %i      Counts2: %i\r\n",counts1,counts2); 
+    {   Encoderinput();
     }
 }
\ No newline at end of file