S-function compiling issue with AMCLIB

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

S-function compiling issue with AMCLIB

Jump to solution
3,045 Views
ruonanzhou
Contributor II

Hello,

We are using the AMCLIB(Automotive and Motor Control Library) in our application code in C, and trying to develop a SIL testing the application code. We use a S-function in Simulink to call the application code. However, the library seems to be written in assembly and when we included the library for the s-function, Matlab had compiling issue with the library.

I'm wondering if the library actually can be run on a windows machine since it's in assembly, and if there's a way to use AMCLIB in SIL.

Thank you very much:)

Ruonan

Tags (2)
0 Kudos
Reply
1 Solution
2,515 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi ruonanzhou‌,

Sorry for delay - i also had some issues until i managed to make it work.

Please find attached a zip file with the entire setup to work on SIL.

A few details about how it works:

The harness model is: AMMCLIB_Simulink_Example.slx

pastedImage_1.png

This harness model is using the SIL_model.slx that implements the S-Function

pastedImage_2.png

The S-Function is used to call the following function:

pastedImage_3.png

The function implementation is:

pastedImage_4.png

The SIN/COS functions implementation is within the AMMCLIB.lib that is linked with the S-Function

pastedImage_5.png

Ideally you will need to have the AMMCLIB source file in order to build the AMMCLIB.lib for the Microsoft SDK 7.1 compiler. Since you do not have it in source file format, you could use one of the latest toolboxes from MBDT: Model Based Design Toolbox for S32K14x Automotive MCU rev2.0 - Is NOW Available!  or Model Based Design Toolbox For Panther (MPC574xP) Family of Processors 2.0 IS NOW AVAILABLE!  to get it. It could be found under: ...\AMMCLIB_s32k14\lib\ folder precompiled for x64 or x86

For convenience you have it int he demo as x64 flavor.

If your simple run (not build) the model attached you should expect the following results:

pastedImage_3.png

Hope this will help you!

Best regards,

Daniel

View solution in original post

10 Replies
2,515 Views
ruonanzhou
Contributor II

Hello Daniel,

I would like to make a small correction. All of the hand written code are in C. The problem is the AMCLIB functions we use in our code.

For example, we have a function to calculate the sine and cosine of an angle input.

void SinCosCal(const tFloat angle)
{
tFloat sinOut, cosOut;
sinOut = GFLIB_Sin_FLT(angle,GFLIB_SIN_DEFAULT_FLT);
cosOut = GFLIB_Cos_FLT(angle,GFLIB_COS_DEFAULT_FLT);
}

And in matlab s-function builder, we built an s-function simply call this function. However, the s-function builder has trouble building the function due to GFLIB_Sin_FLT and GFLIB_Cos_FLT even when we includes the header files for those two functions the library setting for that s-function.

The GFLIB_Sin_FLT and GFLIB_Cos_FLT functions are from library MPC564xL_AMMCLIB.a, and that's why we think the assembly code give us trouble on compiling it on a PC.

Please let us know if you have any suggestions or further questions. Thank you very much for your help.

Ruonan 

0 Kudos
Reply
2,515 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi ruonanzhou‌,

In order to support your use-case you will need a AMMCLIB library build for x86/x64 in order to allow the Matlab to simulate the operations. 

Do you have the source files version for the MPC564xL_AMMCLIB_v1.1.9 ?

If so, i could give you instructions how to rebuild the library with the Microsoft Windows SDK 7.1 in order to obtain the AMMCLIB library version needed for the execution the simulation under Matlab.

If you don't have the source files - all i can give your is an hack based on an existing library within S32K Model Based Design toolbox - which could be reused for MPC564xL as a workaround.

Best regards,
Daniel

0 Kudos
Reply
2,515 Views
ruonanzhou
Contributor II

Hello Daniel,

No we don't have the source files. I guess we need to go with the second solution:)

Could you please provide with more details on it?

Thank you,

Ruonan

0 Kudos
Reply
2,516 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi ruonanzhou‌,

Sorry for delay - i also had some issues until i managed to make it work.

Please find attached a zip file with the entire setup to work on SIL.

A few details about how it works:

The harness model is: AMMCLIB_Simulink_Example.slx

pastedImage_1.png

This harness model is using the SIL_model.slx that implements the S-Function

pastedImage_2.png

The S-Function is used to call the following function:

pastedImage_3.png

The function implementation is:

pastedImage_4.png

The SIN/COS functions implementation is within the AMMCLIB.lib that is linked with the S-Function

pastedImage_5.png

Ideally you will need to have the AMMCLIB source file in order to build the AMMCLIB.lib for the Microsoft SDK 7.1 compiler. Since you do not have it in source file format, you could use one of the latest toolboxes from MBDT: Model Based Design Toolbox for S32K14x Automotive MCU rev2.0 - Is NOW Available!  or Model Based Design Toolbox For Panther (MPC574xP) Family of Processors 2.0 IS NOW AVAILABLE!  to get it. It could be found under: ...\AMMCLIB_s32k14\lib\ folder precompiled for x64 or x86

For convenience you have it int he demo as x64 flavor.

If your simple run (not build) the model attached you should expect the following results:

pastedImage_3.png

Hope this will help you!

Best regards,

Daniel

2,515 Views
ruonanzhou
Contributor II

Thank you Daniel!

I'll try this out and let you know if we have any questions.

Ruonan

0 Kudos
Reply
2,515 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi ruonanzhou‌,

Any updates in regards to this thread? Does it works on your side?

Best regards,
Daniel

0 Kudos
Reply
2,515 Views
ruonanzhou
Contributor II

Hi Daneil

Sorry for my late reply. The solution you provided solved our trouble:)

Thank you very much!

Ruonan

2,515 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi ruonanzhou‌,

It shouldn't be any issues with SIL and PIL. Can you tell us the toolbox name and version you are trying to use.

It would be very helpful and faster it you could provide a test model that replicate the issue you are seeing.

Thank you!

Daniel

0 Kudos
Reply
2,515 Views
ruonanzhou
Contributor II

Hi Daniel,

We are using the math functions (sine/cosine/sqrt,etc...) from MPC564xL_AMMCLIB_v1.1.9 in our application code and trying to set up a s-function to call our application code which uses functions from this library. However, when we tried to compile our Simulink model, it failed because of the library MPC564xL_AMMCLIB.a.

Thank you,

Ruonan

0 Kudos
Reply
2,515 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi ruonanzhou

So, if I've understood correctly, your situation is like this:

- you have some hand written code which is using the math function from AMMCLIB;

- now you want to create a Simulink model and you need to reuse that hand written code;

-  you've used the S-function Simulink block that is calling your custom hand written code;

The problem is that the Matlab does not recognize parts of the hand written code because they are written in assembly. Is this a accurate description for your use case ?

Can you provide a sort of small code snippet to reproduce the issue on my side ?

Thank you!

Daniel

0 Kudos
Reply