C++ class for controlling DC motor with encoder feedback. Dependencies include LS7366LIB, MotCon, and PID.

Dependencies:   LS7366LIB MotCon2 PID

Dependents:   LPC1768_6axis_Arm

Revision:
0:cf7192f9f99a
Child:
1:cd249816dba8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Axis.h	Mon Aug 31 17:14:20 2015 +0000
@@ -0,0 +1,59 @@
+
+
+#ifndef MBED_ROBOTARM_H
+#define MBED_ROBOTARM_H
+ 
+#include "mbed.h"
+#include "PID.h"
+#include "LS7366.h"
+#include "MotCon.h"
+
+class Axis{
+public:
+    Axis(SPI& _spi, PinName _cs, PinName _pwm, PinName _dir, PinName _limit);    
+    void paramUpdate(void);
+    void home(long halfcounts);
+    void init(float);
+    void setSetPoint(float);
+    void moveTrapezoid(float position, float time);
+    void moveUpdate(void);
+    
+    long enc;
+    float co;// = 0.0;
+    float Tdelay;// = .01;
+    float Pk;       // 120.0 for scorbot
+    float Ik;       // 55.0 for scorbot
+    float Dk;
+    float set_point;// = 0.0;
+    float set_point_last;
+    float pos, vel, acc;    //calculated position, velocity, and acceleration
+    float pos_last, vel_last, acc_last; //history variables used to calculate motion
+    float pos_cmd, vel_cmd, vel_avg_cmd, acc_cmd;    
+    float vel_max, acc_max;
+    float vel_accum;
+    float moveTime;    
+    float p_higher, p_lower;
+    int moveStatus;
+    int moveState;
+    int debug;
+    
+    float countsPerDeg;        //number of counts/revolution
+
+    Ticker update;
+    Ticker moveProfile;
+    Timer t;
+    PID *pid;
+    LS7366 *ls7366;
+    MotCon *motcon;
+    
+private:
+    SPI _spi;
+    DigitalOut _cs;
+    PwmOut _pwm;
+    DigitalOut _dir;
+    DigitalIn _limit;    
+};
+
+#endif
+
+