How to write to DAC pins on arduino in MATLAB - not Simulink!

7 ビュー (過去 30 日間)
Logan Hinchcliffe
Logan Hinchcliffe 2024 年 3 月 22 日
回答済み: Brahmadev 2024 年 4 月 3 日
In the MATLAB support package for arduino, there is no function to be able to write to the DAC (analog) pins! I know that there is a block for it in simulink but i need to write it in matlab code. Has anyone else figured out a way to do this, can i somehow use the simulink block in my code?
Thanks in advance this is super important!

回答 (1 件)

Brahmadev
Brahmadev 2024 年 4 月 3 日
As per my understanding, you would like to use MATLAB to write to DAC pin on an Arduino target hardware. A MATLAB function with a similar functionality is not present. But, you can create a simulink model with the "Analog Write" block and simulate it from MATLAB by setting the simulation mode as "Monitor and Tune" using the following command:
set_param(gcs, 'SimulationMode', 'external');
Refer to the following documentation and Community Post for more information:
  1. https://www.mathworks.com/help/simulink/ug/using-the-sim-command.html
  2. https://www.mathworks.com/matlabcentral/answers/91497-how-do-i-run-my-external-mode-simulation-from-the-command-line-or-a-matlab-script
Hope this helps!

カテゴリ

Help Center および File ExchangeRun on Target Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by