Sensorless Control of Permanent Magnet Synchronous Motors (PMSM) powered by ROM and Machine Learning.


Overview

(This is a translated version of an article posted by Kosuke Ikeda. The original article in Japanese can be found here)

In this article we will discover how AI can be leveraged in the field of power electronics, using the sensorless control of permanent magnet synchronous motors (PMSMs) as an example.

Using Altair romAI, a machine learning-based modeling tool, we created a dynamic nonlinear reduced order model (ROM) that predicts the angular velocity and the rotor angle based on the DQ motor currents and DQ reference voltages values (Id, Iq, Vd_ref, Vq_ref).

Image

The generated ROM was then integrated with the PMSM motor drive from Altair's power electronics software, PSIM. In this manner, instead of using the actual angular velocity and angle of the rotor, the motor is controlled by the predicted angular velocity and angle of the rotor from the ROM.

Image

As we can observe from the graph bellow, the rotor speed (wm, green) follows the target speed (wm_ref, red) quite well, and the predicted rotor speed (wm_rom, blue) is almost identical to the actual rotor speed (wm, green).

Thus we can confirm that the sensorless control is possible using the angular velocity and the angular position predicted by the romAI model.

Image

Pre-Requisite

For this model the following software is used:

Altair PSIM: Motor Control and Power Electronics for PMSM

Altair Twin Activate: To integrate and perform the system simulation between the power electronics and the ROM

romAI: For the creation of reduced order motor models (ROMs)

Altair HyperStudy: To run the DoE of the PSIM model

Altair Compose: To Pre-process the results data to be used into romAI

We will also use the PSIM-HyperStudy Connector (coming soon on 2024.0) to connect PSIM with HyperStudy.

 

The complete set of models used in this article can be downloaded from the following link:

Attached model files

Usage/Installation Instructions

1. Model

Folder: 01_training_model

PSIM comes installed with various helpful demo examples. In this case, we used the pmsm-pwm.psimsch model, which deals with the field oriented control of a PMSM.

In order to generate data on different target speeds, the target speed wm_ref is parameterized on PSIM side.

In addition, we add the related outputs to save the data that will be later used for training the romAI model.

pmsm - pwm_param.psimsch  found in attached model files

Image

 

2. Generate training data

Folder: 02_generate_training_data

2-1. Automatic Simulation Execution by using the PSIM-HyperStudy connector

Folder: 02_generate_training_data/hst

The PSIM - HyperStudy connector allows us to run multiple PSIM simulations in an automated way. As an alternative automated method, one could use the Parameter Sweep functionality directly inside PSIM, but the HyperStudy coupling has the following advantages:

  • Easily manage multiple input parameters
  • Analyzing Input-Output Relationships by Setting Output Responses
  • Automatic creation of execution matrices using the design of experiments method
  • Response Surface Creation
  • Various Optimization algorithms available

The PSIM-HyperStudy Connector (coming soon on 2024.0) makes it easy to integrate PSIM with HyperStudy.

After the coupling software is installed the steps are pretty straightforward:

First, we need to define the PSIM model in HyperStudy

Next we need to import the variables that we want to import and modify from the PSIM model by following the steps pictured below

After the import process, the selected variables are populated in the "Define Input Variables" tab. In this case, we only chose to import the reference angular velocity (wm_ref), and at this stage, we can define the different wm_ref values we want to test.

In this stage, we want to perform a check that all of the 11 cases have reached steady state sucesfully. In effect, the last speed value of the time domain data should have a small error versus the target speed. To verify that we can create some custom expressions on the Output Responses Tab.

We then define the DoE with a total of 11 runs by varying the target speed from 110 rad/s to 210 rad/s.

After the analysis is executed the time domain responses from the 11 runs are saved automatically in a structed format, as well as the custom error outputs defined on the previous step.

Going into the Post-processing tab we plot on the horizontal axis the target speed, and on the vertical axis the actual rotor speed and error. As we can observe, the standard motor control looks good at a first glance. Since the error is quite small on all cases, we can confidently state we have reached steady state.

2-2. Data processing using Compose

Folder: 02_generate_training_data/compose

Each PSIM time-domain results from the HyperStudy DoE are saved as .txt files. To use it as training data for romAI, we need to convert them into a csv format.

We also want to merge the results of all 11 cases into one single csv file.

Altair Compose is an environment for doing math calculations, manipulating, and visualizing data, etc., that uses the Open Matrix Language. We will use 2 scripts with it to easily pre-process the data.

 

stc_txt2csv.oml

This is a script that converts PSIM text result files to csv.

If you change the path and file name in lines 6 to 9, you can use it for any PSIM-HyperStudy results files.

When the script is executed, it will generate a .csv file inside each folder run by HyperStudy.

Image

 

stc_merge_PSIM_results.oml

This script copies the .csv files in each folder calculated by the HST DoE to the data folder and then merges them into a single .csv file.

By modifying the path and file name in lines 5 to 8, you can use it for any PSIM-HyperStudy results file.

Image

 

3. Creating ROMs using romAI

Folder: 03_create_rom

Using romAI, we will create a non linear dynamic reduced order model based on the training data we previously generated (merge.csv)

romAI is included with the Twin Activate installation so to use it you just need to enable it from the extension manager.

The merge.csv was loaded into the romAI Director GUI , and the inputs, outputs, and state variables were set as follows.

Inputs: Id, Iq, Vd_ref, Vq_ref (motor current and reference voltage value)

Output: wm, int_wm (rotor speed, rotor angle)

State variables : wm, int_wm (rotor speed, rotor angle)

Next the neural networks hyperparameters are kept as default with the only exception being the number of epochs:

Activate Function: relu

Hidden Layers: 2

Neurons: 20 x 20

Epochs: 30

Image

Even though the model architecture may be the same, every time we train a new romAI model the initial conditions change randomly, so a different model is generated. Using the Repetition functionality under the Auto Exploration checkbox we train sequentially multiple models and can then pick the one that performs the best.

For this example, we run specified the repetition to 10 iterations and picked the 7th one with the smallest Test loss, indicating a more accurate and robust model.(Note: Test loss is calculated on a portion of the data excluded from training defined on "Test Split Ratio" option ,so a low Test loss indicates good generalization capability and high accuracy)

Image

4. Sensorless control simulation using ROM

Folder: 04_deploy_test

PSIM's PMSM motor control model performs the control using the actual rotor speed and rotor angle. We will replace these inputs with romAI's predicted outputs and check whether the sensorless control scheme is possible.

pmsm-pwm_param_cosim.psimsch

Next we need to add into PSIM the In Link Nodes / Out Link Nodes from the SimCoupler module. These will act as communications ports with Twin Activate and thus romAI. More info regarding SimCoupler usage can be found here: SimCoupler Tutorial

It's important to notice that the measured rotor speed and rotor angle in the following image inside PSIM are not used directly for the control but only used for evaluation purposes. Thus we need to assign a different name for those outputs.

Image

 

 

In this step we couple the PSIM and romAI models in our systems integration platform Twin Activate.

activate_rom_psim.scm

In Twin Activate we deploy the PSIM model on the co-simulation block and the generated romAI model. We then connect them as pictured bellow so that the predicted outputs of romAI are the inputs to PSIM block.

Image

We can then perform the whole co-simulation by clicking the Run button in Twin Activate. The results in PSIM format can be opened as usually. As we can observe from the graph bellow, the actual rotor speed (wm, green) follows the target speed (wm_ref, red) quite well, and the predicted rotor speed (wm_rom, blue) is almost identical to the actual rotor speed (wm, green). (Note that wm corresponds to wm_psim which is the actual speed measurement)

Target speed (wm_ref) 170 rad/sec

Image

 

Additionally we test at a different Target speed (wm_ref) set to 110 rad/sec and check the results:

Image

From these results we confirmed that a sensorless control scheme is possible using the rotor angular velocity and rotor angle position predicted leveraging AI (romAI).

By combining this workflow with the existing sensored control schemes that use feedback, it may be possible to improve the total accuracy and employ it for control at low speeds and/or during startup. 

Many thanks to Nikos Dimitrakopoulos for assisting with the translation of the original article posted by Ikeda-San. (Original article in Japanese)

Post-Requisite

Check out a relevant HyperStudy-PSIM application regarding Motor Drive decision making here:

Insights into Motor Drive Design: Analyzing Trends and Long-Term Costs with PSIM and HyperStudy - HyperStudy, PSIM - Altair Products - Altair Community

 

If you are interested in more applications regarding romAI check out these links:

romAI: How to speed-up DEM simulations leveraging Artificial Intelligence - - Engineering Data Science - Altair Community

Application Of romAI for Stress and Load Prediction From Strains - - Engineering Data Science - Altair Community

Combining AI and simulation for efficient bulk solids handling optimization - - Engineering Data Science - Altair Community

When Artificial Intelligence (AI) shakes hands with Modern Control Theory - - Engineering Data Science - Altair Community

romAI: generation of a dynamic Reduced-Order Model (ROM) using AI for linear actuators - - Engineering Data Science - Altair Community

How to speed up truck handling simulation using Artificial Intelligence? - - Engineering Data Science - Altair Community

An AI-Augmented Multiphysics approach to speed up the analysis of a Solenoid Valve - - Engineering Data Science - Altair Community