필터 지우기
필터 지우기

Need help to find the error in the code below

조회 수: 4 (최근 30일)
Vijith Natarajan
Vijith Natarajan 2012년 11월 30일
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
Vijith Natarajan
Vijith Natarajan 2012년 12월 12일
can anyone pls help on the above question?

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2012년 11월 30일
readwaveform() requires more input arguments than just 'channel1' which you are passing it. Why didn't you pass the other input arguments?
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 12월 12일
Yes, it is mandatory to pass all of the values.
Ankit Desai
Ankit Desai 2013년 2월 12일
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Generic Instrument Drivers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by