This section verifies the position PI
module and position loop. For this loop to work properly, the speed loop must have
been completed successfully. When the motor is commanded to run, it is subjected to
an initial alignment stage where the electrical angle and the position encoder angle
count are set to zero. After ensuring a stable alignment, the motor starts to
run.
- Open fcl_f2838x_tmdxiddk_settings_cpu1.h and select the
level 5 incremental build option by setting the BUILDLEVEL to FCL_LEVEL5
(#define BUILDLEVEL FCL_LEVEL5).
- The current loop regulator can be
selected to be PI controller or complex controller by setting FCL_CNTLR to
PI_CNTLR or CMPLX_CNTLR.
- Select CURRENT_SENSE method to
LEM_CURRENT_SENSE.
- Select POSITION_ENCODER to
QEP_POS_ENCODER or T_FORMAT_ENCODER depending on the encoder coupled to
motor.
- Select SAMPLING_METHOD to SINGLE_SAMPLING or DOUBLE_SAMPLING.
If a T-format encoder is used, select SINGLE_SAMPLING and no more than 10 KHz
PWM frequency. For more information, see Section 5.1.3.3.
- Right-click on the project name,
and then click Rebuild Project. When the build is complete, click the
Debug button, reset the CPU, restart, enable real-time mode, and
run.
The key steps are explained as
follows:
- Set enableFlag to 1 in the watch window. The
isrTicker variable is incrementally increased as seen in the watch
windows to confirm the interrupt is working properly.
- Add variables pi_pos, posArray, ptrMax,
and posSlewRate to the Expressions window.
- Gradually increase voltage at variac to get an appropriate
DC-bus voltage.
- Set runMotor to MOTOR_RUN to run the motor. The motor
must be turning to follow the commanded position (see the following note if the
motor does not turn properly).
- The motor runs through
predefined motion profiles and position settings as set by the
refPosGen() module. This module basically cycles the position reference
through a set of values as defined in an array posArray. These values
represent the number of the rotations and turns with respect to the
initial alignment position. Once a certain position value as defined in
the array is reached, it pauses for a while before slewing toward the
next position in the array. Therefore, these array values can be
referred to as parking positions. During transition from one parking
position to the next, the rate of transition (or speed) is set by
posSlewRate. The number of positions in posArray through which it passes
before restarting from the first value is decided by ptrMax. Hence, add
the variables posArray, ptrMax, and posSlewRate to the Expressions
window.
- The parking positions in posArray can be changed to
different values to determine if the motor turns as many rotations as set.
- The number of parking positions ptrMax can also be
changed to set a rotation pattern.
- The position slew rate can be changed using
posSlewRate. This rate represents the angle (in pu) per sampling
instant.
- The proportional and integral gains of the speed and position
PI controllers may be returned to get satisfactory responses. TI advises to
first tune the speed loop and then the position loop.
- Bring the system to a safe stop by reducing the bus voltage,
taking the controller out of real-time mode and reset. Now the motor stops.
Figure 10-1 shows the implementation block diagram.
In the scope plot shown in Figure 10-2, the position reference, and position feedback are plotted. They are aligned with
negligible lag, which may be attributed to software. If the Kp and Ki gains of the
position loop controller are not chosen properly, this may lead to oscillations in
the feedback or a lagged response.
Note:
- If the motor response is erratic, then the sense of turn
of the motor shaft and the encoder may be opposite. Swap any two phase
connections to the motor and repeat the test.
- The position control implemented here is based on an
initial aligned electrical position (= 0). If the motor has multiple pole
pairs, then this alignment can leave the shaft in different mechanical
positions depending on the prestart mechanical position of the rotor. If the
mechanical position repeatability or consistency is needed, then the QEP
index pulse must be used to set a reference point. This may be taken as an
exercise. With an absolute encoder, this may be obvious.