run real-凯发k8网页登录
this example shows how to run a real-time simulation of a permanent magnet synchronous motor (pmsm) that is externally controlled at high switching frequency. the real-time application runs on a speedgoat® target computer that has an io334 i/o module installed. to open the models in this example and build the real-time application requires these products:
matlab®
simulink®
simulink coder™
simulink real-time™
simulink real-time target support package
speedgoat i/o blockset
speedgoat hdl coder™ integration package
speedgoat io334-325k i/o module with io334-21 plugin
hdl coder is required for design customizations.
you can use the simulink real-time model and its corresponding bitstream file to simulate a permanent magnet synchronous motor system that is externally controlled in closed-loop at high switching frequency (100khz) with sufficiently small time step (50 nanoseconds).
simulink model for permanent magnet synchronous motor system
the permanent magnet synchronous motor system model is a physical system in simulink. the system consists of three components, an inverter block, a permanent magnet synchronous motor block, and an incremental encoder block. the hdl-compatible simulink implementation of the subcycle-averaging inverter block reads the pwm duty-cycle from "gates" inport and dc voltage input from "v_plus" and "v_minus", and outputs the line voltages from outport "vll_abc". you can set its fault flag from fault_word port.
the permanent magnet synchronous motor block is an hdl coder compatible implementation of a three-phase exterior permanent magnet synchronous motor (pmsm) with sinusoidal back electromotive force. it takes the input line voltage from the subcycle-averaging inverter block and outputs shaft angular velocity, shaft angular position, three phase currents, and motor torque. this block can also take an external speed or torque as input.
the simulink implementation of quadrature encoder converts the angular position of the motor shaft to digital pulses. to see more details, open the model:
model = 'slrt_ex_pmsm'; open_system(fullfile(matlabroot,'toolbox','slrealtime','examples',model));
set_param(model, 'simulationcommand', 'update');
load_system('slrt_ex_pmsm') open_system('slrt_ex_pmsm/motor and inverter hdl wrapper/motor and inverter mathmatical models')
this model verifies the three-phase output currents and encoder's digital signals resulting from the input torque signal. to see how the model works, simulate the model.
sim(model);
real-time simulation
this example also provides the corresponding simulink real-time interface model and the bitstream generated by using the hdl workflow advisor, which you can download to a speedgoat fpga i/o 334-21 target.
model_gm = 'slrt_ex_pmsm_gm'; open_system(fullfile(matlabroot,'toolbox','slrealtime','examples',model_gm));
1. reconfigure the parameters for pmsm system to your values from the pmsm configuration block mask.
2. make sure that the development computer has a connection to the target computer.
3. make sure that the bitstream file is in your working folder, build the model, and download the real-time application to the target computer. on the real-time tab, click run on target. or, use the slbuild
command and the load
command.
4. run the real-time application by using the run on target button.
5. open the simulation data inspector by double-clicking the simulation data inspector icon or by using the simulink.sdi.view
command.
more information
the fpga bitstream file motorandinverterhdlwrapper.mcs
is available in the simulink real-time examples folder.
cd(fullfile(matlabroot,'toolbox','slrealtime','examples'))
for the motor control blockset version of this example that demonstrates hardware-in-the-loop (hil) simulation of pmsm, see (motor control blockset).
close all open files
bdclose all;