Quickbasic example program - device – National Instruments GPIB-PC User Manual

Page 183

Advertising
background image

BASICA/QuickBASIC GPIB-PC Function Calls

Section Four A

GPIB-PC User Manual

4A-108

©National Instruments Corp.

QuickBASIC Example Program - Device

QuickBASIC - Using device function calls.

COMMON SHARED IBSTA%, IBERR%, IBCNT%
REM Assign a unique identifier to device
REM and store in variable DVM%.
REM

BDNAME$ = "DVM"
CALL IBFIND (BDNAME$,DVM%)

REM
REM Check for error on IBFIND call.
REM

IF DVM% < 0 THEN GOSUB FIND-ERROR:

REM
REM Clear the device.
REM

CALL IBCLR (DVM%)

REM
REM Check for an error on each GPIB call
REM to be safe.
REM

IF IBSTA% < 0 THEN GOSUB GPIB-ERROR:

REM
REM Write the function, range, and trigger
REM source instructions to the DVM.
REM

WRT$ = "F3R7T3" : CALL IBWRT (DVM%,WRT$)
IF IBSTA% < 0 THEN GOSUB GPIB-ERROR:

REM
REM Trigger the device.
REM

CALL IBTRG (DVM%)
IF IBSTA% < 0 THEN GOSUB GPIB-ERROR:

REM
REM Wait for the DVM to set RQS or for a
REM timeout; if the current time limit
REM is too short, use IBTMO to change it.
REM

MASK% = &H4800 : CALL IBWAIT (DVM%,MASK%)
IF (IBSTA% AND &HC000) <> 0 THEN GOSUB GPIB-ERROR:

REM
REM Since neither a timeout nor an error
REM occurred, IBWAIT must have returned
REM on RQS. Next, serial poll the device.
REM

Advertising