Clear Filters
Clear Filters

Analog Output advantech PCI1711

3 views (last 30 days)
Malte
Malte on 16 May 2013
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

Answers (0)

Categories

Find more on Simulink Functions 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!