Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

auto serial polling and wait

Hallo
I have derived an application which communicates with a device1 in the way
listed in the pseudocode below ( auto serial polling was enabled.) :

ub = ibfind(device1);
ub2 = ibfind(device2);
loop;
ibwrt(ub , "Measure" );
ibwait(ub , SRQ | TIMO);
ibsrq(ub, &Status);
ibread(ub , &value , 100);
endloop;

This application worked fine till the PC's clockfrequency increased the
perhaps 600MHZ limit. Now ibwait dosen't terminate with the service request,
but with the timeout! After disabling autoserial polling this problem was
fixed. It seams that auto serial polling handle the service request before
ibwait notice it?

But now we have another problem: another device sometimes sends service
requests while we are waiting for SRQ's from
device1. Now ibwait terminates
with the iberror 16 (ESRQ).

Now I have read some of NI's manuals on serial polling and get some ideas
how to solve this problem. I hope someone could comment this Ideas.

1) the simplest one:
enable auto serial polling and disable interrupts of the GPIB interface
-> auto serial polling couldn't begin before ibwait( am I rigth?).

2) relative simple but cpu-time wasting :
enable auto serial polling and avoid waiting for SRQ:

ub = ibfind(device1);
ub2 = ibfind(device2);
loop;
ibwrt(ub , "Measure" );
while( !(ibwait(ub , 0) & 0x4)) ;
ibsrq(ub, &Status);
ibread(ub , &value , 100);
endloop;

3) some changes on program design
disable auto serial polling and wait for SRQI

u = ibfind(board);
ub = ibfind(device1);
ub2 = ibfind(device2);
loop;
ibwrt(ub , "Measure" );
ibwait(u , SRQI | TIMO);
ibsrq(ub, &status);
if( status & 0x4 ){
ibread(ub , &value , 100);
}
endloop;

4) redesign the program
enable auto serial polling and use ibnotify or i
bInstallCallback.

thanks

Babak
0 Kudos
Message 1 of 2
(3,935 Views)
Hello Babak,

Option 2 would take too much of your processor time. Option 3 would freeze the program until the SRQ is asserted. I would not recommend either of these options. I recommend option 1 or 4.

I do not know why the ibwait would stop working when you increase the PC clock frequency. Are you using the fastest GPIB bus timing? By default, it is set to the middle option (500 ns for a PCI-GPIB board). Try using 350 ns.

Also, make sure that you are reading each serial poll byte after the SRQ has been asserted. The function that you use for this is ibrsp. You might be able to use this to lower the SRQ line of the other device before doing an ibwait.

There are 2 good references for GPIB programming. See the links below.

http://digital.ni.c
om/manuals.nsf/websearch/35CD6168125E0EBD86256789006E84D4?OpenDocument&node=132100_US

http://digital.ni.com/manuals.nsf/websearch/43AB49D953CE104E8625665E007D11FF?OpenDocument&node=132100_US

Have a good day.

Kim L.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,935 Views)