Bayley Wang
/
priustroller
Prius IPM controller
Fork of analoghalls5_5 by
core/core.h@35:83cf9564bd0c, 2015-03-16 (annotated)
- Committer:
- bwang
- Date:
- Mon Mar 16 15:40:07 2015 +0000
- Revision:
- 35:83cf9564bd0c
- Parent:
- 33:e7b132029bae
Set for 3A Iq, 0A Id, Ki = 1e-3, Kp = Kd = 0, loop still oscillates but is passable
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 | 33:e7b132029bae | 16 | Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, 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: |
nki | 33:e7b132029bae | 23 | CurrentSensor *_sense_c,*_sense_b; |
bwang | 1:1f58bdcf2956 | 24 | PositionSensor *_sense_p; |
bwang | 1:1f58bdcf2956 | 25 | TempSensor *_sense_t; |
bwang | 1:1f58bdcf2956 | 26 | int _num_poles; |
bwang | 1:1f58bdcf2956 | 27 | float _kv; |
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 |