(Global_Iq0)START=1 // 0: Disable PWM, 1: Enable PWM (Global_Iq0)VdTesting1=0.2 (Global_Iq0)VqTesting1=0.2 (Global_Iq0)SpeedRef1 = 0.3 // Speed reference at the start. 0.3 pu RampRate=1 // To reduce simulation time, set RampRate=1 // To generate code for hardware, set RampRate=5 or larger PI=3.14159265 POLES=4 // Number of poles BASE_VOLTAGE=236.74 // Base peak phase voltage (volt) BASE_CURRENT=10 // Base peak phase current (amp) BASE_FREQ=120 // Base electrical frequency (Hz) BASE_RPM=120*(BASE_FREQ/POLES) //Base motor speed in rmp RS=11.05 Rr=6.11 Lr=0.316423 // Stator resistance (ohm) LS=0.316423 // Stator inductance (Hr) MotorFreq=10K // Motor PWM switching frequency, in Hz T=1.0/MotorFreq SpdFreq=1K // Speed loop frequency MinDelta = 0.0000305 // Speed change step