MATLAB Programming Example for U22351A USB Modular Data Acquisition (DAQ) module’s Analog Ouput
Show older comments
I am trying to set up a DAQ with an arbritrary (custom) signal but as the daq toolbox is not supported any more, I need to use the instrument control toolbox with IVI components, which I am struggling with. Any advice will be great, my attempt is as follows.
addpath(genpath(toolboxdir('instrument'))); %intrument control toolbox pathway
% Connect steps: Use icdevice with the MATLAB instrument driver name and instrument's resource name to create a device object.
if (exist('KtU23xx_ivic.mdd','file') == 0)
makemid('KtU23xx', 'KtU23xx_ivic.mdd', 'ivi-c');
end
U2351A = icdevice('KtU23xx_ivic', 'USB0::0x0957::0x0F18::TW62020521::0::INSTR');
connect(U2351A);
% now the parameters for the output
U2351A.Instrumentspecificanalogoutgeneration.Mode = 1; % (1 is arbitrary signal)
U2351A.Instrumentspecificanalogoutarbitrary.SampleRate = 10000;
U2351A.Instrumentspecificanalogoutarbitrary.NumberOfStreams = -1; %continuous adquisition
U2351A.Instrumentspecificanalogoutgeneration.TriggerMode = 0; %no wait for trigger
invoke(U2351A.Instrumentspecificanalogout, 'analogoutsetpolarity', 'AOut1', 2); % AOut1 is the output analog channel and 2 is bipolar (+-10V).
invoke(U2351A.Instrumentspecificanalogout, 'analogoutsetreferencesource', 'AOut1', 1); % KTU23XX_VAL_OUTPUT_REFERENCE_INTERNAL = 1
invoke(U2351A.Instrumentspecificanalogout, 'analogoutsetenabled', 'AOut1', 1);
count=100; % silly example
while count
[ReturnCount] = invoke(U2351A.System, 'viwrite', 200, dat(count)); % dat is the signal I want to send
count=count-1
end
% stop
invoke(U2351A.Instrumentspecificanalogoutgeneration, 'analogoutgenerationstop');
% Cleanup
disconnect(U2351A);
delete(U2351A);
I am pretty sure I am missing something very obvious but I am cannot see it....
4 Comments
Mario Malic
on 14 Dec 2022
Is using an MATLAB with the older version that still supports the device an option?
Mario Malic
on 14 Dec 2022
Lorena Santamaria
on 14 Dec 2022
Lorena Santamaria
on 14 Dec 2022
Answers (0)
Categories
Find more on Instrument Connection and Communication 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!