How can I output analog data in Simulink?

2 views (last 30 days)
Hello, I have trouble outputting data with a NI USB 6211 device using the Analog Output block from the Data Acquisition Toolbox on Simulink.
I have been able to acquire signals with the Analog Input block, which makes me think it sholud be possible to output the signals the same way. This is the model that worked fine and the configuration I used:
Anyway, I keep getting the following error whenever I want to run the simulation using Analog Output:
Error reported by S-function 'sdaqao' in 'DAQ_Analog_Output/Analog Output': To run in a hardware-clocked output mode, this hardware requires that at least 2 samples be queued using PUTDATA. You must pad your output with additional samples to use PUTDATA, or use PUTSAMPLE instead.
I have tried writing the following code in the command window and then running the simulation:
ao = analogoutput('nidaq','Dev1');
ch = addchannel(ao,0:1);
y = [1 1]';
putdata(ao,[y y])
But the same error keeps comming out.
I also tried using Analog Output (Single Sample), but I have problems with the timing. For example, I generate a sin of some frequency but on the oscilloscope I see another frequency and the simulation does not last what I set in the model.
I could acquire and output data writing code in the Command Window, but for my work I need to be able to do it on Simulink. I am using Matlbab R2012b.
This are the images of the model and the configuration of the block for Analog Output:
How can I output data using the Analog Output block? I really need to do this so any help will be very appreciated.
Thanks,
Marina

Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations 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!