VISA (GPIB) connection - syntax correct but instrument not understanding commands
이전 댓글 표시
Hi All! A bit of a problem getting an instrument to understand what I am passing it, any advice would be very much appreciated!
Background:
- I am sending commands to a semiconductor analyzer from Agilent
- I am connecting via a USB-to-GPIB interface
Symptoms:
- A connection tool verifies that I have a successful connection
- a connection tool also provides a console in which I can enter texts commands (the same as the ones I pass through matlab), and this works perfectly.
- when I connect to the instrument via matlab with the Instrument Control Toolbox, using code like the below, the connection seems to be successful (see next bullet), but the commands that I deliver are not.
- When I send a command (via fprintf()), I get no immediate error in the matlab window, but using the console I can query the instrument for errors, and I get a "command not understood" error. So the instrument is receiving something, but it isnt understanding it
- When I query the instrument (via fscanf()), I get a VISA timeout error in the matlab window, and the same error as usual from the instrument.
An example of the code that I use is the following; I believe it is correct syntax because this code and others have been provided by the manufacturer, and because similar code that I have written based on these examples and those in the instrument control API have been verified to be correct syntax by the manufacturer:
%Test code to verify instrument and Matlab connectivity
%Close any old instrument connections
newobjs = instrfind; %Find all previously connected instruments
if (length(newobjs)~=0)
fclose(newobjs);
delete(newobjs);
end
instrument = visa('agilent', 'GPIB0::17::INSTR'); %set variable to instrument
fopen(instrument); %connect to the instrument
fprintf(instrument,'*IDN?'); %query instrument
idn = fscanf(instrument) %read from instrument
fclose(instrument); %disconnect from instrument
delete(instrument); %remove instrument from memory
clear instrument idn newobjs A %remove variable from memory
답변 (2개)
Darin
2012년 2월 1일
댓글 수: 1
Walter Roberson
2012년 2월 1일
Huh, so I had the right basic cause but it was implemented a quite different way!
Walter Roberson
2012년 1월 31일
0 개 추천
Before you fopen(instrument), get(instrument,'Terminator') and see what that says, and see if it matches the end-of-line sequence that the device is expecting.
댓글 수: 3
Darin
2012년 1월 31일
Walter Roberson
2012년 1월 31일
Okay, that turned out to be a false lead on my part.
fprintf() for devices turns out to use %s\n as the default format, with the \n meaning newline. This differs from fprintf() for serial ports, which also use %s\n as the default format, but for those the \n means the Terminator string of the device.
488.2 compatible instruments use \n (meaning newline) as their line terminator, I see now.
Sorry, I do not have any further ideas at this time.
Walter Roberson
2012년 2월 1일
Ah: the \n for fprintf() for an instrument turns out to mean send the EOS character, http://www.mathworks.com/help/toolbox/instrument/eoscharcode.html . Same basic issue as with serial ports. Except, as Darin located, there is an EOSMode that determines whether the EOS is sent or not; http://www.mathworks.com/help/toolbox/instrument/eosmode.html
Sigh.
Join my Facebook "One World, One Newline" campaign!
카테고리
도움말 센터 및 File Exchange에서 Instrument Connection and Communication에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!