PMSM Motor Control using NXP Model-Based Design Toolbox

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PMSM Motor Control using NXP Model-Based Design Toolbox

834 Views
Simao
Contributor I

 

Hello NXP Community, 

I am trying to spin a PMSM motor using your Motor Control algorithms with Simulink, Embedded Coder and Model-Based Design Toolbox for S32K3xx, based on the NXP webinar for the S32K3xx family:

https://www.nxp.com/design/training/a-model-based-design-mbdt-environment-for-motor-control-algorith...

But I am having several issues (which I describe below). IOI was hoping you could please give me some pointers to overcome it and get the motor running.

 

I am using MATLAB 2022b and S32 Design Studio 3.5.

Regarding RTD and MBDT, I am using S32K3 Real-Time Drivers AUTOSAR 4.4 Version 2.0.1 in S32 Design Studio, but the SW32K3_RTD_4.4_2.0.0 is delivered with the toolbox. Model-Based Design Toolbox for S32K3xx 1.2.0 is being used, all downloaded from NXP website.

The EVB that is being used for test purposes is the S32K312-Q172 (I also have tried with the S32K344-Q-172). (These are "generic" EVBs; not the one with the small Brushless motor, because that seems to be unavailable). 

After installing MATLAB and the needed Add-Ons, we executed a toolbox script to generate the appropriate settings for the installation environment, as indicated in the Model-Based Design Toolbox quick start guide for the S32K3xx.

Next, using the example for the Dio project, I was able to generate, build and deploy the Code in the S32K312-Q172 EVB with success, and this way assure that the configurations needed were performed correctly.

 

In the next step I have selected the PMSM Motor Control example from Simulink, using Library Browser.

Simulink ModelSimulink Model

 

In the hardware-part selection window configuration, I chose the correct EVB, as you can see below, and the configuration process is using S32 Design Studio as the configuration tool instead of EB Tresos.

Hardware-Part SelectionHardware-Part Selection

 

When I try to generate, build and deploy the Code into the EVB, during the build process, Simulink gives a rebuild reason and several errors as you can see below:

Code Generation Information file does not exist”:

Diagnostic ViewerDiagnostic Viewer

Error 1/2Error 1/2

Error 2/2Error 2/2

 

I have also tried other examples, such as PWM, on the same EVB that work properly.

 

I would like to understand:

- Can the newer version of the Real Time Drivers cause some incompatibility issues with the motor control lib example?

- The error that I have is related with the provided example? (if this is true, can you provide the correct example for the EVB in consideration?)

- Do I need to perform any other action, besides the ones that I already did, in order to get the example working using EVB's S32K312-Q172 or S32K344-Q-172?

- I have also found an existing post that I thought it could help me, but I can't reach step 2, since the build is not successful. (NXP Post: https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/Export-generated-projects-in-MBDT-for-s... )

 

Note:

Please note that the goal here is to use sensorless FOC (we have a circuit with 3 phase current shunts if that can be used), but we do not want to use FOC with Hall sensors. (Hall sensors are excluded from our application).

 

With Best Regards,

Simão Serrano

Labels (1)
2 Replies

752 Views
Irina_Costachescu
NXP Employee
NXP Employee

Hi @Simao ,

Please note that the PMSM example delivered within MBDT for S32K3 v1.2.0 is designed specifically for the S32K344-Q257 processor, having a EB Tresos custom configuration project associated to it. For more details on what MBDT custom or default configuration projects mean and how they are used for applications development, please check the details provided in this thread.

Now, to address the mentioned questions specifically:


1. MBDT for S32K3 uses the RTD delivered within the package for building the models and creating the executable files which are downloaded on the target. So, the step of building the model in the Simulink environment should not be affected by the packages installed in S32DS - they are independent application development environments.

2. If the other S32K312 examples were able to be built and downloaded on the target without any issues, then the problem you are facing might be related only to the PMSM example indeed.

3. As previously mentioned, I think that the error occurs because the PMSM example is designed specifically for the S32K344-Q257 part, using an EB Tresos configuration. When you change the Hardware Part - to S32K312-Q172 EVB, and also the configuration tool to S32CT, the default configuration project corresponding to this part (S32K312) will be used by the model. However, this S32K312 configuration does not contain all the setting necessary for a motor control application. Currently MBDT does not provide motor control examples on S32K312, hence, to fit the particularities of your application, you would need to update the project in the chosen external configuration tool.

Hope this helps,
Irina

0 Kudos

663 Views
Simao
Contributor I

Hello @Irina_Costachescu first of all thank you for your reply, I hope you are well.

After your reply I tried to run again the PMSM example to be able to generate C code. Since the example is designed specifically for the S32K344-Q257 microcontroller, in the target hardware resources in simulink I selected that microprocessor as my target and EB tresos as the configuration tool as we can see in the following pictures:

hardware_part_select.PNGTool_select.PNG

 

After trying to generate and deploy the code in my EVB, I get the following error:

after_build.PNG

 

Next, I tried to open the configuration in EB tresos in order to change the configurations in the tool to see if it could solve my problem and an error that I got in the Block Parameters: "Hardware_Interrupt_Handler2" saying that all callbacks are NULL_PTR

NULL_Callbacks.PNG

EB tresos was able to open the project configuration, but after the use of the tool, we must refresh in order to update the configurations, and I got the following error:

Error_on_RefreshConfiguration.PNG

 After the "ebtOpen" error show, I press ok, and simulink stays forever analyzing the Tresos Project as you can see:

analyzing forever.PNG

I will also attach the log errors that I got from the MATLAB console.

 

In conclusion I cannot get the C code generated nor update the project configurations in EB tresos. 

What should I do next, just to get a clean project build and to be able to generate C code?

 

With best regards,

Simão Serrano

0 Kudos