Hello:
We have a control algorithm verified under simulink needs to be transferred to S32K144 to run. My idea is to replace the corresponding modules in the control algorithm with the calculation module in the S32K toolbox.However, there are some modules that do not have corresponding modules in the S32K toolbox. We would like to keep these modules and not replace them, but the data types of the modules do not match.
Just like the Power operations and state space equations in the following figure.
Is there any way to handle this situation?
Best Regards!
Liu qimin
Solved! Go to Solution.
Hi liuqimin
However, I am concerned that the generated code will run inefficiently on the MCU.Therefore, when generating code, the computation module in the original model should be replaced by S32K toolbox'module to improve the efficiency of code operation. Am I right?
100% true. Nonetheless, that's the main idea of Model-Based Design: Simulate -> Prototype -> Improve.
For sure it will not run efficient but you will have a baseline to start from.
The AMMCLIB User Manual is delivered with the MBDT Toolbox. Can be found in ..\\src\mbdtbx_s32k14x\AMMCLIB_s32k14x\doc
Attached here for your reference too.
and the procedure for computing the C1f is described for fixed point implementation only:
for the floating point case, you can see it in the example:
Best regards,
Daniel
Hi liuqimin,
Relate with your original post:
Is there any way to handle this situation?
You should be able to generate the code from Simulink for the original model - even if it is represented in continuous time domain (1/s). Not sure what error are you getting. If there is an error about data types i think you can use data type conversion between subsystems. You will probably lose some precision between double->single but it should work.
The S32K MCU has a FPU unit on 32bit hence it should deal with such algorithms pretty well. It will not be optimal but it should work.
An addition step that you can do to improve the execution on S32K MCU, is to convert your original model from s-domain to z-domain and implement it into single data type.
In regards with your second post:
However, it is not correct to use the GFLIB_IntegratorTR_FLT module in the S32K toolkit instead.Perhaps the parameter fltC1 is incorrect.Is this parameter the same as the parameter in the discrete integral module as the gain coefficient?If not, how to determine this parameter?
Please have a look into the S32K14xMCLUB.pdf manual $5.48 page 567. It shows how to compute the paramter C1f depending on the type of integrator you may want to use.
Basically for the floating point implementation it should be: fltC1 = Ts/2
Best regards,
Daniel
Hi Daniel
Thanks for your reply ！
Is that the manual you're talking about?I can't find a description of this parameter.
As for generating S32K code directly with Simulink original model, I think it can be done.However, I am concerned that the generated code will run inefficiently on the MCU.Therefore, when generating code, the computation module in the original model should be replaced by S32K toolbox'module to improve the efficiency of code operation. Am I right?
For fltC1, I'll try Ts/2.
Best Regards!
Liu qimin
Hi liuqimin
However, I am concerned that the generated code will run inefficiently on the MCU.Therefore, when generating code, the computation module in the original model should be replaced by S32K toolbox'module to improve the efficiency of code operation. Am I right?
100% true. Nonetheless, that's the main idea of Model-Based Design: Simulate -> Prototype -> Improve.
For sure it will not run efficient but you will have a baseline to start from.
The AMMCLIB User Manual is delivered with the MBDT Toolbox. Can be found in ..\\src\mbdtbx_s32k14x\AMMCLIB_s32k14x\doc
Attached here for your reference too.
and the procedure for computing the C1f is described for fixed point implementation only:
for the floating point case, you can see it in the example:
Best regards,
Daniel
Hi Daniel
Thank you for your information!
When Ts/2 is used for the parameter fltC1 of the GFLIB_IntegratorTR_FLT module, the running result of the replaced algorithm model is exactly the same as that of the original model。
When useing C1 calculation formula of fixed point module as following before：
The resulting parameters do not work at all.
Follows is the results of correct operation:
Next step needs to be verified on MCU hardware.
Best Regards!
Liu qimin
Hello:
For the state space equation, let's change it to the following diagram. Now it's a new proble coming. When the continuous integral module in the figure is replaced by discrete integral module, it works normally.However, it is not correct to use the GFLIB_IntegratorTR_FLT module in the S32K toolkit instead.Perhaps the parameter fltC1 is incorrect.Is this parameter the same as the parameter in the discrete integral module as the gain coefficient?If not, how to determine this parameter?
Best Regards!
Liu qimin