B.2 MATLAB® Code for the Predictive Torque Control Simulation

The predictive controller was implemented using an embedded MATLAB function block (block 4 in Figure B.1). It is important that this block is configured to operate at the sampling time defined for the predictive algorithm in the previous section. Also, some of the arguments of the control function should be defined as inputs while the rest correspond to parameters. Both configurations can be easily done using the Simulink model explorer.

The control algorithm, which was explained in Section 8.4, is presented in Code B.2. The first line in the code declares the control function, where the outputs are the gating signals Sa, Sb, and Sc. The inputs of the algorithm are the torque and flux references (T_ref and sflux_ref) and the measured rotor speed and stator current (wm and i_meas). The remaining arguments of the function correspond to parameters required for the predictions and output state selection.

The PTC algorithm requires two variables to be recalled from the previous sampling instant: the optimum voltage vector selected by the algorithm (x_opt) and the stator flux estimate (Fs). These variables are used to estimate the stator flux, according to (8.18). Lines 4 to 6 are used to declare these persistent variables and to initialize their values, whereas the stator flux (Fs) is estimated in line 8. The rotor flux is also estimated, according to (8.22), in line 10.

The prediction–optimization procedure is performed ...

Get Predictive Control of Power Converters and Electrical Drives now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.