first

Dependents:   17robo_fuzi 17robo_tokyo_kaede

Revision:
0:929eee8e2c2c
Child:
1:0c64de09bd9b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pid_encoder.h	Sun Sep 24 05:24:06 2017 +0000
@@ -0,0 +1,39 @@
+
+#ifndef MBED_PID_ENCORDER_H
+#define MBED_PID_ENCORDER_H
+
+#include "pid.h"
+#include "mbed.h"
+
+#define PI      3.141592654f
+#define Nmax    18000
+#define invalidN    0.1
+
+class Encoder : public PositionPid //: public Speed_pid
+{
+public:
+    Encoder (PinName A_Phase, PinName B_Phase);
+    void setPpr(int Ppr);    
+    void cal(float target, float dt);
+    float deg();    
+    float get_deg_cylinder();
+    float rad();
+    int pulse();
+    float N();
+    void origin();
+    
+private :
+    InterruptIn A;
+    InterruptIn B;
+
+    int ppr;
+    signed int count;
+    float radian,oldtheta;
+    float w,v,n;
+    float degree, deg_cylinder;
+
+    void A_count();
+    void B_count();
+};
+
+#endif
\ No newline at end of file