Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
core.h@1:1f58bdcf2956, 2015-03-01 (annotated)
- Committer:
- bwang
- Date:
- Sun Mar 01 10:51:28 2015 +0000
- Revision:
- 1:1f58bdcf2956
- Child:
- 6:99ee0ce47fb2
moar
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 1:1f58bdcf2956 | 1 | #ifndef __CORE_H |
bwang | 1:1f58bdcf2956 | 2 | #define __CORE_H |
bwang | 1:1f58bdcf2956 | 3 | |
bwang | 1:1f58bdcf2956 | 4 | #include "includes.h" |
bwang | 1:1f58bdcf2956 | 5 | #include "sensors.h" |
bwang | 1:1f58bdcf2956 | 6 | |
bwang | 1:1f58bdcf2956 | 7 | class Motor; |
bwang | 1:1f58bdcf2956 | 8 | class Inverter; |
bwang | 1:1f58bdcf2956 | 9 | class CurrentSensor; |
bwang | 1:1f58bdcf2956 | 10 | class VoltageSensor; |
bwang | 1:1f58bdcf2956 | 11 | class PositionSensor; |
bwang | 1:1f58bdcf2956 | 12 | class TempSensor; |
bwang | 1:1f58bdcf2956 | 13 | |
bwang | 1:1f58bdcf2956 | 14 | class Motor { |
bwang | 1:1f58bdcf2956 | 15 | public: |
bwang | 1:1f58bdcf2956 | 16 | Motor(CurrentSensor *sense_a, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t); |
bwang | 1:1f58bdcf2956 | 17 | void Config(int num_poles, float kv); |
bwang | 1:1f58bdcf2956 | 18 | float UpdateCurrentA(); |
bwang | 1:1f58bdcf2956 | 19 | float UpdateCurrentB(); |
bwang | 1:1f58bdcf2956 | 20 | float UpdatePosition(); |
bwang | 1:1f58bdcf2956 | 21 | float UpdateTemp(); |
bwang | 1:1f58bdcf2956 | 22 | void UpdateState(); |
bwang | 1:1f58bdcf2956 | 23 | public: |
bwang | 1:1f58bdcf2956 | 24 | float angle, I_a, I_b, temp; |
bwang | 1:1f58bdcf2956 | 25 | private: |
bwang | 1:1f58bdcf2956 | 26 | CurrentSensor *_sense_a,*_sense_b; |
bwang | 1:1f58bdcf2956 | 27 | PositionSensor *_sense_p; |
bwang | 1:1f58bdcf2956 | 28 | TempSensor *_sense_t; |
bwang | 1:1f58bdcf2956 | 29 | int _num_poles; |
bwang | 1:1f58bdcf2956 | 30 | float _kv; |
bwang | 1:1f58bdcf2956 | 31 | }; |
bwang | 1:1f58bdcf2956 | 32 | |
bwang | 1:1f58bdcf2956 | 33 | class Inverter { |
bwang | 1:1f58bdcf2956 | 34 | public: |
bwang | 1:1f58bdcf2956 | 35 | Inverter(PinName ph_a, PinName ph_b, PinName ph_c, PinName en, VoltageSensor *sense_bus, TempSensor *sense_t); |
bwang | 1:1f58bdcf2956 | 36 | void SetDtcA(float dtc); |
bwang | 1:1f58bdcf2956 | 37 | void SetDtcB(float dtc); |
bwang | 1:1f58bdcf2956 | 38 | void SetDtcC(float dtc); |
bwang | 1:1f58bdcf2956 | 39 | void Disable(); |
bwang | 1:1f58bdcf2956 | 40 | void Enable(); |
bwang | 1:1f58bdcf2956 | 41 | float UpdateVbus(); |
bwang | 1:1f58bdcf2956 | 42 | float UpdateTemp(); |
bwang | 1:1f58bdcf2956 | 43 | public: |
bwang | 1:1f58bdcf2956 | 44 | float dtcA, dtcB, dtcC; |
bwang | 1:1f58bdcf2956 | 45 | float v_bus, temp; |
bwang | 1:1f58bdcf2956 | 46 | private: |
bwang | 1:1f58bdcf2956 | 47 | PwmOut *_pwm_a, *_pwm_b, *_pwm_c; |
bwang | 1:1f58bdcf2956 | 48 | DigitalOut *_en; |
bwang | 1:1f58bdcf2956 | 49 | VoltageSensor *_sense_bus; |
bwang | 1:1f58bdcf2956 | 50 | TempSensor *_sense_t; |
bwang | 1:1f58bdcf2956 | 51 | }; |
bwang | 1:1f58bdcf2956 | 52 | |
bwang | 1:1f58bdcf2956 | 53 | class User { |
bwang | 1:1f58bdcf2956 | 54 | public: |
bwang | 1:1f58bdcf2956 | 55 | User(Throttle *throttle) {_throttle = throttle;} |
bwang | 1:1f58bdcf2956 | 56 | void UpdateThrottle() {throttle = _throttle->GetThrottle();} |
bwang | 1:1f58bdcf2956 | 57 | void UpdateState() {UpdateThrottle();} |
bwang | 1:1f58bdcf2956 | 58 | public: |
bwang | 1:1f58bdcf2956 | 59 | float throttle; |
bwang | 1:1f58bdcf2956 | 60 | private: |
bwang | 1:1f58bdcf2956 | 61 | Throttle *_throttle; |
bwang | 1:1f58bdcf2956 | 62 | }; |
bwang | 1:1f58bdcf2956 | 63 | |
bwang | 1:1f58bdcf2956 | 64 | #endif |