matlab_23550/Inu/param.c

427 lines
12 KiB
C
Raw Normal View History

2024-12-27 10:50:32 +03:00
/**************************************************************************
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>: 2021.11.08
**************************************************************************/
#include "def.h"
#include "param.h"
#pragma CODE_SECTION(input_param, "ramfuncs");
#pragma CODE_SECTION(output_param, "ramfuncs");
extern short test_param(void);
extern void process_sgm_parameters(void);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void input_param(unsigned short num, unsigned short val) {
switch ( num ) {
case 180://rf.PsiZ, %*10 <20><> PSI_BAZ
if ( (val <= 2000) && (val != param[num]) ) {
param[num] = val;
rf.PsiZ = (float)val*0.001;//%*10 -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 200://offset.Ia1, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Ia1 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 201://offset.Ib1, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Ib1 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 202://offset.Ic1, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Ic1 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 203://offset.Udc1, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Udc1 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 206://offset.Ia2, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Ia2 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 207://offset.Ib2, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Ib2 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 208://offset.Ic2, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Ic2 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 209://offset.Udc2, <20><>. <20><><EFBFBD>
if ( (val >= 1748) && (val <= 4096) && (val != param[num]) ) {
offset.Udc2 = param[num] = val;
eprom.writeRequestNumber += 1;
}
break;
case 210://cc.Kp, %
if ( (val <= 5000) && (val != param[num]) ) {
param[num] = val;
cc.Kp = (float)val*cc.KpOrig;
eprom.writeRequestNumber += 1;
}
break;
case 211://cc.Ki, %
if ( (val <= 5000) && (val != param[num]) ) {
param[num] = val;
cc.Ki = (float)val*cc.KiOrig;
eprom.writeRequestNumber += 1;
}
break;
case 212://cf.Kp, %
if ( (val <= 5000) && (val != param[num]) ) {
param[num] = val;
cf.Kp = (float)val*cf.KpOrig;
eprom.writeRequestNumber += 1;
}
break;
case 213://cf.Ki, %
if ( (val <= 5000) && (val != param[num]) ) {
param[num] = val;
cf.Ki = (float)val*cf.KiOrig;
eprom.writeRequestNumber += 1;
}
break;
case 214://csp.Kp, %
if ( (val <= 5000) && (val != param[num]) ) {
param[num] = val;
csp.Kp = (float)val*csp.KpOrig;
eprom.writeRequestNumber += 1;
}
break;
case 215://csp.Ki, %
if ( (val <= 5000) && (val != param[num]) ) {
param[num] = val;
csp.Ki = (float)val*csp.KiOrig;
eprom.writeRequestNumber += 1;
}
break;
case 220://protect.IacMax, % <20><> IAC_SENS_MAX
if ( (val <= 99) && (val != param[num]) ) {
param[num] = val;
protect.IacMax = (short)(2047.*(float)val*0.01);//% -> <20><>. <20><><EFBFBD>
protect.IacMin = -protect.IacMax;
eprom.writeRequestNumber += 1;
}
break;
case 221://protect.UdcMax, % <20><> U_NOM
if ( (val <= 136) && (val != param[num]) ) {
param[num] = val;
protect.UdcMax = (float)val*0.01;//% -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 222://IzLim, % <20><> I_BAZ
if ( (val <= 200) && (val != param[num]) ) {
param[num] = val;
IzLim = (float)val*0.01;//% -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 223://cf.IdLim, % <20><> I_BAZ
if ( (val <= 200) && (val != param[num]) ) {
param[num] = val;
cf.IdLim = (float)val*0.01;//% -> o.e.
cf.IdLimNeg = cf.IdLim*(-0.4);
eprom.writeRequestNumber += 1;
}
break;
case 224://csp.IqLim, % <20><> I_BAZ
if ( (val <= 200) && (val != param[num]) ) {
param[num] = val;
csp.IqLim = (float)val*0.01;//% -> o.e.
csp.IqLimNeg = -csp.IqLim;
eprom.writeRequestNumber += 1;
}
break;
case 225://protect.UdcMin, % <20><> U_NOM
if ( (val <= 110) && (val != param[num]) ) {
param[num] = val;
protect.UdcMin = (float)val*0.01;//% -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 226://protect.WmMax, % <20><> N_NOM
if ( (val <= 200) && (val != param[num]) ) {
param[num] = val;
protect.WmMax = (float)val*0.01;//% -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 228://rf.WmNomPsi, % <20><> N_NOM
if ( (val <= 200) && (val != param[num]) ) {
param[num] = val;
rf.WmNomPsi = (float)val*0.01;//% -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 229://rf.YlimPsi, % <20><> Y_LIM
if ( (val <= 101) && (val != param[num]) ) {
param[num] = val;
rf.YlimPsi = (float)val*0.01*Y_LIM;//% -> <20><>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
eprom.writeRequestNumber += 1;
}
break;
case 231://protect.TudcMin, <20><>
if ( (val >= 1) && (val <= 8500) && (val != param[num]) ) {
param[num] = val;
protect.TudcMin = (unsigned short)((float)val*0.001/TY);
eprom.writeRequestNumber += 1;
}
break;
case 233://protect.TwmMax, <20><>
if ( (val >= 1) && (val <= 8500) && (val != param[num]) ) {
param[num] = val;
protect.TwmMax = (unsigned short)((float)val*0.001/TY);
eprom.writeRequestNumber += 1;
}
break;
case 244://rs.WlimIncr, <20><>
if ( (val >= 1) && (val != param[num]) ) {
param[num] = val;
// <20><><EFBFBD>. <20><> 1.0 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><>
rs.WlimIncr = 1.0*TY*DECIM_PSI_WM_PM/((float)val*0.001);
eprom.writeRequestNumber += 1;
}
break;
case 245://csp.IlimIncr, <20><>
if ( (val >= 1) && (val != param[num]) ) {
param[num] = val;
// <20><><EFBFBD>. <20><> I_BAZ <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><>
csp.IlimIncr = 1.0*TY*DECIM_PSI_WM_PM/((float)val*0.001);
eprom.writeRequestNumber += 1;
}
break;
case 248://rp.PlimIncr, <20><>
if ( (val >= 1) && (val != param[num]) ) {
param[num] = val;
// <20><><EFBFBD>. <20><> 1.0 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><>
rp.PlimIncr = 1.0*TY*DECIM_PSI_WM_PM/((float)val*0.001);
eprom.writeRequestNumber += 1;
}
break;
case 269://KmeCorr, %*100
if ( (val >= 5000) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
KmeCorr = (float)val*0.0001;//%*100 -> o.e.
eprom.writeRequestNumber += 1;
}
break;
case 285://Kudc, <20><>*10
if ( (val >= 1) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
Kudc = (TY*10000.)/(float)val;
if ( Kudc > 1.0 )
Kudc = 1.0;
eprom.writeRequestNumber += 1;
}
break;
case 286://Kwm, <20><>*10
if ( (val >= 1) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
Kwm = (TY*10000.)/(float)val;
if ( Kwm > 1.0 )
Kwm = 1.0;
eprom.writeRequestNumber += 1;
}
break;
case 288://rs.Kwmz, <20><>
if ( (val >= 1) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
rs.Kwmz = (TY*DECIM_PSI_WM_PM*1000.)/(float)val;
eprom.writeRequestNumber += 1;
}
break;
case 289://rf.Kpsiz, <20><>
if ( (val >= 1) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
rf.Kpsiz = (TY*DECIM_PSI_WM_PM*1000.)/(float)val;
eprom.writeRequestNumber += 1;
}
break;
case 290://Kme, <20><>
if ( (val >= 1) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
Kme = (TY*1000.)/(float)val;
eprom.writeRequestNumber += 1;
}
break;
case 292://rp.Kpmz, <20><>
if ( (val >= 1) && (val <= 20000) && (val != param[num]) ) {
param[num] = val;
rp.Kpmz = (TY*DECIM_PSI_WM_PM*1000.)/(float)val;
eprom.writeRequestNumber += 1;
}
break;
case 303://sgmPar.Rs, <20><><EFBFBD><EFBFBD>
if ( val != param[num] ) {
param[num] = val;
sgmPar.Rs = (float)val*1e-6;//<2F><><EFBFBD><EFBFBD> -> <20><>
eprom.writeRequestNumber += 1;
}
break;
case 304://sgmPar.Lls, <20><><EFBFBD><EFBFBD>*10
if ( val != param[num] ) {
param[num] = val;
sgmPar.Lls = (float)val*1e-7;//<2F><><EFBFBD><EFBFBD>*10 -> <20><>
process_sgm_parameters();
eprom.writeRequestNumber += 1;
}
break;
case 305://sgmPar.Rr, <20><><EFBFBD><EFBFBD>
if ( val != param[num] ) {
param[num] = val;
sgmPar.Rr = (float)val*1e-6;//<2F><><EFBFBD><EFBFBD> -> <20><>
process_sgm_parameters();
eprom.writeRequestNumber += 1;
}
break;
case 306://sgmPar.Llr, <20><><EFBFBD><EFBFBD>*10
if ( val != param[num] ) {
param[num] = val;
sgmPar.Llr = (float)val*1e-7;//<2F><><EFBFBD><EFBFBD>*10 -> <20><>
process_sgm_parameters();
eprom.writeRequestNumber += 1;
}
break;
case 307://sgmPar.Lm, <20><><EFBFBD><EFBFBD>
if ( val != param[num] ) {
param[num] = val;
sgmPar.Lm = (float)val*1e-6;//<2F><><EFBFBD><EFBFBD> -> <20><>
process_sgm_parameters();
eprom.writeRequestNumber += 1;
}
break;
default:
if ( num < PAR_NUMBER ) {
param[num] = val;
}
break;
} //switch ( num )
} //void input_param(unsigned short num, unsigned short val)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned short output_param(unsigned short num) {
static unsigned short output;
switch ( num ) {
case 1: //udc1, o.e. -> o.e.*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
output = (unsigned short)(emerg.udc1*CONTROLLER_GAIN);
}
else {
output = (unsigned short)(out.udc1*CONTROLLER_GAIN);
}
break;
case 2: //udc2, o.e. -> o.e.*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
output = (unsigned short)(emerg.udc2*CONTROLLER_GAIN);
}
else {
output = (unsigned short)(out.udc2*CONTROLLER_GAIN);
}
break;
case 5: //iac1, o.e. -> o.e.*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
output = (unsigned short)(emerg.iac1*CONTROLLER_GAIN);
}
else {
output = (unsigned short)(out.iac1*CONTROLLER_GAIN);
}
break;
case 6: //iac2, o.e. -> o.e.*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
output = (unsigned short)(emerg.iac2*CONTROLLER_GAIN);
}
else {
output = (unsigned short)(out.iac2*CONTROLLER_GAIN);
}
break;
case 7: //me, o.e. -> (o.e. + CONTROLLER_BIAS)*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
if ( emerg.me > CONTROLLER_BIAS )
output = (unsigned short)((CONTROLLER_BIAS + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else if ( emerg.me > -CONTROLLER_BIAS )
output = (unsigned short)((emerg.me + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else
output = 0;
}
else {
if ( out.me > CONTROLLER_BIAS )
output = (unsigned short)((CONTROLLER_BIAS + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else if ( out.me > -CONTROLLER_BIAS )
output = (unsigned short)((out.me + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else
output = 0;
}
break;
case 8: //nm, o.e. -> (o.e. + CONTROLLER_BIAS)*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
if ( emerg.wm > CONTROLLER_BIAS )
output = (unsigned short)((CONTROLLER_BIAS + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else if ( emerg.wm > -CONTROLLER_BIAS )
output = (unsigned short)((emerg.wm + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else
output = 0;
}
else {
if ( out.wm > CONTROLLER_BIAS )
output = (unsigned short)((CONTROLLER_BIAS + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else if ( out.wm > -CONTROLLER_BIAS )
output = (unsigned short)((out.wm + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else
output = 0;
}
break;
case 9: //pm, o.e. -> (o.e. + CONTROLLER_BIAS)*CONTROLLER_GAIN
if ( state == STATE_SHUTDOWN ) {
if ( emerg.pm > CONTROLLER_BIAS )
output = (unsigned short)((CONTROLLER_BIAS + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else if ( emerg.pm > -CONTROLLER_BIAS )
output = (unsigned short)((emerg.pm + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else
output = 0;
}
else {
if ( out.pm > CONTROLLER_BIAS )
output = (unsigned short)((CONTROLLER_BIAS + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else if ( out.pm > -CONTROLLER_BIAS )
output = (unsigned short)((out.pm + CONTROLLER_BIAS)*CONTROLLER_GAIN);
else
output = 0;
}
break;
case 10: //compound
output = faultNo + (inuWork<<7);
break;
default:
output = param[num];
break;
} //switch ( num )
return output;
} //unsigned short output_param(unsigned short num)