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 analoghalls5 by
core.h
00001 #ifndef __CORE_H 00002 #define __CORE_H 00003 00004 #include "includes.h" 00005 #include "sensors.h" 00006 00007 class Motor; 00008 class Inverter; 00009 class CurrentSensor; 00010 class VoltageSensor; 00011 class PositionSensor; 00012 class TempSensor; 00013 00014 class Motor { 00015 public: 00016 Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t); 00017 void Config(int num_poles, float kv); 00018 float UpdateCurrentC(); 00019 float UpdateCurrentB(); 00020 float UpdatePosition(); 00021 float UpdateTemp(); 00022 void UpdateState(); 00023 public: 00024 float angle, I_c, I_b, temp; 00025 private: 00026 CurrentSensor *_sense_c,*_sense_b; 00027 PositionSensor *_sense_p; 00028 TempSensor *_sense_t; 00029 int _num_poles; 00030 float _kv; 00031 }; 00032 00033 class Inverter { 00034 public: 00035 Inverter(PinName ph_a, PinName ph_b, PinName ph_c, PinName en, VoltageSensor *sense_bus, TempSensor *sense_t); 00036 void SetDtcA(float dtc); 00037 void SetDtcB(float dtc); 00038 void SetDtcC(float dtc); 00039 void Disable(); 00040 void Enable(); 00041 float UpdateVbus(); 00042 float UpdateTemp(); 00043 public: 00044 float dtcA, dtcB, dtcC; 00045 float v_bus, temp; 00046 float va, vb; //debug 00047 private: 00048 PwmOut *_pwm_a, *_pwm_b, *_pwm_c; 00049 DigitalOut *_en; 00050 VoltageSensor *_sense_bus; 00051 TempSensor *_sense_t; 00052 }; 00053 00054 class User { 00055 public: 00056 User(Throttle *throttle) {_throttle = throttle;} 00057 void UpdateThrottle() {throttle = _throttle->GetThrottle();} 00058 void UpdateState() {UpdateThrottle();} 00059 public: 00060 float throttle; 00061 private: 00062 Throttle *_throttle; 00063 }; 00064 00065 #endif
Generated on Fri Jul 15 2022 12:15:05 by
