Borrar filtros
Borrar filtros

Example of a Device Driver integrated in Simulink using a Custom block

17 visualizaciones (últimos 30 días)
Archit
Archit el 20 de Ag. de 2024 a las 14:18
Comentada: akshatsood el 20 de Ag. de 2024 a las 17:46
Hi,
Can someone point to any example/sample code demonstrating integration of a board specific device driver code ( for example read data from a serial bus like CAN/SPI, or even simpler read data from ADC etc.. ) into SIMULINK with a custom block.
Which is a better choice for such a requirement , S-Function block or a C Function block?
I want to possibly simulate and also generate the glue code to integrate with the low level driver with the embedded coder.
Thanks in advance
AAA

Respuestas (1)

akshatsood
akshatsood el 20 de Ag. de 2024 a las 14:47
Editada: akshatsood el 20 de Ag. de 2024 a las 14:51
Dear @Archit,
I understand that you are looking for guidance on integrating board-specific device driver code into Simulink using a custom block. You mentioned tasks such as reading data from interfaces like CAN, SPI, or ADC, and you are considering whether to use an S-Function block or a C Function block for this purpose.
S-Function Block: provides extensive flexibility for integrating complex device drivers and managing detailed hardware interactions. Also, supports both simulation and automatic code generation.
C Function Block: simplifies the integration process for less complex tasks, enabling direct incorporation of C code into models. Ideal for rapid prototyping and simple hardware interactions.
Recommendation
  • For Complex Integrations: S-Function blocks are preferable if you need comprehensive control over hardware interactions and plan to generate production code with Embedded Coder.
  • For Simpler Tasks: C Function blocks are suitable for simpler integrations or when you are prototyping.
I hope this helps.
  2 comentarios
Archit
Archit el 20 de Ag. de 2024 a las 16:53
Hi Akshat,
Thanks a lot for the quick and clear answer.it clarifies my query.
Can you point to some example demonstrating this type of custom block integration?
Also, can i try out such an example on the Online version of Matlab? I understand that i won't be able to try out the device driver interfacing in the online version, but any example showing the process to create a custom block and integrate into an existing model and integrate some dummy C code will help.
thanks again!
Regards,
AAA

Iniciar sesión para comentar.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by