void A3(void) // Motor Start Stop State Machine
//-----------------------------------------
[
// For ACI Motor
if(StartMotor==1)
[
MotorEnable=1;
IdRef = _IQ(0.05); // Id reference (pu)
IqRef = _IQ(0.02); // Iq reference (pu)
SpeedRef = _IQ(0.3); // Speed reference (pu)
StartMotor=0;
]
if(StopMotor==1)
[
//open the speed loop
lsw=0;
//kill the flux
if(IdRef>2000)
[
IdRef=IdRef-2000;
if(SpeedRef>=_IQ(0.10))
[
SpeedRef=SpeedRef-(SpeedRef*0.1);
]
]
else
[
//flux is kllled, stop the motor
MotorEnable=0;
StopMotor=0;
]
]
//-----------------
//the next
time CpuTimer0 'counter' reaches Period value go to A1
A_Task_Ptr = &A4;
//-----------------
]