Borrar filtros
Borrar filtros

Need help to find the error in the code below

1 visualización (últimos 30 días)
Vijith Natarajan
Vijith Natarajan el 30 de Nov. de 2012
Hi i tried to acquire the waveform from the agilent scope to matlab using tmtool of instrument control toolbox. when i execute the read waveform function it is showing me an error "undefined function or variable waveformArray".
_Please find the code for Readwaveform function which is already done in tmtool _
function [WaveformArray, ActualPoints, InitialX, XIncrement] = readwaveform(obj, Channel, WaveformSize, MaxTimeMilliseconds, WaveformArray)
libname = get(get(obj, 'Parent'), 'DriverName');
session = get(get(obj, 'Parent'), 'Interface');
Channel = [double(Channel) 0];
WaveformArray = libpointer('doublePtr', WaveformArray);
ActualPoints = libpointer('int32Ptr', 0);
InitialX = libpointer('doublePtr', 0);
XIncrement = libpointer('doublePtr', 0);
status = calllib(libname, 'AgInfiniiVision_ReadWaveform', session, Channel, WaveformSize, MaxTimeMilliseconds, WaveformArray, ActualPoints, InitialX, XIncrement);
WaveformArray = double(WaveformArray.Value);
ActualPoints = double(ActualPoints.Value);
InitialX = double(InitialX.Value);
XIncrement = double(XIncrement.Value);
if (status < 0) errorMessage = libpointer('int8Ptr', repmat(10, 1, 512));
status = calllib(libname, 'AgInfiniiVision_error_message', session, status, errorMessage);
if (status < 0)
error('Failed to interpret error message');
end
errorMessage = strtrim(char(errorMessage.Value));
error('The instrument returned an error while executing the function.\n%s', errorMessage)
end
the code i tried to access the read wave form function is below
% Create a device object.
deviceObj = icdevice('AgInfiniiVision.mdd', 'USB0::2391::6038::my51135042::0::INSTR');
% Connect device object to hardware.
connect(deviceObj);
% Execute device object function(s).
groupObj = get(deviceObj, 'Waveformacquisition'); groupObj = groupObj(1); [WAVEFORMARRAY] = invoke(groupObj, 'readwaveform', 'channel1');
Please tell me the error in the code
  4 comentarios
Vijith Natarajan
Vijith Natarajan el 12 de Dic. de 2012
can anyone pls help on the above question?

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 30 de Nov. de 2012
readwaveform() requires more input arguments than just 'channel1' which you are passing it. Why didn't you pass the other input arguments?
  3 comentarios
Walter Roberson
Walter Roberson el 12 de Dic. de 2012
Yes, it is mandatory to pass all of the values.
Ankit Desai
Ankit Desai el 12 de Feb. de 2013
You might be confusing a webinar on using IVI-COM drivers with IVI-C drivers. You are using an MDD file based on IVI-C driver. As seen in the code generated by makemid or midedit, and as pointed out by Walter, the function readWaveform takes in 5 arguments (obj, Channel, WaveformSize, MaxTimeMilliseconds and WaveformArray). These input parameters are used by the code in that function.
Not passing any input will cause the code to error out complaining about missing parameter. In your case, you did not pass all the arguments and so when the code reached line 4:
WaveformArray = libpointer('doublePtr', WaveformArray)
It errored out since it did not find the variable WaveformArray in the input argument.
Here's how the call to that function should look like:
% Record length.
recordLength = 1000; %Can be whatever length you want.
% Pre-allocate buffer to store the data read from scope.
waveformArray = zeros(1, recordLength);
% Set the time to wait before the function times out.
maxTimeOut = 1000;
waveformArray = invoke(groupObj,'readwaveform','channel1',recordLength, maxTimeOut, waveformArray);
Note:- When you call invoke on groupObj, the first argument that is required by all the driver methods "obj" is taken care of. That is the reason why we are providing only the remaining four arguments (Channel,WaveformSize,MaxTimeMilliSeconds and WaveformArray).
Hope this clears all your doubts.
All the best!

Iniciar sesión para comentar.

Categorías

Más información sobre Instrument Connection and Communication en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by