Creating Instrument Object Array for GPIB communication

4 views (last 30 days)
Hi,
I'm trying to communicate with some lab equipment via GPIB. I kind of made it work but I'm still having some problems.
The basic code is very simple:
g=gpib('ni',0,1) %create GPIB object
out=instrfind('Type','gpib')
fopen(out)
fprintf(out,['*IDN?'])
fscanf(out)
fclose(out)
The first time I run this programm works fine. But when running it again the instrument array increases by 1 and it looks like this:
*Index: Type: Status: Name:
1 gpib closed GPIB0-1
2 gpib closed GPIB0-1*
and it gives the error:
??? Error using ==> icinterface.fprintf at 77 OBJ must be a 1-by-1 interface object.
And then I have to restart Matlab since I have no idea how to clear this interface object. Nothing I tried worked so far. So you can imagine it's pretty annoying.
Does anybody of you have some experience with communication via GPIB?
Thanks a lot.

Answers (0)

Categories

Find more on Instrument Control Toolbox 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!