First version of program for measuring current of three phase BLDC motor.

Dependencies:   AutomationElements CurrentRegulation_ mbed

Committer:
dfraj
Date:
Sat Jul 18 20:01:58 2015 +0000
Revision:
0:c499ebd23db0
First version of program for measuring current of three phase BLDC motor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dfraj 0:c499ebd23db0 1 #include "CurrentMeasurement.h"
dfraj 0:c499ebd23db0 2
dfraj 0:c499ebd23db0 3 CurrentMeasurement::CurrentMeasurement(PinName pI_A, PinName pI_B, PinName pI_C, PinName pI_TOTAL):I_A(pI_A), I_B(pI_B), I_C(pI_C), I_TOTAL(pI_TOTAL){
dfraj 0:c499ebd23db0 4 setValues(1e-3, 1e3, 1e3, 40e3, 20e3, 3.3);
dfraj 0:c499ebd23db0 5 calculateCurrentA();
dfraj 0:c499ebd23db0 6 calculateCurrentB();
dfraj 0:c499ebd23db0 7 calculateCurrentC();
dfraj 0:c499ebd23db0 8 calculateCurrentTotal();
dfraj 0:c499ebd23db0 9 }
dfraj 0:c499ebd23db0 10
dfraj 0:c499ebd23db0 11 CurrentMeasurement::CurrentMeasurement(PinName pI_A, PinName pI_B, PinName pI_C, PinName pI_TOTAL, float R_sh, float R_1s, float R_1t, float R_fs, float R_ft, float V_ref):I_A(pI_A), I_B(pI_B), I_C(pI_C), I_TOTAL(pI_TOTAL){
dfraj 0:c499ebd23db0 12 setValues(R_sh, R_1s, R_1t, R_fs, R_ft, V_ref);
dfraj 0:c499ebd23db0 13 calculateCurrentA();
dfraj 0:c499ebd23db0 14 calculateCurrentB();
dfraj 0:c499ebd23db0 15 calculateCurrentC();
dfraj 0:c499ebd23db0 16 calculateCurrentTotal();
dfraj 0:c499ebd23db0 17 }
dfraj 0:c499ebd23db0 18
dfraj 0:c499ebd23db0 19 void CurrentMeasurement::setValues(float R_sh, float R_1s, float R_1t, float R_fs, float R_ft, float V_ref){
dfraj 0:c499ebd23db0 20 this->R_sh = R_sh;
dfraj 0:c499ebd23db0 21 this->R_1s = R_1s;
dfraj 0:c499ebd23db0 22 this->R_1t = R_1t;
dfraj 0:c499ebd23db0 23 this->R_fs = R_fs;
dfraj 0:c499ebd23db0 24 this->R_ft = R_ft;
dfraj 0:c499ebd23db0 25 this->V_ref = V_ref;
dfraj 0:c499ebd23db0 26 }
dfraj 0:c499ebd23db0 27
dfraj 0:c499ebd23db0 28 float CurrentMeasurement::calculateCurrentA(){
dfraj 0:c499ebd23db0 29 return I_A_ = (R_sh * R_1s * (V_ref * I_A.read()))/R_fs - (R_sh * R_1s * (V_ref/2))/R_fs;
dfraj 0:c499ebd23db0 30 }
dfraj 0:c499ebd23db0 31
dfraj 0:c499ebd23db0 32 float CurrentMeasurement::calculateCurrentB(){
dfraj 0:c499ebd23db0 33 return I_B_ = (R_sh * R_1s * (V_ref * I_B.read()))/R_fs - (R_sh * R_1s * (V_ref/2))/R_fs;
dfraj 0:c499ebd23db0 34 }
dfraj 0:c499ebd23db0 35
dfraj 0:c499ebd23db0 36 float CurrentMeasurement::calculateCurrentC(){
dfraj 0:c499ebd23db0 37 return I_C_ = (R_sh * R_1s * (V_ref * I_C.read()))/R_fs - (R_sh * R_1s * (V_ref/2))/R_fs;
dfraj 0:c499ebd23db0 38 }
dfraj 0:c499ebd23db0 39
dfraj 0:c499ebd23db0 40 float CurrentMeasurement::calculateCurrentTotal(){
dfraj 0:c499ebd23db0 41 return I_TOTAL_ = (R_1t * (V_ref * I_TOTAL.read()))/(R_ft * R_sh) - (R_1t * (V_ref/2))/(R_ft * R_sh);
dfraj 0:c499ebd23db0 42 }