Test the set param mode
Diff: PositionSensor/PositionSensor.h
- Revision:
- 22:60276ba87ac6
- Parent:
- 20:bf9ea5125d52
- Child:
- 34:51647c6c500d
diff -r 7d1f0a206668 -r 60276ba87ac6 PositionSensor/PositionSensor.h --- a/PositionSensor/PositionSensor.h Thu Mar 02 15:31:45 2017 +0000 +++ b/PositionSensor/PositionSensor.h Fri Mar 31 18:24:46 2017 +0000 @@ -2,75 +2,64 @@ #define POSITIONSENSOR_H class PositionSensor { public: + virtual void Sample(void) = 0; virtual float GetMechPosition() {return 0.0f;} virtual float GetElecPosition() {return 0.0f;} virtual float GetMechVelocity() {return 0.0f;} virtual float GetElecVelocity() {return 0.0f;} + virtual void ZeroPosition(void) = 0; + virtual int GetRawPosition(void) = 0; + virtual void SetElecOffset(float offset) = 0; + virtual int GetCPR(void) = 0; + virtual void WriteLUT(int new_lut[128]) = 0; }; class PositionSensorEncoder: public PositionSensor { public: PositionSensorEncoder(int CPR, float offset, int ppairs); + virtual void Sample(); virtual float GetMechPosition(); virtual float GetElecPosition(); virtual float GetMechVelocity(); virtual float GetElecVelocity(); + virtual void ZeroPosition(void); + virtual void SetElecOffset(float offset); + virtual int GetRawPosition(void); + virtual int GetCPR(void); + virtual void WriteLUT(int new_lut[128]); private: InterruptIn *ZPulse; DigitalIn *ZSense; //DigitalOut *ZTest; virtual void ZeroEncoderCount(void); virtual void ZeroEncoderCountDown(void); - int _CPR, flag, rotations, _ppairs; + int _CPR, flag, rotations, _ppairs, raw; //int state; - float _offset, MechPosition, dir, test_pos, vel_old, out_old; -}; - -class PositionSensorMA700: public PositionSensor{ -public: - PositionSensorMA700(int CPR, float offset, int ppairs); - virtual float GetMechPosition(); - virtual float GetElecPosition(); - virtual float GetMechVelocity(); - virtual int GetRawPosition(); - virtual void ZeroPosition(); -private: - float _offset, MechPosition, MechOffset; - int _CPR, rotations, old_counts, _ppairs; - SPI *spi; - DigitalOut *cs; + float _offset, MechPosition, MechOffset, dir, test_pos, oldVel, out_old, velVec[16]; + int offset_lut[128]; }; class PositionSensorAM5147: public PositionSensor{ public: PositionSensorAM5147(int CPR, float offset, int ppairs); + virtual void Sample(); virtual float GetMechPosition(); virtual float GetElecPosition(); virtual float GetMechVelocity(); virtual int GetRawPosition(); virtual void ZeroPosition(); + virtual void SetElecOffset(float offset); + virtual int GetCPR(void); + virtual void WriteLUT(int new_lut[128]); private: - float _offset, MechPosition, MechOffset; - int _CPR, rotations, old_counts, _ppairs; + float position, ElecPosition, ElecOffset, MechPosition, MechOffset, modPosition, oldModPosition, oldVel, velVec[16], MechVelocity, ElecVelocity; + int raw, _CPR, rotations, old_counts, _ppairs; SPI *spi; DigitalOut *cs; int readAngleCmd; + int offset_lut[128]; }; -class PositionSensorSineGen: public PositionSensor{ -public: - PositionSensorSineGen(int CPR, float offset, int ppairs); - virtual float GetMechPosition(); - virtual float GetElecPosition(); - virtual float GetMechVelocity(); - virtual int GetRawPosition(); - virtual void ZeroPosition(); -private: - float _offset, MechPosition, MechOffset; - int _CPR, rotations, old_counts, _ppairs; - int readAngleCmd; - -}; #endif \ No newline at end of file