pulsewith calculation with simulink on Arduino Uno/Due
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (0)
Siehe auch
Kategorien
Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!