pulsewith calculation with simulink on Arduino Uno/Due

1 回表示 (過去 30 日間)
Kobe Van Doren
Kobe Van Doren 2021 年 4 月 30 日
コメント済み: sapry 2022 年 11 月 12 日
I need to determine the pulse width of a PWM signal in simulink.
This PWM signal is the input of the Arduino Uno, attached to the digital-PWM input admittedly.
Since there are no simulink blocks that calculate the pulse width directly, I chose the Sfunction builder to implement the 'pulseIn' function from Arduino IDE(the source code) as C code. When the required number of libraries is added and the necessary commands such as 'define Arduino 100', and the statement '#ifndef MATLAB_MEX_FILE, #endif', external "C" for each void loop, etc no more error messages are given. Still, the display does not give a value in the neighborhood of 1000 to 2000ms.
The Sfunction block does not support masking. The source code does contain a 'digitalpintobitmask'... Since this does not give an error, I assume that this
cannot be the problem. I think it's due to the function call and how to connect this to the output. Have no idea how to write it correctly though.
An alternative solution is to use the 'pulsewidth' command in a matlab function block. This command is not supported by Arduino.
I am giving you some pictures for clarification.
Does anyone have an idea how to solve this?
Thanks in advance.
  1 件のコメント
sapry
sapry 2022 年 11 月 12 日
How do you use the pulsein function in matlab?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by