tau new

Dependencies:   HIDScope QEI mbed

Fork of Tau by V D

Revision:
1:d2fe9abf5082
Parent:
0:cf88b023a080
Child:
2:9c3713420e24
--- a/main.cpp	Tue Oct 31 13:51:16 2017 +0000
+++ b/main.cpp	Wed Nov 01 09:18:17 2017 +0000
@@ -15,17 +15,17 @@
 //Button
 DigitalIn   button1(SW2);
 
-//PC
-Serial pc(USBTX, USBRX);
-
 // HIDscope
 HIDScope scope(1);
 
 // Encoder
-int counts;
-QEI Encoder(A0,A1,NC,32);
-Ticker tick;
+//Ticker tick;
 float F = 0.02;
+float X = 32;
+float N = 131;
+float pulse_count;
+float angle_motor;
+QEI Encoder(A0,A1,NC,N);
 
 //Minimum wait time between rolls
 float t = 1;
@@ -34,15 +34,14 @@
 void Measure()
 {
     // Get pulses and send to HIDScope
-    counts = Encoder.getPulses();
+    pulse_count = Encoder.getPulses();
     
-    float angle_pc = 1/87;
-    float angle = counts * angle_pc;
+    angle_pp =360/(X * N);
+    
+    angle = pulse_count*angle_pp;
     
     scope.set(0, angle);
     scope.send();
-    
-    pc.printf("Counts:%i. \n Angle:%i. \n",counts,angle);
 }
 
 //Dice rolling function
@@ -59,6 +58,8 @@
     
     ledr = 1; // red led off
     ledb = 0; // blue led on
+    
+    //Encoder.reset();
 }
 
 int main()
@@ -68,8 +69,6 @@
     ledr = 1;
     ledg = 0;
     
-    
-    
     while (true) 
     {
         if(button1==0)