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.
Fork of foc-ed_in_the_bot_compact by
PositionSensor/PositionSensor.h@9:074575151e4b, 2016-05-17 (annotated)
- Committer:
- bwang
- Date:
- Tue May 17 06:44:09 2016 +0000
- Revision:
- 9:074575151e4b
- Parent:
- 0:bac9c3a3a6ca
prepping for altermotter operation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 0:bac9c3a3a6ca | 1 | #ifndef POSITIONSENSOR_H |
bwang | 0:bac9c3a3a6ca | 2 | #define POSITIONSENSOR_H |
bwang | 0:bac9c3a3a6ca | 3 | |
bwang | 0:bac9c3a3a6ca | 4 | class PositionSensor { |
bwang | 0:bac9c3a3a6ca | 5 | public: |
bwang | 0:bac9c3a3a6ca | 6 | virtual float GetMechPosition() {return 0.0f;} |
bwang | 0:bac9c3a3a6ca | 7 | virtual float GetElecPosition() {return 0.0f;} |
bwang | 0:bac9c3a3a6ca | 8 | }; |
bwang | 0:bac9c3a3a6ca | 9 | |
bwang | 0:bac9c3a3a6ca | 10 | |
bwang | 0:bac9c3a3a6ca | 11 | class PositionSensorEncoder: public PositionSensor { |
bwang | 0:bac9c3a3a6ca | 12 | public: |
bwang | 9:074575151e4b | 13 | PositionSensorEncoder(int cpr, float offset); |
bwang | 0:bac9c3a3a6ca | 14 | virtual float GetMechPosition(); |
bwang | 0:bac9c3a3a6ca | 15 | virtual float GetElecPosition(); |
bwang | 0:bac9c3a3a6ca | 16 | private: |
bwang | 0:bac9c3a3a6ca | 17 | InterruptIn *ZPulse; |
bwang | 0:bac9c3a3a6ca | 18 | DigitalIn *ZSense; |
bwang | 0:bac9c3a3a6ca | 19 | DigitalOut *ZTest; |
bwang | 0:bac9c3a3a6ca | 20 | void ZeroEncoderCount(void); |
bwang | 9:074575151e4b | 21 | int _cpr; |
bwang | 0:bac9c3a3a6ca | 22 | int state; |
bwang | 0:bac9c3a3a6ca | 23 | float _offset; |
bwang | 0:bac9c3a3a6ca | 24 | }; |
bwang | 0:bac9c3a3a6ca | 25 | |
bwang | 0:bac9c3a3a6ca | 26 | #endif |