Biorobotics_group_2 / Mbed 2 deprecated Encoder

Dependencies:   HIDScope_motor_ff QEI mbed FastPWM MODSERIAL

Fork of HID_scope_test by Biorobotics_group_2

Revision:
7:e7aa4f10d1fb
Parent:
6:ed11342ab079
Child:
8:fe907b9a0bab
diff -r ed11342ab079 -r e7aa4f10d1fb main.cpp
--- a/main.cpp	Fri Oct 07 12:26:22 2016 +0000
+++ b/main.cpp	Fri Oct 07 12:28:01 2016 +0000
@@ -5,26 +5,33 @@
  
 Serial pc(USBTX,USBRX);
 
+// Variables counter
 int countsCW = 0;
 int countsCCW = 0;
 int net_counts = 0;
+
+// Variables degrees, and speed
 float degrees = 0.0;
-
 volatile float curr_degrees = 0.0;
 volatile float prev_degrees = 0.0;
 volatile float speed = 0.0;          // speed in degrees/s
 volatile const float T_CalculateSpeed = 0.1; // 100 Hz
 
+// Set counts per revolution
 const float counts_per_rev = 4200.0;
+
+// Set encoder
 QEI EncoderCW(D12,D13,NC,32);
 QEI EncoderCCW(D13,D12,NC,32);
 
+// Print the output
 void PrintDegrees(){
     pc.printf("\r\n Nett Pulses %i \r\n", net_counts);
     pc.printf("\r\n Output degrees  %f \r\n", degrees);
     pc.printf("\r\n Speed %f \r\n",speed);
     }
-    
+
+// Calculate the speed
 void CalculateSpeed() {
     curr_degrees = degrees;
     speed = (curr_degrees-prev_degrees)/T_CalculateSpeed;