Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
Diff: core.h
- Revision:
- 1:1f58bdcf2956
- Child:
- 6:99ee0ce47fb2
diff -r 54cf32d35f4d -r 1f58bdcf2956 core.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core.h Sun Mar 01 10:51:28 2015 +0000 @@ -0,0 +1,64 @@ +#ifndef __CORE_H +#define __CORE_H + +#include "includes.h" +#include "sensors.h" + +class Motor; +class Inverter; +class CurrentSensor; +class VoltageSensor; +class PositionSensor; +class TempSensor; + +class Motor { +public: + Motor(CurrentSensor *sense_a, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t); + void Config(int num_poles, float kv); + float UpdateCurrentA(); + float UpdateCurrentB(); + float UpdatePosition(); + float UpdateTemp(); + void UpdateState(); +public: + float angle, I_a, I_b, temp; +private: + CurrentSensor *_sense_a,*_sense_b; + PositionSensor *_sense_p; + TempSensor *_sense_t; + int _num_poles; + float _kv; +}; + +class Inverter { +public: + Inverter(PinName ph_a, PinName ph_b, PinName ph_c, PinName en, VoltageSensor *sense_bus, TempSensor *sense_t); + void SetDtcA(float dtc); + void SetDtcB(float dtc); + void SetDtcC(float dtc); + void Disable(); + void Enable(); + float UpdateVbus(); + float UpdateTemp(); +public: + float dtcA, dtcB, dtcC; + float v_bus, temp; +private: + PwmOut *_pwm_a, *_pwm_b, *_pwm_c; + DigitalOut *_en; + VoltageSensor *_sense_bus; + TempSensor *_sense_t; +}; + +class User { +public: + User(Throttle *throttle) {_throttle = throttle;} + void UpdateThrottle() {throttle = _throttle->GetThrottle();} + void UpdateState() {UpdateThrottle();} +public: + float throttle; +private: + Throttle *_throttle; +}; + +#endif \ No newline at end of file