Embedded coder simulink question: external .c and .h? create S function? use Matlab function block

조회 수: 17 (최근 30일)
Hi,
I think I am getting confused with all the products capabilities and which to use.
I would like to create a custom function in a simulink model that calculates a checksum amongst other things. Code is auto generated from the model to run on an arm microcontroller.
Preferably I would like to reuse this function across the model and maybe in futre in other models. What would be the best approach for this?
  1. Integrate C Code Using the MATLAB Function Block
  2. Create a wrapper around a .c file to create an S-function <not sure if this is even correct?
  3. Create a Matlab function to do this (what does the generated code look like, is it ok to do this?)
  4. Use simulink blocks to do this?
Thanks.

채택된 답변

Birdman
Birdman 2018년 1월 29일
The preference order for me is as follows:
3-4-1-2
I would first and always try to go with solve my issue with a MATLAB Function block because it is really easy to implement your algorithm in it and for Simulink, it is easy to generate C code from it. See the following links:

추가 답변 (1개)

Joe Holdsworth
Joe Holdsworth 2018년 1월 30일
Birdman,
Thanks very much for your answer, what parameters define which method you would use?
  댓글 수: 1
Birdman
Birdman 2018년 1월 30일
You are welcome, as I said, I would first try to use MATLAB Function.
Actually, to get used to the stuff and see the differences, why don't you implement something simple with Simulink blocks and MATLAB Function? A mathematical expression or else, implement something and generate code from it and see the differences and similarities.
By the way, if my answer helped, can you also accept it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Timers and Scheduling에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by