We'd like to control CAMAC via a GPIB/CAMAC interface module (LeCroy
8901a). We use NI GPIB-USB-HS as the interface to 8901a.
We also download GPIB Matlab Toolbox from <http://www.alamath.com/gpib.html>,
nd try to make it work with the example (in C) given in 8901A manual.
However, the 8901a does not response correctly. For example, with a
GPIB address of 3, i did the following (Matlab R14) to make 8901a to
listen ---
g = visa('ni', 'GPIB0::3::0::INSTR');
fopen(g);
ibsic(0)
ibtmo(0,12)
ibcmd(0,'0x23',2)
fclose(g);
delete(g);
clear g;
Well, it is NOT OK.
Can anybody tell me what went wrong ?
Wrong driver (gpib53.dll) ? or, wrong syntax ? ...
Thanks !
CY Cheng
From your first line of code it appears you are trying communicate
with your instrument using visa. However, since you are using the NI
gpib-usb-hs it is most likely easier to use the NI driver that is
supplied with the gpib-usb-hs interface. For the latter, follow the
NI driver installation instructions and then take a look at the
Matlab documentation under the heading "Controlling Instruments Using
the GPIB". Next look at the example under the sub-heading "Creating a
GPIB Object".
Just yesterday I set up an instrument as mentioned above with no
problems.
HTH
RF
Sorry, I didn't quite finish my first reply.
In my response above I assumed you are using the Matlab Instrument
Control Toolbox. As far as the download you mentioned (We also
download GPIB Matlab Toolbox from <http://www.alamath.com/gpib.html,)>.
I haven't heard of it and thus have no clue about it.
RF
(1) LeCroy 8901a can reponse to the GPIB Matlab Toolbox from <http://www.alamath.com/gpib.html>.
nd, using NI-488.2 utility program --- NI spy, we can monitor the
response of 488.2's commands.
However, it has some bug somehow ! By the following program, we can
successfully open, initialize, set transfer mode, and write command
word to LeCroy 8901a.
But, whenever, any of the 8-bit bytes of 24-bit word exceed 126 (d1,
or d2, or d3), CAMAC response went wrong !!
% --- Sample Code to initiate & write --- %
global gpibBd Device;
global pcTalk pcListen pcStandby;
global qx_Return; qx_Return = 0;
gpibBd = 0; addr = 3; sub_addr = 0; % LeCroy 8901a
pcTalk = char([64, 32 + addr]);
pcListen = char([32, 64 + addr]);
pcStandby = char([63, 95]);
Device = ibdev(gpibBd,addr,sub_addr,7,0,0); % open 8901a
ibrsc(gpibBd, 1); ibtmo(gpibBd,12);
ibsic(gpibBd); ibtmo(gpibBd,12); % clear GPIB interface
ibclr(Device); ibtmo(gpibBd,12); % clear GPIB device
ibcmd(gpibBd, pcTalk, 2);
ibwrt(Device, char(100), 1); % 24 bit normal mode
ibcmd(gpibBd, pcStandby, 2);
ibcmd(gpibBd, pcTalk, 2);
ibwrt(Device, char(33), 1); % initialize CAMAC
ibcmd(gpibBd, pcListen, 2);
ibcmd(gpibBd, pcTalk, 2);
ibwrt(gpibBd, char(72), 1); % inhibit CAMAC
ibcmd(gpibBd, pcListen, 2);
ibcmd(gpibBd, pcTalk, 2);
ibwrt(Device, char(100), 1); % 24 bit normal mode
ibcmd(gpibBd, pcStandby, 2);
d1 = 1; % first byte of data (24-bit word)
d2 = 1; % second byte of data (24-bit word)
d3 = 1; % third byte of data (24-bit word)
rw = char( [16 0 16 d1 d2 d3] ); % data for test
ibcmd(gpibBd, pcTalk, 2);
ibwrt(gpibBd, rw, 6) % write command & data
ibcmd(gpibBd, pcListen, 2);
ibonl(Device,0); % close 8901a
% --- End of Sample Code --- %
It seems we have to find some other way to send data byte by byte,
because the ascii has range of about 126 ?
How can we send them in binary way ?
(2) On the other way to talk to 8901a, we try the followig:
%% ------------------------------------ %%
gpibBd = 0; addr = 3; sub_addr = 0; % LeCroy 8901a
pcTalk = char([64, 32 + addr]);
pcListen = char([32, 64 + addr]);
pcStandby = char([63, 95]);
g = visa('ni', 'GPIB0::3::0::INSTR');
fopen(g);
fprintf(g,pcTalk)
fprintf(g,char(100))
fprintf(g,pcListen)
fprintf(g,pcTalk)
fprintf(g,char(33))
fprintf(g,pcListen)
fclose(g);
delete(g);
%% ------------------------------------ %%
However, nothing happen ....
So, we post the issue here, and wish some help ...
CY Cheng
Rafal
I would recommend Instrument Control Toolbox for the task.
For controlling the instrument using GPIB object, check the following
link:
http://www.mathworks.com/access/helpdesk/help/toolbox/instrument/f13-5310.html
You can also try to communicate using device object.
http://www.mathworks.com/access/helpdesk/help/toolbox/instrument/f6-1007240.html
Instrument Control Toolbox provides driver for LeCroy 8600a that can
be used to communicate via TCPIP. You can try using that driver for
this instrument or modify the driver using 'midedit' function to suite
the needs.
Hope this helps,
-Ankit
Rafal