temp repo

Dependencies:   mbed

Fork of priustroller_2 by N K

Committer:
nki
Date:
Sun Mar 15 01:45:22 2015 +0000
Revision:
30:2b6d426f3bfc
Parent:
29:cb03760ba9ea
Child:
33:e7b132029bae
New interrupt driven current-sensing; current sensors have a ~0.2A offset

Who changed what in which revision?

UserRevisionLine numberNew 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);
nki 30:2b6d426f3bfc 17 void InitSensors(float ib_zero, float ic_zero, float scale);
bwang 1:1f58bdcf2956 18 void Config(int num_poles, float kv);
bwang 11:dccbaa9274c5 19 float GetCurrentC();
bwang 11:dccbaa9274c5 20 float GetCurrentB();
bwang 11:dccbaa9274c5 21 float GetPosition();
bwang 11:dccbaa9274c5 22 float GetTemp();
bwang 1:1f58bdcf2956 23 private:
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;
nki 29:cb03760ba9ea 28 float _ib, _ic;
nki 30:2b6d426f3bfc 29 float _ib_zero, _ic_zero;
nki 30:2b6d426f3bfc 30 float _scale;
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 11:dccbaa9274c5 41 float GetVbus();
bwang 11:dccbaa9274c5 42 float GetTemp();
bwang 1:1f58bdcf2956 43 private:
bwang 1:1f58bdcf2956 44 PwmOut *_pwm_a, *_pwm_b, *_pwm_c;
bwang 1:1f58bdcf2956 45 DigitalOut *_en;
bwang 1:1f58bdcf2956 46 VoltageSensor *_sense_bus;
bwang 1:1f58bdcf2956 47 TempSensor *_sense_t;
bwang 1:1f58bdcf2956 48 };
bwang 1:1f58bdcf2956 49
bwang 1:1f58bdcf2956 50 class User {
bwang 1:1f58bdcf2956 51 public:
bwang 1:1f58bdcf2956 52 User(Throttle *throttle) {_throttle = throttle;}
bwang 1:1f58bdcf2956 53 void UpdateThrottle() {throttle = _throttle->GetThrottle();}
bwang 1:1f58bdcf2956 54 public:
bwang 1:1f58bdcf2956 55 float throttle;
bwang 1:1f58bdcf2956 56 private:
bwang 1:1f58bdcf2956 57 Throttle *_throttle;
bwang 1:1f58bdcf2956 58 };
bwang 1:1f58bdcf2956 59
bwang 1:1f58bdcf2956 60 #endif