Arduino PWM Block, Continously changing PWM Frequency
Show older comments
Hello everyone,
im currently trying to mirror a PWM Signal with a Arduino Nano 33 IoT.
I want to mirror the signal, because I want to be abled to manipulate the PWM duty cycle in certain situations.
Therefore I connected the Arduino to the Simulink environment. This works well .
In order to mirror it I am capturing the PWM duty-cylce and the frequency with the "Arduino Input Capture Block". Thist works reliably.
In order to put out the captured signal I use the "Arduino PWM Block" (because it uses the built in timers). The duty-cycle is fed to the block via the input of the block.
My Problem is:
The PWM Block does not have an input pin for the frequency. How can I feed the continously measured frequency into the PWM Block? Is it even possible to continously change the PWM frequency of the Arduino PWM Block?
It is important, that the frequency is continously updated, because it can change depending on the PWM source. As far as I know "to Workspace Block"s only refresh after the simulation.
Currently I am trying to use a global variable. I need to define the varibale before in the Workspace before running it on the Hardware. I try to write the frequency into the variable with a Matlab Function Block. But this does not work. The frequency of the output PWM does not change at all. And it seems like the variable is not changing as well
The Code is of the "Matlab Function Block" the following:
function y = fcn(u)
y = u;
I hope I made myself clear enough.
Thank you for your help!
Accepted Answer
More Answers (0)
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!