'**************************************************************************** '* QuickBASIC SAMPLE: SAMPLE4.BAS * '* * '* This is a demonstration program to be used with the ad8 A/D * '* board. The program will prompt for a counter number, a counter mode * '* and a load divisor value. A channel number greater than 2 exits. * '* * '* This program demonstrates the use of task 0 to initialize the driver * '* and task 5 to manipulate the counter. * '* * '* Set the IRQ jumper to IRQ5. * '* The counter clk jumper should be installed. * '* * '* 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 setup and control of the counters. * '* * '* INPUT: None. * '* * '* CALLS: calldriver * '* * '* OUTPUT: None. * '* * '****************************************************************************} CLS PRINT " QSAMPLE4.BAS : AD8-16 D/A OUTPUT" PRINT PRINT "This is a demonstration program to be used with the AD8 A/D board." PRINT "The program will prompt for a counter number, a counter mode and a" PRINT "load divisor value. A channel number greater than 2 exits the program." 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 " -- Differential mode inputs (required)" PRINT " -- All remaining jumper settings are irrelevant." PRINT : PRINT : PRINT PRINT "Press any key to start." C$ = INPUT$(1) CLS 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 LOCATE 7, 1 PRINT "Enter the counter number ( larger than 2 exits):" LOCATE 9, 1 PRINT " Enter the counter mode(0 - 5):" LOCATE 11, 1 PRINT " Enter the counter load value:" task% = 5 ' counter Output Task WHILE status = 0 ' loop until driver error LOCATE 7, 50 INPUT param%(1) ' fetch counter number IF param%(1) > 2 THEN ' if not 0 thru 2 then exit CLS SYSTEM END IF LOCATE 9, 50 INPUT param%(2) ' fetch counter mode LOCATE 11, 50 INPUT param%(3) ' fetch counter load value GOSUB calldriver WEND CLS END '***************************************************************************** '* 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