Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CANnucleo FastPWM3 mbed
Fork of Hobbyking_Cheetah_Compact by
Diff: PositionSensor/PositionSensor.h
- Revision:
- 23:db1263aae417
diff -r c8a1f2071bb0 -r db1263aae417 PositionSensor/PositionSensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PositionSensor/PositionSensor.h Thu Nov 02 22:28:25 2017 +0000 @@ -0,0 +1,65 @@ +#ifndef POSITIONSENSOR_H +#define POSITIONSENSOR_H +class PositionSensor { +public: + virtual float GetMechPosition() {return 0.0f;} + virtual float GetElecPosition() {return 0.0f;} + virtual float GetMechVelocity() {return 0.0f;} + virtual float GetElecVelocity() {return 0.0f;} +}; + + +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(); +private: + InterruptIn *ZPulse; + DigitalIn *ZSense; + //DigitalOut *ZTest; + virtual void ZeroEncoderCount(void); + virtual void ZeroEncoderCountDown(void); + int _CPR, flag, rotations, _ppairs; + //int state; + float _offset, MechPosition, MechOffset, dir, test_pos, oldVel, out_old, velVec[16]; +}; + +class PositionSensorMA700: public PositionSensor{ +public: + PositionSensorMA700(int CPR, float offset, int ppairs); + virtual void Sample(); + 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; +}; + +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(); +private: + 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; + +}; + +#endif \ No newline at end of file