# Parameterize a Permanent Magnet Synchronous Motor

This example shows how to estimate the back EMF and torque constants of a blackbox permanent magnet synchronous motor (PMSM) with an unknown flux linkage. You can use either the back EMF or torque constant to describe the flux linkage and parameterize a Simscape™ Electrical™ PMSM block. This parameterization allows you to accurately replicate the blackbox motor's behaviour in simulation.

In this example, the number of pole pairs, stator resistance and stator inductances of the simulation and blackbox PMSMs are already specified to match.

### Open Model

Open the model.

model='ee_pmsm_parameterization'; open_system(model) set_param(find_system('ee_pmsm_parameterization','FindAll', 'on','type','annotation','Tag','ModelFeatures'),'Interpreter','off')

### Set Back EMF Constant

Select the back EMF parameterization option for the simulation PMSM and initialize its value to an arbitrary default value of 0.1 V*s/rad.

Simulation_PMSM = [model,'/Simulation PMSM']; Ke = 0.1; set_param(Simulation_PMSM,'pmflux_param','3');

Alternatively, you can set the back EMF parameterization option and specify its value from the PMSM block mask by selecting **Specify back EMF** under **Permanent magnet flux linkage parameterization** and specifying **Back EMF constant**.

### Compare Results

Simulate the model and plot the voltage over time across the a-winding for both the experimental and simulation PMSMs. Observe that there is a significant difference in voltage amplitude between the experimental and simulation PMSMs.

sim(model); v_a_exp = simlog_ee_pmsm_parameterization.v_Ra_exp.V; v_a_sim = simlog_ee_pmsm_parameterization.v_Ra_sim.V; simscape.logging.plot({v_a_exp,v_a_sim},... 'names',{'Experimental PMSM','Simulation PMSM'}); title('Voltage across a-winding') ylabel('Voltage, V');

### Calculate Voltage Constant

Calculate the voltage constant of the blackbox experimental PMSM by using the defining equation

,

where is the angular velocity of the PMSM shaft, and is the voltage drop across the a-winding of the motor. This equation is valid only when the current through the windings is very small. The small current restriction is enforced in the model by attaching each of the winding free ends to ground via a very high resistance, effectively making each winding an open-circuit.

is calculated by taking the average of the maximum and minimum values of the voltage drop across the a-winding, and dividing the result by two. You can improve the accuracy of this calculation by first filtering out the high frequency noise of the measured voltage signal:

window_size = 100; v_a_exp_filt = filter(1/window_size*ones(1,window_size),1,v_a_exp.series.values); v_a_exp_peak = (max(v_a_exp_filt)-min(v_a_exp_filt))/2;

The angular velocity can be measured directly from the source block:

angular_velocity_exp = mean(simlog_ee_pmsm_parameterization.Experiment_Angular_Velocity_Source.w.series.values);

The back EMF constant can now be calculated from the above results:

Ke = v_a_exp_peak / angular_velocity_exp; disp(Ke);

0.1803

### Change Back EMF Constant

Change the back EMF constant for the simulation motor to the estimated value , calculated in the previous section.

Simulation_PMSM = [model,'/Simulation PMSM']; set_param(Simulation_PMSM,'pmflux_param','3');

### Compare New Results

Resimulate the model and plot the voltage across the a-winding. The new parameterization of the voltage constant improves the simulation PMSM's ability to replicate the behaviour of the experimental PMSM.

sim(model); v_a_exp = simlog_ee_pmsm_parameterization.v_Ra_exp.V; v_a_sim = simlog_ee_pmsm_parameterization.v_Ra_sim.V; simscape.logging.plot({v_a_exp,v_a_sim},... 'names',{'Experimental PMSM','Simulation PMSM'}); title('Voltage across a-winding') ylabel('Voltage, V');

### Calculate Torque Constant

Calculate the torque constant of the blackbox PMSM using the defining equation:

,

where is the peak current through the a-winding and is the overall mechanical torque driving the PMSM.

i_a_exp = simlog_ee_pmsm_parameterization.Ra_exp.i; i_a_sim = simlog_ee_pmsm_parameterization.Ra_sim.i; T = abs(mean(simlog_ee_pmsm_parameterization.Experiment_Angular_Velocity_Source.t.series.values)); window_size = 100; i_a_exp_filt = filter(1/window_size*ones(1,window_size),1,i_a_exp.series.values); i_a_exp_peak = (max(i_a_exp_filt)-min(i_a_exp_filt))/2; Kt = 2/3*T/i_a_exp_peak; disp(Kt); simscape.logging.plot({i_a_exp,i_a_sim},... 'names',{'Experimental PMSM','Simulation PMSM'}); title('Current across a-winding') ylabel('Current, A');

0.1797

### Compare Flux Linkage Parameterizations

As expected, the measured torque and back EMF constants have approximately the same value (0.18) and are related to the permanent magnet flux linkage via the number of pole pairs of the motor:

You can parameterize the permanent magnet flux linkage of the motor by specifying any of , or in the Simulation PMSM block mask. Back EMF and torque constants are more commonly given than permanent magnet flux linkage on motor datasheets.

### Learn More

See the PMSM block page for more information.