Simulink Matlab Function DAQ Pulse Generation Instance Class

5 Comments

Hi, I need to generate a PWM signal and write it into a NI USB-6341. If I run the program Generate Pulse Width Modulated Signals Using NI Devices - MATLAB & Simulink - MathWorks América Latina in Matlab, it works. But I have a larger program on Simulink, so I am trying to create a Matlab Function there. Thank you!
Hey,
You need to set the frequency of the channel, not the device.
ch.Frequency = 5e-5;
Thank you Mario. Sorry, I should have strated that I tried with those same commands (as indicated on this link Generate Pulse Width Modulated Signals Using NI Devices - MATLAB & Simulink - MathWorks América Latina) and getting this other error as well:
The InitialDelay property does not exist for your output channel ch. Here is a function that can show you what properties are available for your channel in the table.
DisplayProperties(ch);
function objectTable = DisplayProperties(object)
% Get fields, their values and put them in UITable
fields = fieldnames(object);
propVals = cell(length(fields), 1);
for ii = 1:length(fields)
propVals{ii,1} = object.(fields{ii,1});
end
objectTable = table(fields, propVals);
uiFig = uifigure();
uitable(uiFig, "Data", objectTable);
end
Great! Thank you Mario, I was looking for that type of function to check the available properties.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2022a

Asked:

on 10 Oct 2022

Commented:

on 11 Oct 2022

Community Treasure Hunt

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

Start Hunting!