2023-01-30 05:12 AM
DAC block is not directly available on MATLAB Simulink.
We tried interfacing CubeIDE with Simulink using S-Function builder but were not able to run. We are facing problem in creating S-function.
Any idea on how to do so directly or indirectly would be appreciated.
Solved! Go to Solution.
2023-02-07 01:04 AM
Hello @AAgra.5
I would like to share with you an answer from our partner Mathworks about your issue.
There are multiple ways to add DAC driver in Simulink model to leverage DAC peripheral.
Attached is an example model to use DAC and ADC with Embedded Coder Support Package for STMicroelectronics STM32 Processors that uses second way. Model is created with MATLAB version R2022b.
The attached example uses custom code way to trigger DAC and the voltage is read by ADC. The output port 1 in the model is mapped/configured to generate “DAC_Output�? global variable as shown below:
Special thanks dedicated to Mathworks Team for the support.
Firas
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-01-31 01:28 AM
Hello @AAgra.5
You need to Install Simulink Coder Support Package for STM32 Nucleo Boards
Also you may need to check Getting Started with STM32 Nucleo Boards Using Simulink - MATLAB & Simulink (mathworks.com)
Also make sure that you are using a Nucleo board that is supported in the support package.
Hope this helps
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-01-31 02:26 AM
Hii @F.Belaid
Thank you so much for the insights.
But the thing is I am facing a particular problem with DAC convertors as no MATLAB block is available.
As referenced in the link given ADC, Digital Input and Digital Output are applied.
I have tried using S-function builder as the code was available in CubeIDE but was not able to do it.
Could you guide me in the same.
2023-01-31 06:35 AM
Well @AAgra.5,
I guess you may need to check Level-2 MATLAB S-function API which allows you to create S-function block in Simulink not in STM32CubeIDE.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-02-07 01:04 AM
Hello @AAgra.5
I would like to share with you an answer from our partner Mathworks about your issue.
There are multiple ways to add DAC driver in Simulink model to leverage DAC peripheral.
Attached is an example model to use DAC and ADC with Embedded Coder Support Package for STMicroelectronics STM32 Processors that uses second way. Model is created with MATLAB version R2022b.
The attached example uses custom code way to trigger DAC and the voltage is read by ADC. The output port 1 in the model is mapped/configured to generate “DAC_Output�? global variable as shown below:
Special thanks dedicated to Mathworks Team for the support.
Firas
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.