matlab_23550/Inu/app_wrapper/app_init.c

169 lines
4.7 KiB
C
Raw Normal View History

/**************************************************************************
Description: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TMS320F28335/TMS320F28379D.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>.<EFBFBD>.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2021.10.04
**************************************************************************/
#include "app_init.h"
#define FREQ_TIMER_3 (FREQ_PWM*2)
#define MAX_U_PROC_SMALL 2.5 //1.4
#define MAX_U_PROC 1.3 //1.11 //1.4
#define MIN_U_PROC 0.8 //0.7
#define ADD_U_MAX_GLOBAL 200.0 //V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GLOBAL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZadanieU_Charge
#define ADD_U_MAX_GLOBAL_SMALL 500.0 //V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GLOBAL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZadanieU_Charge
#define LEVEL_DETECT_U_SMALL 1000.0 //V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GLOBAL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZadanieU_Charge
void app_init(void) {
edrk.flag_second_PCH = 0;
edrk_init_variables_matlab();
init_global_time_struct(FREQ_TIMER_3);
Init_Adc_Variables();
//svgen_pwm24_1.phase_sequence = SIMULINK_SEQUENCE;
//svgen_pwm24_2.phase_sequence = SIMULINK_SEQUENCE;
edrk.zadanie.iq_Izad = _IQ(1);
edrk.disable_alg_u_disbalance = 0;
edrk.zadanie.iq_limit_power_zad = _IQ(1);
edrk.zadanie.ZadanieU_Charge = 2500;
edrk.zadanie.iq_ZadanieU_Charge = _IQ(2500 / NORMA_ACP);
edrk.temper_limit_koeffs.sum_limit = _IQ(1);
simple_scalar1.fzad_add_max = _IQ(FZAD_ADD_MAX);
edrk.Mode_ScalarVectorUFConst = ALG_MODE_SIMULINK;
//edrk.Mode_ScalarVectorUFConst = ALG_MODE_FOC_OBOROTS;
edrk.zadanie.iq_power_zad = _IQ(1);
edrk.zadanie.iq_oborots_zad_hz = _IQ(1);
edrk.MasterSlave = MODE_MASTER;
edrk.master_theta;
edrk.master_Iq;
edrk.iq_power_kw_another_bs = edrk.P_to_master;
edrk.tetta_to_slave;
edrk.Iq_to_slave;
edrk.P_to_master;
uf_alg.winding_displacement_bs1;
//analog_zero.iqU_1 = 2048;
//analog_zero.iqU_2 = 2048;
} //void init28335(void)
void edrk_init_variables_matlab(void)
{
initVectorControl();
InitXPWM(FREQ_PWM);
InitPWM_Variables();
//#if(SENSOR_ALG==SENSOR_ALG_23550)
// rotorInit();
//#endif
//#if(SENSOR_ALG==SENSOR_ALG_22220)
// // 22220
// rotorInit_22220();
//#endif
control_station.clear(&control_station);
edrk_init_matlab();
init_ramp_all_zadanie();
//init_all_limit_koeffs();
for (int i = 0; i < CONTROL_STATION_CMD_LAST; i++)
control_station.array_cmd[CONTROL_STATION_TERMINAL_CAN][i] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][i];
ramp_all_zadanie(2);
set_zadanie_u_charge_matlab();
init_Uin_rms();
}
void edrk_init_matlab(void)
{
edrk.Uzad_max = _IQ(K_STATOR_MAX); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = DEF_PERIOD_MIN_MKS
edrk.iq_bpsi_normal = _IQ(BPSI_NORMAL / NORMA_FROTOR);
// edrk.iq_f_provorot = _IQ(F_PROVOROT/NORMA_FROTOR);
//init_simple_scalar();
//edrk.flag_enable_update_hmi = 1;
edrk.Uzad_max = _IQ(K_STATOR_MAX); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = DEF_PERIOD_MIN_MKS
edrk.iq_bpsi_normal = _IQ(BPSI_NORMAL / NORMA_FROTOR);
// edrk.iq_bpsi_max = _IQ(BPSI_MAXIMAL/NORMA_FROTOR);
// edrk.iq_f_provorot = _IQ(F_PROVOROT/NORMA_FROTOR);
init_simple_scalar();
edrk.flag_enable_update_hmi = 1;
//edrk.zadanie.iq_set_break_level = _IQ(2500 / NORMA_ACP);
control_station.setup_time_detect_active[CONTROL_STATION_TERMINAL_RS232] = 50;
}
void set_zadanie_u_charge_matlab(void)
{
//edrk.ZadanieU_Charge = edrk.ZadanieU_Charge_RS;
//edrk.iq_ZadanieU_Charge = _IQ(edrk.ZadanieU_Charge/NORMA_ACP);
if (edrk.zadanie.ZadanieU_Charge<=100)
{
edrk.iqMIN_U_ZPT = _IQ(-50.0/NORMA_ACP);
edrk.iqMIN_U_IN = _IQ(-50.0/NORMA_ACP);
}
else
{
edrk.iqMIN_U_ZPT = _IQ(edrk.zadanie.ZadanieU_Charge*MIN_U_PROC/NORMA_ACP);
edrk.iqMIN_U_IN = _IQ(edrk.zadanie.ZadanieU_Charge*MIN_U_PROC/NORMA_ACP);
}
if (edrk.zadanie.ZadanieU_Charge<LEVEL_DETECT_U_SMALL)
{
edrk.iqMAX_U_ZPT_Predzaryad = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC_SMALL/NORMA_ACP);
edrk.iqMAX_U_ZPT_Global = edrk.iqMAX_U_ZPT_Predzaryad + _IQ(ADD_U_MAX_GLOBAL_SMALL/NORMA_ACP); // +500V
}
else
{
edrk.iqMAX_U_ZPT_Predzaryad = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP);
edrk.iqMAX_U_ZPT_Global = edrk.iqMAX_U_ZPT_Predzaryad + _IQ(ADD_U_MAX_GLOBAL/NORMA_ACP); // +200V
if (edrk.iqMAX_U_ZPT_Global>U_D_MAX_ERROR_GLOBAL_2800)
edrk.iqMAX_U_ZPT_Global = U_D_MAX_ERROR_GLOBAL_2800;
}
edrk.iqMAX_U_ZPT = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP);
edrk.iqMAX_U_IN = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP);
}