DRV8323RS Version
Dependencies: mbed-dev-f303 FastPWM3
PositionSensor/PositionSensor.h@11:c83b18d41e54, 2016-05-22 (annotated)
- Committer:
- benkatz
- Date:
- Sun May 22 00:14:59 2016 +0000
- Revision:
- 11:c83b18d41e54
- Parent:
- 10:370851e6e132
- Child:
- 13:a3fa0a31b114
summer cleaning;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
benkatz | 0:4e1c4df6aabd | 1 | #ifndef POSITIONSENSOR_H |
benkatz | 0:4e1c4df6aabd | 2 | #define POSITIONSENSOR_H |
benkatz | 0:4e1c4df6aabd | 3 | class PositionSensor { |
benkatz | 0:4e1c4df6aabd | 4 | public: |
benkatz | 0:4e1c4df6aabd | 5 | virtual float GetMechPosition() {return 0.0f;} |
benkatz | 0:4e1c4df6aabd | 6 | virtual float GetElecPosition() {return 0.0f;} |
benkatz | 9:d7eb815cb057 | 7 | virtual float GetMechVelocity() {return 0.0f;} |
benkatz | 0:4e1c4df6aabd | 8 | }; |
benkatz | 0:4e1c4df6aabd | 9 | |
benkatz | 0:4e1c4df6aabd | 10 | |
benkatz | 0:4e1c4df6aabd | 11 | class PositionSensorEncoder: public PositionSensor { |
benkatz | 0:4e1c4df6aabd | 12 | public: |
benkatz | 10:370851e6e132 | 13 | PositionSensorEncoder(int CPR, float offset, int ppairs); |
benkatz | 0:4e1c4df6aabd | 14 | virtual float GetMechPosition(); |
benkatz | 0:4e1c4df6aabd | 15 | virtual float GetElecPosition(); |
benkatz | 3:6a0015d88d06 | 16 | virtual float GetMechVelocity(); |
benkatz | 3:6a0015d88d06 | 17 | virtual float GetElecVelocity(); |
benkatz | 0:4e1c4df6aabd | 18 | private: |
benkatz | 0:4e1c4df6aabd | 19 | InterruptIn *ZPulse; |
benkatz | 0:4e1c4df6aabd | 20 | DigitalIn *ZSense; |
benkatz | 1:b8bceb4daed5 | 21 | //DigitalOut *ZTest; |
benkatz | 0:4e1c4df6aabd | 22 | virtual void ZeroEncoderCount(void); |
benkatz | 7:dc5f27756e02 | 23 | virtual void ZeroEncoderCountDown(void); |
benkatz | 10:370851e6e132 | 24 | int _CPR, flag, rotations, _ppairs; |
benkatz | 1:b8bceb4daed5 | 25 | //int state; |
benkatz | 9:d7eb815cb057 | 26 | float _offset, MechPosition, dir, test_pos, vel_old, out_old; |
benkatz | 0:4e1c4df6aabd | 27 | }; |
benkatz | 0:4e1c4df6aabd | 28 | |
benkatz | 8:10ae7bc88d6e | 29 | class PositionSensorSPI: public PositionSensor{ |
benkatz | 8:10ae7bc88d6e | 30 | public: |
benkatz | 10:370851e6e132 | 31 | PositionSensorSPI(int CPR, float offset, int ppairs); |
benkatz | 8:10ae7bc88d6e | 32 | virtual float GetMechPosition(); |
benkatz | 8:10ae7bc88d6e | 33 | virtual float GetElecPosition(); |
benkatz | 9:d7eb815cb057 | 34 | virtual float GetMechVelocity(); |
benkatz | 11:c83b18d41e54 | 35 | virtual int GetRawPosition(); |
benkatz | 9:d7eb815cb057 | 36 | virtual void ZeroPosition(); |
benkatz | 8:10ae7bc88d6e | 37 | private: |
benkatz | 9:d7eb815cb057 | 38 | float _offset, MechPosition, MechOffset; |
benkatz | 10:370851e6e132 | 39 | int _CPR, rotations, old_counts, _ppairs; |
benkatz | 8:10ae7bc88d6e | 40 | SPI *spi; |
benkatz | 8:10ae7bc88d6e | 41 | DigitalOut *cs; |
benkatz | 8:10ae7bc88d6e | 42 | }; |
benkatz | 0:4e1c4df6aabd | 43 | #endif |