- Power on the AC or DC power supply, gradually
increase output voltage at power supply to get an appropriate DC-bus voltage.
- The required motor parameters must be defined in
the user_mtr1.h header file as shown in the following example
code.
#define USER_MOTOR1_TYPE MOTOR_TYPE_PM
#define USER_MOTOR1_NUM_POLE_PAIRS (4)
#define USER_MOTOR1_Rr_Ohm (NULL)
#define USER_MOTOR1_Rs_Ohm (0.38157931f)
#define USER_MOTOR1_Ls_d_H (0.000188295482f)
#define USER_MOTOR1_Ls_q_H (0.000188295482f)
#define USER_MOTOR1_RATED_FLUX_VpHz (0.0396642499f)
- Build the project and load the code into the
controller, disable the data cache by unchecking the "Data Cache Enabled" in Tools >
ARM Advanced Features, run the project by clicking on Resume button, or click Run →
Resume in the Debug tab. The systemVars.flagEnableSystem is set to
1 after a fixed time, that means the offsets calibration have been done and the
power relay for inrush is turned on. The fault flags motorVars_M1.faultMtrUse.all
is equal to 0 , if not, the user must check the current and voltage sensing circuit
as described in Section 4.4.1.
- Set the variable
motorVars_M1.flagEnableRunAndIdentify to 1 in the Expressions window as
shown in Figure 4-26.
- After you start running the motor:
- Set the target speed value to the
variable motorVars_M1.speedRef_Hz and watch how the motor shaft speed follow
the setting speed.
- To change the acceleration, enter a
different acceleration value for the variable
motorVars_M1.accelerationMax_Hzps.
- Use PWMDAC module to display the
monitoring variables as described in Section 4.5.2. The motor angle and current waveforms are shown in Figure 4-27.
- The default proportional gain (Kp) and integral
gain (Ki) for the current controllers of the FOC system are calculated in the function
setupControllers(). After setupControllers() is called, the global
variables motorSetVars_M1.Kp_Id, motorSetVars_M1.Ki_Id, motorSetVars_M1.Kp_Iq, and
motorSetVars_M1.Ki_Iq are initialized with the newly calculated Kp and Ki gains. Tune the
Kp and Ki value of these four variables in Expressions Watch Window as shown in Figure 4-26 for the current controllers to achieve the expected current control bandwidth and
response. The Kp gain creates a zero that cancels the pole of the motor’s stator and can
easily be calculated. The Ki gain adjusts the bandwidth of the current controller-motor
system. When a speed controlled system is needed for a certain damping, the Kp gain of the
current controller relates to the time constant of the speed controlled system.
- Set the variables
motorVars_M1.flagEnableRunAndIdentify to 0 to stop run the motor.
- Once complete, the controller can now be halted
and the debug connection terminated. Fully halting the controller by first clicking the
Suspend button on the toolbar or by clicking Target → Halt. Finally, reset
the controller by clicking on CPU Reset button or clicking Run → Reset.
- Close CCS debug session by clicking on Terminate
Debug Session button or clicking Run → Terminate.
As illustrated in Section 4.2.2, multiple FOC algorithms can be supported in the project. The user can use one (eSMO or
Hall or Encoder) algorithm or two algorithms (eSMO + Encoder) for motor control in the
project.
The user can implement eSMO and Encoder estimators
in the project simultaneously by adding the pre-define name MOTOR1_ESMO and
MOTOR1_ENC in project properties as described in Section 4.2.1. Rebuild, load and run the project as the operation steps above.
- The systemVars.estType value equals to EST_TYPE_ESMO_ENC that means eSMO and Encoder estimators are enabled in this project.
- The motorVars_M1.estimatorMode equals to ESTIMATOR_MODE_ESMO that means the eSMO estimator is using for sensorless-FOC, equals to ESTIMATOR_MODE_ENC that means the encoder estimator is using for sensored-FOC.
- The estimated rotor angles from eSMO and Encoder
are shown in Figure 4-28. The motor is running with eSMO at forward rotation by setting motorVars_M1.speedRef_Hz
to a positive value.
- The user can change the value to ESTIMATOR_MODE_ENC to select the Encoder estimator for sensored-FOC. And also the user can change the value to switch the using estimator on the fly.