Analog Output advantech PCI1711
1 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I would like to use the "Analog Output"-Block of the Data Acquisition Toolbox for the advantech PCI1711 in one of my Simulink modells. Unfortunately I receive the following error:
Error reported by S-function 'sdaqao' in '.../Analog Output': The analog output subsystem of this device does not support clocked generation. With this hardware you must output individual samples using PUTSAMPLE and can not use a combination of PUTDATA and START.
To get around this error I wrote a Level-2 MATLAB S-function with the following code:
function analogoutput(block)
setup(block);
%endfunction
function setup(block)
% Register the number of ports.
block.NumInputPorts = 1;
block.NumOutputPorts = 0;
% Set up the port properties to be inherited or dynamic.
block.SetPreCompInpPortInfoToDynamic;
% Override the input port properties.
block.InputPort(1).DatatypeID = 0; %double
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).Dimensions = 1;
% Register the parameters.
block.NumDialogPrms = 0;
block.SetAccelRunOnTLC(false);
block.SimStateCompliance = 'DefaultSimState';
block.RegBlockMethod('Outputs', @Outputs);
%endfunction
function Outputs(block)
output(block.InputPort(1).Data);
%endfuction
function output(u)
AO = analogoutput('advantech');
set(AO,'Samplerate',500);
chan = addchannel(AO, [0 1]);
putsample(AO, [0 u]); %0 Volt auf Channel 0 geben
delete(AO);
Unfortunately this is a very slow solution that takes 26,5 ms/call.
If you had an idea of a faster solution I would be very thankful!
Cheers, Malte
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!