'**************************************************************************** '* QuickBASIC SAMPLE: SAMPLE1.BAS * '* * '* This is a demonstration program to be used with the ad8 A/D * '* board. The program will perform constant differential conversions of * '* all eight channels and display the results. * '* * '* This program demonstrates the use of task 0 to initialize the driver * '* and task 1 to perform A/D conversions. * '* * '* Set the IRQ jumper to IRQ5. * '* The differential/single ended jumper should be installed to DIF. * '* * '* LAST MODIFICATION: 2/4/98 * '* * '****************************************************************************} 'Dimension the parameter passing variables and data buffer DIM index%, task%, status%, param%(5) COMMON SHARED param% 'Declare the driver entry point DECLARE SUB ad8drv (task%, BYVAL param%, status%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) '**************************************************************************** '* FUNCTION: main -- local routine * '* * '* PURPOSE: Performs a constant scan of 8 differential channels. * '* * '* INPUT: None. * '* * '* CALLS: calldriver * '* * '* OUTPUT: None. * '* * '****************************************************************************} CLS PRINT " QSAMPLE1.BAS : AD8-16 A/D DATA VIA POLLING" PRINT PRINT "This is a demonstration program to be used with the AD8 A/D board." PRINT "The program will perform constant differential conversions of all" PRINT "eight channels 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 " -- Polarity is set to bipolar (required)" PRINT " -- Jumper IRQ5 should be installed (required)" PRINT " -- Range is from -5 to 5 volts (required)" PRINT " -- Differential mode inputs (required)" PRINT " -- All remaining jumper settings are irrelevant." PRINT : PRINT : PRINT PRINT "Press any key to start." C$ = INPUT$(1) task% = 0 ' Setup driver param%(1) = Address% ' Assign the Base Address param%(2) = 0 ' differential mode inputs, 1 would be S/E param%(3) = 1 ' bipolar mode, 0 would be unipolar param%(4) = 5 ' IRQ line jumpered on board GOSUB calldriver ' Begin the acquisition task% = 1 ' Analog Input Task param%(2) = 1 ' +/- 5V range, 0 would be +/-127mV I = 0 CLS WHILE INKEY$ = "" ' loop until key is pressed param%(1) = I ' channel number to be scanned GOSUB calldriver LOCATE 7 + I, 1 PRINT USING "Channel: # value: ####"; I; param%(3) I = ((I + 1) MOD 8) LOCATE 17, 1 PRINT "Press any key to terminate the program." WEND IF status = 0 THEN CLS CLS END ' main program '***************************************************************************** '* 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