修正电流限幅
This commit is contained in:
parent
f404369a32
commit
721796e105
|
@ -40,11 +40,11 @@ void High_Frequency_Task() {
|
||||||
|
|
||||||
|
|
||||||
number++;
|
number++;
|
||||||
if (number >= 1 && number <= 50000) {
|
if (number >= 1 && number <= 10000) {
|
||||||
Speedtarget = 0.1;
|
Speedtarget = 1.0;
|
||||||
} else if (number >= 50000 && number <= 100000) {
|
} else if (number >= 10000 && number <= 20000) {
|
||||||
Speedtarget = -1.0;
|
Speedtarget = -1.0;
|
||||||
} else if (number >= 100001) {
|
} else if (number >= 20001) {
|
||||||
number = 0;
|
number = 0;
|
||||||
}
|
}
|
||||||
// Test_Angle += 0.01f;
|
// Test_Angle += 0.01f;
|
||||||
|
@ -63,8 +63,8 @@ void High_Frequency_Task() {
|
||||||
|
|
||||||
// Generate_SVM(0.0f, 0.05f, Data.Angle.getAngle());
|
// Generate_SVM(0.0f, 0.05f, Data.Angle.getAngle());
|
||||||
// float32_t Eangle = Data.Angle.getAngle();
|
// float32_t Eangle = Data.Angle.getAngle();
|
||||||
SpeedControl(Speedtarget, MT_ReadAngle());
|
SpeedControl(Speedtarget, MT_ReadAngle(),10.0f);
|
||||||
FOC_current(0, 5.0f, Data.Angle.getAngle(), 5000);
|
FOC_current(0, 10.0f, Data.Angle.getAngle(), 5000);
|
||||||
|
|
||||||
// SendCurrent_Vofa(Test_Angle,A, (FOC.dtc_a * (float) HALF_PWM_PERIOD_CYCLES));
|
// SendCurrent_Vofa(Test_Angle,A, (FOC.dtc_a * (float) HALF_PWM_PERIOD_CYCLES));
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ float32_t id_curr_pi_error;
|
||||||
|
|
||||||
float32_t id_curr_pi_errMin = 0.0f;
|
float32_t id_curr_pi_errMin = 0.0f;
|
||||||
float32_t id_curr_pi_errSum;
|
float32_t id_curr_pi_errSum;
|
||||||
float32_t id_curr_pi_errSumMax = 5.0f;
|
float32_t id_curr_pi_errSumMax = 30.0f;
|
||||||
|
|
||||||
float32_t id_curr_pi_result;
|
float32_t id_curr_pi_result;
|
||||||
|
|
||||||
|
@ -48,12 +48,11 @@ float32_t iq_curr_pi_error;
|
||||||
|
|
||||||
float32_t iq_curr_pi_errMin = 0.0f;
|
float32_t iq_curr_pi_errMin = 0.0f;
|
||||||
float32_t iq_curr_pi_errSum;
|
float32_t iq_curr_pi_errSum;
|
||||||
float32_t iq_curr_pi_errSumMax = 5.0f;
|
float32_t iq_curr_pi_errSumMax = 30.0f;
|
||||||
|
|
||||||
float32_t iq_curr_pi_result;
|
float32_t iq_curr_pi_result;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float32_t Speed_target = 0.0f;
|
float32_t Speed_target = 0.0f;
|
||||||
|
|
||||||
float32_t Speedpid_error;
|
float32_t Speedpid_error;
|
||||||
|
@ -61,14 +60,12 @@ float32_t Speedpid_errSum;
|
||||||
float32_t Speedpid_kp = 1.0f;
|
float32_t Speedpid_kp = 1.0f;
|
||||||
float32_t Speedpid_ki = 0.1f;
|
float32_t Speedpid_ki = 0.1f;
|
||||||
float32_t Speedpid_kd = 1.0f;
|
float32_t Speedpid_kd = 1.0f;
|
||||||
float32_t Speedpid_errSumMax = 5.0f;
|
float32_t Speedpid_errSumMax = 30.0f;
|
||||||
float32_t Speedpid_lastErr;
|
float32_t Speedpid_lastErr;
|
||||||
float32_t Speedpid_errDt;
|
float32_t Speedpid_errDt;
|
||||||
float32_t Speedpid_result;
|
float32_t Speedpid_result;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float32_t u_d, u_q;
|
float32_t u_d, u_q;
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,13 +138,13 @@ static float32_t PIDGetResult(float32_t Speedpid_value, float32_t valMax, float3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SpeedControl(float32_t target,float32_t angleVal) {
|
void SpeedControl(float32_t target, float32_t angleVal, float32_t valMax) {
|
||||||
Speed_target = target;
|
Speed_target = target;
|
||||||
float32_t motorControl_speedValue = GetSpeed(angleVal);
|
float32_t motorControl_speedValue = GetSpeed(angleVal);
|
||||||
SendCurrent_Vofa(motorControl_speedValue, target, 0);
|
// SendCurrent_Vofa(motorControl_speedValue, target, 0);
|
||||||
// speedPID_value = motorControl_speedValue;
|
// speedPID_value = motorControl_speedValue;
|
||||||
|
|
||||||
iq_curr_pi_target = PIDGetResult(motorControl_speedValue, angleVal, 0.0f);
|
iq_curr_pi_target = PIDGetResult(motorControl_speedValue, valMax, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,8 +152,8 @@ void SpeedControl(float32_t target,float32_t angleVal) {
|
||||||
|
|
||||||
//bool Generate_SVM(float ud, float uq, float Theta) {
|
//bool Generate_SVM(float ud, float uq, float Theta) {
|
||||||
bool FOC_current(float Id_set, float Iq_set, float Theta, float bw) {
|
bool FOC_current(float Id_set, float Iq_set, float Theta, float bw) {
|
||||||
if (id_curr_pi_target>Id_set){id_curr_pi_target=Id_set;}
|
if (id_curr_pi_target > Id_set) { id_curr_pi_target = Id_set; }
|
||||||
if (iq_curr_pi_target>Iq_set){iq_curr_pi_target=Iq_set;}
|
if (iq_curr_pi_target > Iq_set) { iq_curr_pi_target = Iq_set; }
|
||||||
// id_curr_pi_target = Id_set;
|
// id_curr_pi_target = Id_set;
|
||||||
// iq_curr_pi_target = Iq_set;
|
// iq_curr_pi_target = Iq_set;
|
||||||
|
|
||||||
|
@ -229,7 +226,7 @@ bool FOC_current(float Id_set, float Iq_set, float Theta, float bw) {
|
||||||
// FOC.dtc_a = FOC.dtc_a * 0.01;
|
// FOC.dtc_a = FOC.dtc_a * 0.01;
|
||||||
// FOC.dtc_b = FOC.dtc_b * 0.01;
|
// FOC.dtc_b = FOC.dtc_b * 0.01;
|
||||||
// FOC.dtc_c = FOC.dtc_c * 0.01;
|
// FOC.dtc_c = FOC.dtc_c * 0.01;
|
||||||
// SendCurrent_Vofa(mod_d, mod_q, current1);
|
SendCurrent_Vofa(mod_d, mod_q, iq_curr_pi_target);
|
||||||
TIM1->CCR1 = (uint16_t) (FOC.dtc_c * (float) HALF_PWM_PERIOD_CYCLES);
|
TIM1->CCR1 = (uint16_t) (FOC.dtc_c * (float) HALF_PWM_PERIOD_CYCLES);
|
||||||
TIM1->CCR2 = (uint16_t) (FOC.dtc_b * (float) HALF_PWM_PERIOD_CYCLES);
|
TIM1->CCR2 = (uint16_t) (FOC.dtc_b * (float) HALF_PWM_PERIOD_CYCLES);
|
||||||
TIM1->CCR3 = (uint16_t) (FOC.dtc_a * (float) HALF_PWM_PERIOD_CYCLES);
|
TIM1->CCR3 = (uint16_t) (FOC.dtc_a * (float) HALF_PWM_PERIOD_CYCLES);
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
#include "arm_math.h"
|
#include "arm_math.h"
|
||||||
|
|
||||||
typedef struct sFOC
|
typedef struct sFOC {
|
||||||
{
|
|
||||||
bool is_armed;
|
bool is_armed;
|
||||||
|
|
||||||
float v_bus, v_bus_filt, i_a, i_b, i_c;
|
float v_bus, v_bus_filt, i_a, i_b, i_c;
|
||||||
|
@ -23,7 +22,8 @@ typedef struct sFOC
|
||||||
extern tFOC FOC;
|
extern tFOC FOC;
|
||||||
|
|
||||||
|
|
||||||
extern void SpeedControl(float32_t target,float32_t angleVal);
|
extern void SpeedControl(float32_t target, float32_t angleVal, float32_t valMax);
|
||||||
|
|
||||||
extern bool FOC_current(float Id_set, float Iq_set, float Theta, float bw);
|
extern bool FOC_current(float Id_set, float Iq_set, float Theta, float bw);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue