📄 aci3_3.c
字号:
ipark1.Angle = rg1.Out;
ipark1.calc(&ipark1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWMDAC module
// ------------------------------------------------------------------------------
PwmDacCh1 = float2fix(ipark1.Alpha,15);
PwmDacCh2 = float2fix(ipark1.Beta,15);
PwmDacCh3 = float2fix(rg1.Out,15);
// ------------------------------------------------------------------------------
// Connect inputs of the DATALOG module
// ------------------------------------------------------------------------------
DlogCh1 = float2fix(ipark1.Alpha,15);
DlogCh2 = float2fix(ipark1.Beta,15);
DlogCh3 = float2fix(rg1.Freq,15);
DlogCh4 = float2fix(rg1.Out,15);
#endif // (BUILDLEVEL==LEVEL1)
// ***************** LEVEL2 *****************
#if (BUILDLEVEL==LEVEL2)
// ------------------------------------------------------------------------------
// Connect inputs of the RMP module and call the Ramp control
// calculation function.
// ------------------------------------------------------------------------------
rc1.TargetValue = SpeedRef;
rc1.calc(&rc1);
// ------------------------------------------------------------------------------
// Connect inputs of the RAMP GEN module and call the Ramp generator
// calculation function.
// ------------------------------------------------------------------------------
rg1.Freq = rc1.SetpointValue;
rg1.calc(&rg1);
// ------------------------------------------------------------------------------
// Connect inputs of the PARK module and call the park transformation
// calculation function.
// ------------------------------------------------------------------------------
park1.Alpha = aci1.Ialpha;
park1.Beta = aci1.Ibeta;
park1.Angle = rg1.Out;
park1.calc(&park1);
// ------------------------------------------------------------------------------
// Connect inputs of the INV_PARK module and call the inverse park transformation
// calculation function.
// ------------------------------------------------------------------------------
ipark1.Ds = VdTesting;
ipark1.Qs = VqTesting;
ipark1.Angle = rg1.Out;
ipark1.calc(&ipark1);
// ------------------------------------------------------------------------------
// Connect inputs of the ACI module and call the induction motor model
// calculation function.
// ------------------------------------------------------------------------------
aci1.Ualpha = ipark1.Alpha;
aci1.Ubeta = ipark1.Beta;
aci1.calc(&aci1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWMDAC module
// ------------------------------------------------------------------------------
PwmDacCh1 = float2fix(aci1.Ialpha,15);
PwmDacCh2 = float2fix(aci1.Wr,15);
PwmDacCh3 = float2fix(aci1.Torque,15);
// ------------------------------------------------------------------------------
// Connect inputs of the DATALOG module
// ------------------------------------------------------------------------------
DlogCh1 = float2fix(ipark1.Alpha,15);
DlogCh2 = float2fix(ipark1.Beta,15);
DlogCh3 = float2fix(aci1.Ialpha,15);
DlogCh4 = float2fix(aci1.Ibeta,15);
#endif // (BUILDLEVEL==LEVEL2)
// ***************** LEVEL3 *****************
#if (BUILDLEVEL==LEVEL3)
// ------------------------------------------------------------------------------
// Connect inputs of the RMP module and call the Ramp control
// calculation function.
// ------------------------------------------------------------------------------
rc1.TargetValue = SpeedRef;
rc1.calc(&rc1);
// ------------------------------------------------------------------------------
// Connect inputs of the RAMP GEN module and call the Ramp generator
// calculation function.
// ------------------------------------------------------------------------------
rg1.Freq = rc1.SetpointValue;
rg1.calc(&rg1);
// ------------------------------------------------------------------------------
// Connect inputs of the PARK module and call the park transformation
// calculation function.
// ------------------------------------------------------------------------------
park1.Alpha = aci1.Ialpha;
park1.Beta = aci1.Ibeta;
park1.Angle = rg1.Out;
park1.calc(&park1);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID IQ controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_iq.Ref = IqRef;
pid1_iq.Fdb = park1.Qs;
pid1_iq.calc(&pid1_iq);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID ID controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_id.Ref = IdRef;
pid1_id.Fdb = park1.Ds;
pid1_id.calc(&pid1_id);
// ------------------------------------------------------------------------------
// Connect inputs of the INV_PARK module and call the inverse park transformation
// calculation function.
// ------------------------------------------------------------------------------
ipark1.Ds = pid1_id.Out;
ipark1.Qs = pid1_iq.Out;
ipark1.Angle = rg1.Out;
ipark1.calc(&ipark1);
// ------------------------------------------------------------------------------
// Connect inputs of the ACI module and call the induction motor model
// calculation function.
// ------------------------------------------------------------------------------
aci1.Ualpha = ipark1.Alpha;
aci1.Ubeta = ipark1.Beta;
aci1.calc(&aci1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWMDAC module
// ------------------------------------------------------------------------------
PwmDacCh1 = float2fix(aci1.Ialpha,15);
PwmDacCh2 = float2fix(aci1.Wr,15);
PwmDacCh3 = float2fix(aci1.Torque,15);
// ------------------------------------------------------------------------------
// Connect inputs of the DATALOG module
// ------------------------------------------------------------------------------
DlogCh1 = float2fix(aci1.Ialpha,15);
DlogCh2 = float2fix(aci1.Ibeta,15);
DlogCh3 = float2fix(aci1.Wr,15);
DlogCh4 = float2fix(aci1.Torque,15);
#endif // (BUILDLEVEL==LEVEL3)
// ***************** LEVEL4 *****************
#if (BUILDLEVEL==LEVEL4)
// ------------------------------------------------------------------------------
// Connect inputs of the RMP module and call the Ramp control
// calculation function.
// ------------------------------------------------------------------------------
rc1.TargetValue = SpeedRef;
rc1.calc(&rc1);
// ------------------------------------------------------------------------------
// Connect inputs of the RAMP GEN module and call the Ramp generator
// calculation function.
// ------------------------------------------------------------------------------
rg1.Freq = rc1.SetpointValue;
rg1.calc(&rg1);
// ------------------------------------------------------------------------------
// Connect inputs of the PARK module and call the park transformation
// calculation function.
// ------------------------------------------------------------------------------
park1.Alpha = aci1.Ialpha;
park1.Beta = aci1.Ibeta;
park1.Angle = rg1.Out;
park1.calc(&park1);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID IQ controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_iq.Ref = IqRef;
pid1_iq.Fdb = park1.Qs;
pid1_iq.calc(&pid1_iq);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID ID controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_id.Ref = IdRef;
pid1_id.Fdb = park1.Ds;
pid1_id.calc(&pid1_id);
// ------------------------------------------------------------------------------
// Connect inputs of the INV_PARK module and call the inverse park transformation
// calculation function.
// ------------------------------------------------------------------------------
ipark1.Ds = pid1_id.Out;
ipark1.Qs = pid1_iq.Out;
ipark1.Angle = rg1.Out;
ipark1.calc(&ipark1);
// ------------------------------------------------------------------------------
// Connect inputs of the ACI module and call the induction motor model
// calculation function.
// ------------------------------------------------------------------------------
aci1.Ualpha = ipark1.Alpha;
aci1.Ubeta = ipark1.Beta;
aci1.calc(&aci1);
// ------------------------------------------------------------------------------
// Connect inputs of the CUR_MOD module and call the current model
// calculation function.
// ------------------------------------------------------------------------------
cm1.IDs = park1.Ds;
cm1.IQs = park1.Qs;
cm1.Wr = aci1.Wr;
cm1.calc(&cm1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWMDAC module
// ------------------------------------------------------------------------------
PwmDacCh1 = float2fix(aci1.Ialpha,15);
PwmDacCh2 = float2fix(cm1.Theta,15);
PwmDacCh3 = float2fix(aci1.Torque,15);
// ------------------------------------------------------------------------------
// Connect inputs of the DATALOG module
// ------------------------------------------------------------------------------
DlogCh1 = float2fix(aci1.Ialpha,15);
DlogCh2 = float2fix(aci1.Wr,15);
DlogCh3 = float2fix(cm1.Theta,15);
DlogCh4 = float2fix(rg1.Out,15);
#endif // (BUILDLEVEL==LEVEL4)
// ***************** LEVEL5 *****************
#if (BUILDLEVEL==LEVEL5)
// ------------------------------------------------------------------------------
// Connect inputs of the PARK module and call the park transformation
// calculation function.
// ------------------------------------------------------------------------------
park1.Alpha = aci1.Ialpha;
park1.Beta = aci1.Ibeta;
park1.Angle = cm1.Theta;
park1.calc(&park1);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID speed controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_spd.Ref = SpeedRef;
pid1_spd.Fdb = aci1.Wr;
pid1_spd.calc(&pid1_spd);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID IQ controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_iq.Ref = pid1_spd.Out;
pid1_iq.Fdb = park1.Qs;
pid1_iq.calc(&pid1_iq);
// ------------------------------------------------------------------------------
// Connect inputs of the PID module and call the PID ID controller
// calculation function.
// ------------------------------------------------------------------------------
pid1_id.Ref = IdRef;
pid1_id.Fdb = park1.Ds;
pid1_id.calc(&pid1_id);
// ------------------------------------------------------------------------------
// Connect inputs of the INV_PARK module and call the inverse park transformation
// calculation function.
// ------------------------------------------------------------------------------
ipark1.Ds = pid1_id.Out;
ipark1.Qs = pid1_iq.Out;
ipark1.Angle = cm1.Theta;
ipark1.calc(&ipark1);
// ------------------------------------------------------------------------------
// Connect inputs of the ACI module and call the induction motor model
// calculation function.
// ------------------------------------------------------------------------------
aci1.Ualpha = ipark1.Alpha;
aci1.Ubeta = ipark1.Beta;
aci1.calc(&aci1);
// ------------------------------------------------------------------------------
// Connect inputs of the CUR_MOD module and call the current model
// calculation function.
// ------------------------------------------------------------------------------
cm1.IDs = park1.Ds;
cm1.IQs = park1.Qs;
cm1.Wr = aci1.Wr;
cm1.calc(&cm1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWMDAC module
// ------------------------------------------------------------------------------
PwmDacCh1 = float2fix(aci1.Ialpha,15);
PwmDacCh2 = float2fix(cm1.Theta,15);
PwmDacCh3 = float2fix(aci1.Torque,15);
// ------------------------------------------------------------------------------
// Connect inputs of the DATALOG module
// ------------------------------------------------------------------------------
DlogCh1 = float2fix(aci1.Ialpha,15);
DlogCh2 = float2fix(cm1.Theta,15);
DlogCh3 = float2fix(pid1_spd.Ref,15);
DlogCh4 = float2fix(pid1_spd.Fdb,15);
#endif // (BUILDLEVEL==LEVEL5)
// ------------------------------------------------------------------------------
// Call the PWMDAC update function.
// ------------------------------------------------------------------------------
pwmdac1.update(&pwmdac1);
// ------------------------------------------------------------------------------
// Call the DATALOG update function.
// ------------------------------------------------------------------------------
dlog.update(&dlog);
#if (DSP_TARGET==F2808)
// Enable more interrupts from this timer
EPwm1Regs.ETCLR.bit.INT = 1;
// Acknowledge interrupt to recieve more interrupts from PIE group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
#endif
#if (DSP_TARGET==F2812)
// Enable more interrupts from this timer
EvaRegs.EVAIMRA.bit.T1UFINT = 1;
// Note: To be safe, use a mask value to write to the entire
// EVAIFRA register. Writing to one bit will cause a read-modify-write
// operation that may have the result of writing 1's to clear
// bits other then those intended.
EvaRegs.EVAIFRA.all = BIT9;
// Acknowledge interrupt to recieve more interrupts from PIE group 2
PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
#endif
}
//===========================================================================
// No more.
//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -