Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
core/core.h@29:cb03760ba9ea, 2015-03-14 (annotated)
- Committer:
- nki
- Date:
- Sat Mar 14 23:42:46 2015 +0000
- Revision:
- 29:cb03760ba9ea
- Parent:
- 11:dccbaa9274c5
- Child:
- 30:2b6d426f3bfc
Cautionary commit, possibly works
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: |
nki | 29:cb03760ba9ea | 16 | Motor(PositionSensor *sense_p, TempSensor *sense_t); |
bwang | 1:1f58bdcf2956 | 17 | void Config(int num_poles, float kv); |
bwang | 11:dccbaa9274c5 | 18 | float GetCurrentC(); |
bwang | 11:dccbaa9274c5 | 19 | float GetCurrentB(); |
bwang | 11:dccbaa9274c5 | 20 | float GetPosition(); |
bwang | 11:dccbaa9274c5 | 21 | float GetTemp(); |
bwang | 1:1f58bdcf2956 | 22 | private: |
bwang | 1:1f58bdcf2956 | 23 | PositionSensor *_sense_p; |
bwang | 1:1f58bdcf2956 | 24 | TempSensor *_sense_t; |
bwang | 1:1f58bdcf2956 | 25 | int _num_poles; |
bwang | 1:1f58bdcf2956 | 26 | float _kv; |
nki | 29:cb03760ba9ea | 27 | float _ib, _ic; |
bwang | 1:1f58bdcf2956 | 28 | }; |
bwang | 1:1f58bdcf2956 | 29 | |
bwang | 1:1f58bdcf2956 | 30 | class Inverter { |
bwang | 1:1f58bdcf2956 | 31 | public: |
bwang | 1:1f58bdcf2956 | 32 | Inverter(PinName ph_a, PinName ph_b, PinName ph_c, PinName en, VoltageSensor *sense_bus, TempSensor *sense_t); |
bwang | 1:1f58bdcf2956 | 33 | void SetDtcA(float dtc); |
bwang | 1:1f58bdcf2956 | 34 | void SetDtcB(float dtc); |
bwang | 1:1f58bdcf2956 | 35 | void SetDtcC(float dtc); |
bwang | 1:1f58bdcf2956 | 36 | void Disable(); |
bwang | 1:1f58bdcf2956 | 37 | void Enable(); |
bwang | 11:dccbaa9274c5 | 38 | float GetVbus(); |
bwang | 11:dccbaa9274c5 | 39 | float GetTemp(); |
bwang | 1:1f58bdcf2956 | 40 | private: |
bwang | 1:1f58bdcf2956 | 41 | PwmOut *_pwm_a, *_pwm_b, *_pwm_c; |
bwang | 1:1f58bdcf2956 | 42 | DigitalOut *_en; |
bwang | 1:1f58bdcf2956 | 43 | VoltageSensor *_sense_bus; |
bwang | 1:1f58bdcf2956 | 44 | TempSensor *_sense_t; |
bwang | 1:1f58bdcf2956 | 45 | }; |
bwang | 1:1f58bdcf2956 | 46 | |
bwang | 1:1f58bdcf2956 | 47 | class User { |
bwang | 1:1f58bdcf2956 | 48 | public: |
bwang | 1:1f58bdcf2956 | 49 | User(Throttle *throttle) {_throttle = throttle;} |
bwang | 1:1f58bdcf2956 | 50 | void UpdateThrottle() {throttle = _throttle->GetThrottle();} |
bwang | 1:1f58bdcf2956 | 51 | public: |
bwang | 1:1f58bdcf2956 | 52 | float throttle; |
bwang | 1:1f58bdcf2956 | 53 | private: |
bwang | 1:1f58bdcf2956 | 54 | Throttle *_throttle; |
bwang | 1:1f58bdcf2956 | 55 | }; |
bwang | 1:1f58bdcf2956 | 56 | |
bwang | 1:1f58bdcf2956 | 57 | #endif |