#8 Чуть доработан модуль adc_sim и настройка режима ПЧ выведена в app_configs.h
This commit is contained in:
parent
3b5b9b86f7
commit
864a2dfcac
@ -5,19 +5,27 @@
|
||||
Дата последнего обновления: 2021.11.08
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef DEF
|
||||
#define DEF
|
||||
#ifndef _APP_CONFIG
|
||||
#define _APP_CONFIG
|
||||
|
||||
// раскомментировать, если есть сдвиг между обмотками ГЭД (30 град.)
|
||||
#define SHIFT
|
||||
|
||||
#define ALG_MODE_SIMULINK ALG_MODE_SCALAR_OBOROTS
|
||||
/*
|
||||
ALG_MODE_UF_CONST,
|
||||
ALG_MODE_SCALAR_OBOROTS,
|
||||
ALG_MODE_SCALAR_POWER,
|
||||
ALG_MODE_FOC_OBOROTS,
|
||||
ALG_MODE_FOC_POWER
|
||||
*/
|
||||
#define SIMULINK_SEQUENCE V_PWM24_PHASE_SEQ_NORMAL_ABC
|
||||
/* V_PWM24_PHASE_SEQ_NORMAL_ABC, - êðàñèâûé òîê, íåêðàñèâîå íàïðÿæåíèÿ
|
||||
V_PWM24_PHASE_SEQ_NORMAL_BCA, - âñ¸ õåðíÿ
|
||||
V_PWM24_PHASE_SEQ_NORMAL_CAB, - âñ¸ õåðíÿ
|
||||
V_PWM24_PHASE_SEQ_REVERS_ACB, - âñ¸ õåðíÿ
|
||||
V_PWM24_PHASE_SEQ_REVERS_CBA, - æîïà
|
||||
V_PWM24_PHASE_SEQ_REVERS_BAC - æîïà
|
||||
/* V_PWM24_PHASE_SEQ_NORMAL_ABC,
|
||||
V_PWM24_PHASE_SEQ_NORMAL_BCA,
|
||||
V_PWM24_PHASE_SEQ_NORMAL_CAB,
|
||||
V_PWM24_PHASE_SEQ_REVERS_ACB,
|
||||
V_PWM24_PHASE_SEQ_REVERS_CBA,
|
||||
V_PWM24_PHASE_SEQ_REVERS_BAC
|
||||
*/
|
||||
|
||||
#endif //DEF
|
||||
#endif //_APP_CONFIG
|
||||
|
@ -41,7 +41,7 @@ void app_init(void) {
|
||||
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_SCALAR_OBOROTS;
|
||||
edrk.Mode_ScalarVectorUFConst = ALG_MODE_SIMULINK;
|
||||
//edrk.Mode_ScalarVectorUFConst = ALG_MODE_FOC_OBOROTS;
|
||||
|
||||
edrk.zadanie.iq_power_zad = _IQ(1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef INIT28335
|
||||
#define INIT28335
|
||||
#ifndef _APP_INIT
|
||||
#define _APP_INIT
|
||||
|
||||
#include "app_includes.h"
|
||||
|
||||
@ -10,4 +10,4 @@ void edrk_init_variables_matlab(void);
|
||||
void set_zadanie_u_charge_matlab(void);
|
||||
void init_Uin_rms(void);
|
||||
void init_flag_a(void);
|
||||
#endif //INIT28335
|
||||
#endif //_APP_INIT
|
||||
|
@ -119,4 +119,14 @@ void writeOutputParameters(real_T* xD) {
|
||||
xD[nn++] = xpwm_time.Tc1_0;
|
||||
xD[nn++] = xpwm_time.Tc1_1;
|
||||
|
||||
|
||||
|
||||
xD[nn++] = (AdcSim.udc1.adc_val);
|
||||
xD[nn++] = (AdcSim.udc2.adc_val);
|
||||
xD[nn++] = (AdcSim.ia1.adc_val);
|
||||
xD[nn++] = (AdcSim.ib1.adc_val);
|
||||
xD[nn++] = (AdcSim.ic1.adc_val);
|
||||
xD[nn++] = (AdcSim.ia2.adc_val);
|
||||
xD[nn++] = (AdcSim.ib2.adc_val);
|
||||
xD[nn++] = (AdcSim.ic2.adc_val);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#include "simstruc.h"
|
||||
#include "app_includes.h"
|
||||
|
||||
#ifndef PARAM
|
||||
#define PARAM
|
||||
#ifndef _APP_IO
|
||||
#define _APP_IO
|
||||
|
||||
|
||||
void readInputParameters(const real_T* u);
|
||||
@ -13,5 +13,5 @@ extern int CAN_timeout[UNIT_QUA];
|
||||
extern RS_DATA_STRUCT rs_a;
|
||||
extern RS_DATA_STRUCT rs_b;
|
||||
extern _iq iq_norm_ADC[COUNT_ARR_ADC_BUF][16];
|
||||
#endif //PARAM
|
||||
#endif //_APP_IO
|
||||
|
||||
|
@ -9,27 +9,27 @@ void Simulate_ADC(SimStruct* S)
|
||||
|
||||
adcMeasure(&AdcSim.Measure, IN, 0);
|
||||
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.udc1, AdcSim.Measure.udc1, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.udc2, AdcSim.Measure.udc2, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ia1, AdcSim.Measure.ia1, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ib1, AdcSim.Measure.ib1, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ic1, AdcSim.Measure.ic1, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ia2, AdcSim.Measure.ia2, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ib2, AdcSim.Measure.ib2, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ic2, AdcSim.Measure.ic2, 0);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.udc1, AdcSim.Measure.udc1);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.udc2, AdcSim.Measure.udc2);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ia1, AdcSim.Measure.ia1);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ib1, AdcSim.Measure.ib1);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ic1, AdcSim.Measure.ic1);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ia2, AdcSim.Measure.ia2);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ib2, AdcSim.Measure.ib2);
|
||||
adcConvert(&AdcSim.convertion, &AdcSim.ic2, AdcSim.Measure.ic2);
|
||||
}
|
||||
|
||||
void Init_ADC_Simulation()
|
||||
{
|
||||
adcInitConvertion(&AdcSim.convertion, NORMA_ACP, 2.5, 4096);
|
||||
adcInitMeasure(&AdcSim.udc1, K_LEM_ADC[0], R_ADC[0], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.udc2, K_LEM_ADC[1], R_ADC[1], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.ia1, K_LEM_ADC[2], R_ADC[2], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.ib1, K_LEM_ADC[3], R_ADC[3], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.ic1, K_LEM_ADC[4], R_ADC[4], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.ia2, K_LEM_ADC[5], R_ADC[5], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.ib2, K_LEM_ADC[6], R_ADC[6], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.ic2, K_LEM_ADC[7], R_ADC[7], DEFAULT_ZERO_ADC);
|
||||
adcInitMeasure(&AdcSim.udc1, K_LEM_ADC[0], R_ADC[0], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.udc2, K_LEM_ADC[1], R_ADC[1], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.ia1, K_LEM_ADC[2], R_ADC[2], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.ib1, K_LEM_ADC[3], R_ADC[3], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.ic1, K_LEM_ADC[4], R_ADC[4], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.ia2, K_LEM_ADC[5], R_ADC[5], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.ib2, K_LEM_ADC[6], R_ADC[6], DEFAULT_ZERO_ADC, 0);
|
||||
adcInitMeasure(&AdcSim.ic2, K_LEM_ADC[7], R_ADC[7], DEFAULT_ZERO_ADC, 0);
|
||||
|
||||
}
|
||||
|
||||
@ -40,11 +40,12 @@ void adcInitConvertion(AdcConvertionHandle* hconv, int norma_adc, double adc_amp
|
||||
hconv->adc_bit_depth = adc_bit_depth;
|
||||
}
|
||||
|
||||
void adcInitMeasure(AdcMeasureHandle* hmeasure, int k_lem_adc, int r_adc, int offset)
|
||||
void adcInitMeasure(AdcMeasureHandle* hmeasure, int k_lem_adc, int r_adc, int offset, double real_satur)
|
||||
{
|
||||
hmeasure->k_lem_adc = k_lem_adc;
|
||||
hmeasure->r_adc = r_adc;
|
||||
hmeasure->offset = offset;
|
||||
hmeasure->k_lem_adc = k_lem_adc;
|
||||
hmeasure->r_adc = r_adc;
|
||||
hmeasure->offset = offset;
|
||||
hmeasure->real_satur = real_satur;
|
||||
}
|
||||
|
||||
void adcMeasure(AdcRealMeasureHandle *hrmeasure, const real_T* u, int startind)
|
||||
@ -59,16 +60,15 @@ void adcMeasure(AdcRealMeasureHandle *hrmeasure, const real_T* u, int startind)
|
||||
hrmeasure->ic2 = u[startind++];
|
||||
}
|
||||
|
||||
void adcConvert(AdcConvertionHandle* hconv, AdcMeasureHandle* hmeasure, double realMeasure, double MeasureSatur)
|
||||
void adcConvert(AdcConvertionHandle* hconv, AdcMeasureHandle* hmeasure, double realMeasure)
|
||||
{
|
||||
if (MeasureSatur != 0)
|
||||
if (hmeasure->real_satur != 0)
|
||||
{
|
||||
if (realMeasure > MeasureSatur)
|
||||
realMeasure = MeasureSatur;
|
||||
else if (realMeasure < -MeasureSatur)
|
||||
realMeasure = -MeasureSatur;
|
||||
if (realMeasure > hmeasure->real_satur)
|
||||
realMeasure = hmeasure->real_satur;
|
||||
else if (realMeasure < -hmeasure->real_satur)
|
||||
realMeasure = -hmeasure->real_satur;
|
||||
}
|
||||
// AdcMirror.ADCRESULT0 = (unsigned short)(realMeasure/MeasureSatur*2048. + (float)offset.Udc1);
|
||||
hmeasure->adc_val =
|
||||
(unsigned short)(realMeasure / hmeasure->k_lem_adc * hmeasure->r_adc / hconv->norma_adc / hconv->adc_amplitude * hconv->adc_bit_depth + (float)hmeasure->offset);
|
||||
}
|
@ -35,6 +35,7 @@ typedef struct
|
||||
{
|
||||
int adc_val;
|
||||
|
||||
double real_satur;
|
||||
int r_adc;
|
||||
int k_lem_adc;
|
||||
int offset;
|
||||
@ -63,10 +64,10 @@ AdcSimHandle AdcSim;
|
||||
void Simulate_ADC(SimStruct* S);
|
||||
void Init_ADC_Simulation();
|
||||
|
||||
void adcInitConvertion(AdcConvertionHandle* hconv, int norma_adc, int adc_amplitude, int adc_bit_depth);
|
||||
void adcInitMeasure(AdcMeasureHandle* hmeasure, int k_lem_adc, int r_adc, int offset);
|
||||
void adcInitConvertion(AdcConvertionHandle* hconv, int norma_adc, double adc_amplitude, int adc_bit_depth);
|
||||
void adcInitMeasure(AdcMeasureHandle* hmeasure, int k_lem_adc, int r_adc, int offset, double real_satur);
|
||||
|
||||
void adcMeasure(AdcRealMeasureHandle* hrmeasure, const real_T* u, int startind);
|
||||
void adcConvert(AdcConvertionHandle* hconv, AdcMeasureHandle* hmeasure, double realMeasure, double MeasureSatur);
|
||||
void adcConvert(AdcConvertionHandle* hconv, AdcMeasureHandle* hmeasure, double realMeasure);
|
||||
|
||||
#endif //PWM_SIM
|
||||
|
BIN
inu_23550.slx
BIN
inu_23550.slx
Binary file not shown.
Loading…
Reference in New Issue
Block a user