MBDT Fuzzzy Logic Controller

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

MBDT Fuzzzy Logic Controller

Jump to solution
721 Views
C_Zuercher_APR
Contributor III

Hi,

 

I'm having some issues with deploying code onto the MPC5744P DEVKIT Board when using the Simulink Fuzzy Logic Control block.

When I comment through the Fuzzy Logic Control block, the code deploys perfectly fine and works as expected. However, when I leave the block in (as attached), the code deploys however there's no activity on the CAN Bus (as ascertained through PCAN-View) and the PWM Output remains at the initial value set in the PWM Config block.

 

Can anyone help with this?

Thanks in advance.

Attached are:

- Simulink Model

- DBC File

- FIS File (for Fuzzy logic System)

 

 

0 Kudos
1 Solution
710 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @C_Zuercher_APR ,

The problem is caused by the Fuzzy block which inserts the variable declaration code inside our step function. The variables' sizes are so large that it causes a stack overflow.

mariuslucianand_0-1612358999462.png

There are two ways of solving this.

1. One of them is to try forcing the block to declare the variables from lines 310 to 323 as global so as they do not end up on the stack, on each step function execution. I've tried that but I was not successful so you should consider contacting MathWorks Support. I am sure that they can help you with this.

2. You can use a custom linker file that contains an increased stack size. This is the faster workaround for your scenario. I have attached the linker file with a higher stack size.

Let me show you how to install and use this linker file.

a. in Matlab, type the following command:

 cd(fullfile(mbd_find_mpc_root, '\mbdtbx_mpc574x\src\linker\gcc'))

This will change the directory to where the linker files are stored. In this folder, you should copy the attached  MPC5744P_flash_IncStack.ld file.

mariuslucianand_1-1612359890216.png

b. In your model,  Open the main config block. Go to "Build Toolchain", uncheck the "Default linker..." and select the newly added file. 

mariuslucianand_2-1612360056954.png

If the added linker is not displayed there, just replace the 'MPC5744P_flash.ld' with the one attached.

Hope this helps,

Marius

View solution in original post

2 Replies
705 Views
C_Zuercher_APR
Contributor III

Hi Marius, that's great thank you!

 

Appears to work great now.

 

Thanks,

 

Crispin

711 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @C_Zuercher_APR ,

The problem is caused by the Fuzzy block which inserts the variable declaration code inside our step function. The variables' sizes are so large that it causes a stack overflow.

mariuslucianand_0-1612358999462.png

There are two ways of solving this.

1. One of them is to try forcing the block to declare the variables from lines 310 to 323 as global so as they do not end up on the stack, on each step function execution. I've tried that but I was not successful so you should consider contacting MathWorks Support. I am sure that they can help you with this.

2. You can use a custom linker file that contains an increased stack size. This is the faster workaround for your scenario. I have attached the linker file with a higher stack size.

Let me show you how to install and use this linker file.

a. in Matlab, type the following command:

 cd(fullfile(mbd_find_mpc_root, '\mbdtbx_mpc574x\src\linker\gcc'))

This will change the directory to where the linker files are stored. In this folder, you should copy the attached  MPC5744P_flash_IncStack.ld file.

mariuslucianand_1-1612359890216.png

b. In your model,  Open the main config block. Go to "Build Toolchain", uncheck the "Default linker..." and select the newly added file. 

mariuslucianand_2-1612360056954.png

If the added linker is not displayed there, just replace the 'MPC5744P_flash.ld' with the one attached.

Hope this helps,

Marius