pulsewith calculation with simulink on Arduino Uno/Due
1 次查看(过去 30 天)
显示 更早的评论
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!