There are several ways to support GPIB SRQ's within ATEasy. They are:- Using SetInterfaceEvent() internal function
- Using the GPIB driver and implementing OnInterface event
- Using EnableInterrupt() internal function
- Using I/O Table Receive operation
This article will demonstrate the process for using ATEasy's SetInterfaceEvent() procedure, allowing you to set an ATEasy procedure that will be called by ATEasy when a GPIB SRQ interrupt occurs for a particular GPIB Controller card. A full description of this function is available in ATEasy Help. As there is only one GPIB SRQ line on the GPIB bus, when the event procedure is called, you will have to poll each of the instruments, using GpibSpl(), to find which one requires servicing.
For example, to assign event procedure OnGpibCntlr1SRQ() to the SRQ interrupt of GPIB controller card1 (there may be more than one GPIB controller card in the system), use the following code:
status = SetInterfaceEvent(aioGpib, 0x10000, aioGpibSRQ, OnGpibCntlr1SRQ)
Create a service procedure called OnGpibCntlr1SRQ(). The function will search for all of the GPIB drivers in the application system to find the GPIB instrument generating the SRQ:
OnGpibCntlr1SRQ()
! Declare the following variables
! i !short variable to be used as a loop counter
! sDriverName !String to hold the drivers name
! lAddress !string to hold GPIB instrument address
! sData !String to hold instruments buffer information
{
!Search all the drivers assigned to the application to find the GPIB drivers
i=1 !System driver numbers start at 1
while i <= System.DriversCount
! System.DriversCount gives the number of drivers assigned to the application
sDriverName = GetDriverName(i) !Get the name of the driver
!Check if it is a GPIB driver
if GetDriverType(sDriverName) = aioGpib
!Get the address of the GPIB driver
lAddress = GetDriverAddress(sDriverName)
! Now check Request Service bit (RQS is Bit6) in the instruments Status
! Byte Register (STB). RQS will be set to 1 if service is requested
if(GpibSpl(lAddress) and 0b01000000) <> 0 !Check if RQS (bit6) is set
!Read the instruments buffer for information on the SRQ
sData="" !Clear the buffer array
GpibReceive(lAddress, "\r\n", 1, 150, 0, sData, 20)
!TODO: Add code to handle the SRQ
!...
endif
GpibClear(lAddress) !Reset the Gpib Instrument if required
endif
endwhile
)