⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aci3_4.c

📁 异步电机矢量控制c源程序
💻 C
📖 第 1 页 / 共 3 页
字号:
 	aci1.K8 = _IQ(aci1_const.K8);
  	aci1.K9 = _IQ(aci1_const.K9);
 	aci1.K10 = _IQ(aci1_const.K10);
	aci1.BaseRpm = 120*BASE_FREQ/P;
 	aci1.LoadTorque = _IQ(TL/BASE_TORQUE);	

// Initialize the ACI_FE constant module
	fe1_const.Rs = RS;
	fe1_const.Rr = RR;
	fe1_const.Ls = LS;
	fe1_const.Lr = LR;
	fe1_const.Lm = LM;
	fe1_const.Ib = BASE_CURRENT;
	fe1_const.Vb = BASE_VOLTAGE;
	fe1_const.Ts = T;
 	fe1_const.calc(&fe1_const);

// Initialize the ACI_FE module 
 	fe1.K1 = _IQ(fe1_const.K1);
 	fe1.K2 = _IQ(fe1_const.K2);
 	fe1.K3 = _IQ(fe1_const.K3);
 	fe1.K4 = _IQ(fe1_const.K4);
 	fe1.K5 = _IQ(fe1_const.K5);
 	fe1.K6 = _IQ(fe1_const.K6);
 	fe1.K7 = _IQ(fe1_const.K7);
 	fe1.K8 = _IQ(fe1_const.K8);
    fe1.Kp = _IQ(0.055);
    fe1.Ki = _IQ(0.002);
 
// Initialize the ACI_SE constant module
	se1_const.Rr = RR;
	se1_const.Lr = LR;
	se1_const.fb = BASE_FREQ;
	se1_const.fc = 200;
	se1_const.Ts = T;
 	se1_const.calc(&se1_const);

// Initialize the ACI_SE module 
 	se1.K1 = _IQ(se1_const.K1);
 	se1.K2 = _IQ21(se1_const.K2);
 	se1.K3 = _IQ(se1_const.K3);
 	se1.K4 = _IQ(se1_const.K4);
 	se1.BaseRpm = 120*BASE_FREQ/P;

// Initialize the PID module for Id
	pid1_id.Kp = _IQ(0.541);
	pid1_id.Ki = _IQ(T/0.04);				
	pid1_id.Kd = _IQ(0/T);						
	pid1_id.Kc = _IQ(0.9);
    pid1_id.OutMax = _IQ(0.30);
    pid1_id.OutMin = _IQ(-0.30);    
 
// Initialize the PID module for Iq
	pid1_iq.Kp = _IQ(0.541);
	pid1_iq.Ki = _IQ(T/0.04);					
	pid1_iq.Kd = _IQ(0/T);						
	pid1_iq.Kc = _IQ(0.9);
    pid1_iq.OutMax = _IQ(0.95);
    pid1_iq.OutMin = _IQ(-0.95);    

// Initialize the PID module for speed
    pid1_spd.Kp = _IQ(1.2);
	pid1_spd.Ki = _IQ(T/0.2);					
	pid1_spd.Kd = _IQ(0/T);						
 	pid1_spd.Kc = _IQ(0.9);
    pid1_spd.OutMax = _IQ(1);
    pid1_spd.OutMin = _IQ(-1); 
    
// Enable global Interrupts and higher priority real-time debug events:
	EINT;   // Enable Global interrupt INTM
	ERTM;	// Enable Global realtime interrupt DBGM

// IDLE loop. Just sit and loop forever:	
	for(;;) BackTicker++;
}


interrupt void MainISR(void)
{

// Verifying the ISR
    IsrTicker++;

// ***************** LEVEL1 *****************
#if (BUILDLEVEL==LEVEL1)

// ------------------------------------------------------------------------------
//    Connect inputs of the RMP module and call the Ramp control
//    calculation function.
// ------------------------------------------------------------------------------
    rc1.TargetValue = _IQ(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 INV_PARK module and call the inverse park transformation
//    calculation function.
// ------------------------------------------------------------------------------
    ipark1.Ds = _IQ(VdTesting);
    ipark1.Qs = _IQ(VqTesting);	
    ipark1.Angle = rg1.Out;
    ipark1.calc(&ipark1);

// ------------------------------------------------------------------------------
//    Connect inputs of the PWMDAC module 
// ------------------------------------------------------------------------------	
    PwmDacCh1 = (int16)_IQtoIQ15(ipark1.Alpha);
    PwmDacCh2 = (int16)_IQtoIQ15(ipark1.Beta);    
    PwmDacCh3 = (int16)_IQtoIQ15(rg1.Out);

// ------------------------------------------------------------------------------
//    Connect inputs of the DATALOG module 
// ------------------------------------------------------------------------------
    DlogCh1 = (int16)_IQtoIQ15(ipark1.Alpha);
    DlogCh2 = (int16)_IQtoIQ15(ipark1.Beta);
    DlogCh3 = (int16)_IQtoIQ15(rg1.Freq);
    DlogCh4 = (int16)_IQtoIQ15(rg1.Out);

#endif // (BUILDLEVEL==LEVEL1)


// ***************** LEVEL2 *****************
#if (BUILDLEVEL==LEVEL2)

// ------------------------------------------------------------------------------
//    Connect inputs of the RMP module and call the Ramp control
//    calculation function.
// ------------------------------------------------------------------------------
    rc1.TargetValue = _IQ(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 = _IQ(VdTesting);
    ipark1.Qs = _IQ(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 = (int16)_IQtoIQ15(aci1.Ialpha);
    PwmDacCh2 = (int16)_IQtoIQ15(aci1.Wr);    
    PwmDacCh3 = (int16)_IQtoIQ15(aci1.Torque);
    
// ------------------------------------------------------------------------------
//    Connect inputs of the DATALOG module 
// ------------------------------------------------------------------------------
    DlogCh1 = (int16)_IQtoIQ15(ipark1.Alpha);
    DlogCh2 = (int16)_IQtoIQ15(ipark1.Beta);
    DlogCh3 = (int16)_IQtoIQ15(aci1.Ialpha);
    DlogCh4 = (int16)_IQtoIQ15(aci1.Ibeta);

#endif // (BUILDLEVEL==LEVEL2)


// ***************** LEVEL3 *****************
#if (BUILDLEVEL==LEVEL3)

// ------------------------------------------------------------------------------
//    Connect inputs of the RMP module and call the Ramp control
//    calculation function.
// ------------------------------------------------------------------------------
    rc1.TargetValue = _IQ(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 = _IQ(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 = _IQ(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 = (int16)_IQtoIQ15(aci1.Ialpha);
    PwmDacCh2 = (int16)_IQtoIQ15(aci1.Wr);    
    PwmDacCh3 = (int16)_IQtoIQ15(aci1.Torque);
    
// ------------------------------------------------------------------------------
//    Connect inputs of the DATALOG module 
// ------------------------------------------------------------------------------
    DlogCh1 = (int16)_IQtoIQ15(aci1.Ialpha);
    DlogCh2 = (int16)_IQtoIQ15(aci1.Ibeta);
    DlogCh3 = (int16)_IQtoIQ15(aci1.Wr);
    DlogCh4 = (int16)_IQtoIQ15(aci1.Torque);

#endif // (BUILDLEVEL==LEVEL3)


// ***************** LEVEL4 *****************
#if (BUILDLEVEL==LEVEL4)

// ------------------------------------------------------------------------------
//    Connect inputs of the RMP module and call the Ramp control
//    calculation function.
// ------------------------------------------------------------------------------
    rc1.TargetValue = _IQ(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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -