Reusable function error with Matlab 2020a and MBDT v4.2

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

Reusable function error with Matlab 2020a and MBDT v4.2

1,164 Views
jimfreudenberg
Contributor I

Hi, All -- We are trying to generate multitasking code for the S32K144 using Matlab 2020a and MBDT v 4.2. This is for the purpose of teaching an embedded control class, which enrolls over 200 students/year at the University of Michigan and ETH Zurich

We want the multitasking code in separate functions --- but when we check "Reusable Function", we get error messages. This feature works fine without the Toolbox -- it is only when the MBD Toolbox is used that we get errors. And it seems to be specific to version 4.2 -- we believe it also worked with version 4.1.

yesterday we discovered that the problems arise when we are receiving input from the FlexTimer quadrature decode blocks. When we replace these blocks with inputs from ADCs everything is OK again.

I have attached here a zip directory with the models that worked, the ones that did not work, and the error messages. Also, I have pasted below the message from the teaching assistant, Paul Young, who did this work. his email is plyoung@umich.edu.

from Paul:

I looked into this a bit more during my open lab hours today. It appears there is a problem with the quadrature decode block being used in conjunction with "reusable function" subsystems. A quick walkthrough of my methodology is below:


Took the solution code two_virtual_wheel.slx model from gitlab and changed both triggered subsystems to "reusable functions".
Attempted to build code and got an error message that I saved to a text file.
Created a duplicate model that is exactly the same, except instead of using the quadrature decode block to create the angle input, it uses an ADC block.
Successfully built code with the modified model (two_virtual_wheel_adc.slx) and saved the diagnostics viewer output to a text file.
Zipped up the entire matlab workspace including both models, the auto-generated code, and the two diagnostics logs.

 

Thanks!

 

Jim

0 Kudos
4 Replies

1,048 Views
jimfreudenberg
Contributor I

Hi, and thank you for your help!  It has taken us along time to respond because oyr students are very busy with the end of the semester.

Selecting "Reusable Function" no longer causes an error -- thanks again!

However, we also (see attached screenshot1) want to select two additional options so that the nerated code has functions in separate files (see screenshot2). Unfortunately, thos causes erros again.

these screenshots are from the instructions that we give students, so they can see how to customize code to improve readability, and it would be great if they would work -- it appears as though additional fixes are need though.

It would be great of you could help us out again, and thanks in advance!

Jim

0 Kudos

1,117 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @jimfreudenberg 

I am sorry for my delayed answer, I might have missed this community post. 

You are right, the issue comes from the quadrature decoder block. For some of our blocks, like FTM we generate dedicated C source files and headers for declaring the configuration structures for peripherals. The issue comes from including the model_private.h header in some of them. 

For this particular case, I have removed the include line from the generated code and on my machine, the model which is using qd builds successfully. I have attached a tlc file that must be replaced in our toolbox ( please backup it first). 

To do so, please type the following command in Matlab: winopen(fullfile(mbd_find_s32k_root, 'mbdtbx_s32k\blocks\ftm')) This will open the exact file location of where the attached tlc must be replaced. Please give it a try.

For now, I've only added the qd file but most likely we might have to change all FlexTimer blocks with this fix. 

Hope this helps,

Marius

0 Kudos

922 Views
bryan_brauchler
NXP Employee
NXP Employee

Hi @mariuslucianand 

 

I spoke with Jim today, and he is still seeing this bug. I was able to reproduce on my end as well. Here are the settings for the sub-module where I observe the error:

bryan_brauchler_1-1631055658349.png

 

From a glance it looks like a include order issue:

bryan_brauchler_0-1631055633582.png

The types rtB_FastDynamics_two_virtual__T and rtDW_FastDynamics_two_virtual_T are defined in FastDynamics.h. Do you have any advice to correct this behavior?

 

Best,

Bryan

0 Kudos

916 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @bryan_brauchler ,

Have you tried applying the "patch" delivered previously in my response and do you still have this error? Can you send me the model, please? (You can send it in private) 

Regards,

Marius

0 Kudos