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@0:bac9c3a3a6ca, 2016-03-09 (annotated)
- Committer:
- bwang
- Date:
- Wed Mar 09 06:44:51 2016 +0000
- Revision:
- 0:bac9c3a3a6ca
- Child:
- 5:efd3838b79a6
- Child:
- 8:70122bad5f90
- Child:
- 9:074575151e4b
open loop, working; motor draws ~400mA at 30V; pre-center aligned PWM
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 | 0:bac9c3a3a6ca | 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 | 0:bac9c3a3a6ca | 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 |
