C++ class for controlling DC motor with encoder feedback. Dependencies include LS7366LIB, MotCon, and PID.
Dependencies: LS7366LIB MotCon2 PID
Diff: Axis.h
- Revision:
- 8:7e399d7c990d
- Parent:
- 7:d0458137d6e0
- Child:
- 9:7bc59203ce98
--- a/Axis.h Thu May 19 12:41:53 2016 +0000 +++ b/Axis.h Mon Jul 11 18:26:26 2016 +0000 @@ -10,7 +10,7 @@ class Axis{ public: - Axis(SPI& _spi, PinName _cs, PinName _pwm, PinName _dir, PinName _analog, int* limit, float totalCnts); + Axis(SPI& _spi, PinName _cs, PinName _pwm, PinName _dir, PinName _analog, int* limit); void paramUpdate(void); void center(void); void init(void); @@ -20,6 +20,7 @@ void axisOff(void); void axisOn(void); void zero(void); + void writeEncoderValue(long value); long enc; //used to return the data from the LS7366 encoder chip float co; // = 0.0; @@ -30,6 +31,7 @@ float set_point;// = 0.0; float set_point_last; float pos, vel, acc; //calculated position, velocity, and acceleration + int stat; //overall axis status 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; @@ -40,12 +42,14 @@ int moveState; int debug; int *ptr_limit; - float totalCounts; float motCurrent; //motor current read from readCurrent() function float mot_I_lim; //max current limit int axisState; int motInvert; char dataFormat; //'r'=radians (default), 'd'=degrees, 'e'=encoder counts + float pos_rad, vel_rad; //current position measurement in radians + float pos_deg, vel_deg; //current position measurement in degrees + float ctsPerDeg; Ticker update; Ticker moveProfile;