sampleProgram

Dependencies:   QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo

Fork of 17robo_fuzi by kusano kiyoshige

Revision:
31:285c9898da03
Parent:
10:04f2a82cfd89
Child:
32:f535ace7c529
--- a/encorder.h	Thu Aug 24 18:20:12 2017 +0000
+++ b/encorder.h	Tue Aug 29 02:07:56 2017 +0000
@@ -87,24 +87,24 @@
         origin();
     }
     
-    void cal(float target, float dt) {
+    void cal(float target, float dt){
         radian = (float) count/ppr*2*PI;
-        degree = radian / PI * 180.0;         //
+        degree = radian / PI * 180.0;
         w = (radian - oldtheta) / dt;
         v = 0.05*w/27;
         n = w*30/(PI);
         oldtheta = radian;
         //pid_cal(target, n/Nmax, dt);
-        deg_cylinder_cal();                 //
-        position_cal(target, deg_cylinder, dt);
+        //deg_cylinder = (count / 1200) * 360 * 3 / 20;
+        position_cal(target, (float)count, dt);
+    }
+
+    float deg(){
+        return degree;
     }
     
-    void deg_cylinder_cal(){
-        deg_cylinder = (count / 1200) * 360 * 3 / 20;
-    }
-    
-    float deg(){
-        return degree;
+    float get_deg_cylinder(){
+        return deg_cylinder;
     }
     
     float rad() {