'**************************************************************************** '* QuickBASIC SAMPLE: SAMPLE2.BAS * '* * '* This is a demonstration program to be used with the ad8 A/D * '* board. The program will perform 80 interrupt driven acquisitions on * '* channel 0 and display the results. * '* * '* This program demonstrates the use of task 0 to initialize the driver * '* and task 7 to perform and monitor the interrupt process. * '* * '* Set the IRQ jumper to IRQ5. * '* The differential/single ended jumper should installed to SE. * '* * '* LAST MODIFICATION: 2/4/98 * '* * '**************************************************************************** 'Dimension the parameter passing variables and data buffer DIM index%, task%, status%, param%(5), buf%(100) COMMON SHARED param%, buf% 'Declare the driver entry point DECLARE SUB ad8drv (task%, BYVAL param%, status%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) '**************************************************************************** '* FUNCTION: main -- local routine * '* * '* PURPOSE: Performs data acquisition using interrupts. * '* * '* INPUT: None. * '* * '* CALLS: calldriver * '* * '* OUTPUT: None. * '* * '****************************************************************************} CLS PRINT " QSAMPLE2.BAS : AD8-16 DATA VIA INTERRUPTS" PRINT PRINT "This is a demonstration program to be used with the AD8 A/D board." PRINT "The program will perform 80 interrupt driven acquisitions on channel 0" PRINT "and display the results." PRINT : PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- The Base Address is "; HEX$(Address%); " hex" PRINT " -- Jumper IRQ5 should be installed (required)" PRINT " -- Single ended mode (bottom pins) (required)" PRINT " -- All remaining jumper settings are irrelevant" PRINT : PRINT : PRINT PRINT "Press any key to start." C$ = INPUT$(1) task% = 0 ' initialize driver param%(1) = Address% ' assign the Base Address param%(2) = 1 ' 1 = single ended -- 0 = differential param%(3) = 1 ' bipolar mode, 0 would be unipolar param%(4) = 5 ' IRQ line jumpered on board GOSUB calldriver ' Begin the acquisition task% = 7 ' Interrupt setup tast param%(1) = 1 ' subtask 1, setup and begin param%(2) = 80 ' number of scans desired param%(3) = 0 ' channel we wish to scan param%(4) = 1 ' gain code we want for the readings param%(5) = VARPTR(buf%(1)) GOSUB calldriver ' loop until driver indicates completion of readings task% = 7 param%(1) = 2 ' select subtask 2, check for completion of interrupts param%(2) = 1 ' number of conversion left, is returned here. CLS WHILE param%(2) > 0 GOSUB calldriver WEND GOSUB displaydata CLS END ' main '**************************************************************************** '* FUNCTION: displaydata -- local routine * '* * '* PURPOSE: Displays the data from the buffer after interrupts. * '* * '* INPUT: None. * '* * '* CALLS: None. * '* * '* OUTPUT: None. * '* * '**************************************************************************** displaydata: CLS PRINT FOR j = 0 TO 7 FOR K = 1 TO 10 index = j * 10 + K LOCATE j + 1, K * 6 PRINT USING "######"; buf%(index) NEXT K PRINT NEXT j RETURN '***************************************************************************** '* PROCEDURE: call_driver -- local routine * '* * '* PURPOSE: Performs the call to the driver package. * '* * '* INPUT: None. * '* * '* CALLS: ad8drv - entry point to driver package. * '* * '***************************************************************************** calldriver: CALL ad8drv(task%, VARPTR(param%(1)), status%) IF status > 0 THEN ' an error has occured PRINT "A status error code of"; status%; " was detected." PRINT "Program terminated." END END IF RETURN FUNCTION AskForBaseAddress (OldOne AS INTEGER) Msg$ = "" NewOne% = 0: Success = 0: Dummy% = 0 AddrInputPosX = 0: AddrInputPosY = 0 PRINT "Please enter the Base Address (0000-FFFF) for your card (in hex)" PRINT "or press ENTER for "; HEX$(OldOne%); "." PRINT ">"; AddrInputPosX = POS(0): AddrInputPosY = CSRLIN WHILE Success = 0 LOCATE AddrInputPosY, AddrInputPosX PRINT " " LOCATE AddrInputPosY, AddrInputPosX LINE INPUT Msg$ NewOne% = VAL("&H0" + LEFT$(Msg$, 4)) Success = 1 Dummy% = NewOne% IF (Msg$ = "") THEN LOCATE AddrInputPosY, AddrInputPosX PRINT HEX$(OldOne%) Success = 1 Dummy% = OldOne% END IF WEND AskForBaseAddress = Dummy% END FUNCTION