'**************************************************************************** '* QuickBASIC SAMPLE: SAMPLE5.BAS * '* * '* This is a demonstration program to be used with the ad8 A/D * '* board. The program will constantly read the digital input until a * '* key is pressed. When a key is pressed the program exits. * '* * '* This program demonstrates the use of task 0 to initialize the driver * '* and task 2 to read digital I/O. * '* * '* Set the IRQ jumper to IRQ5. * '* * '* 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: Inputs data from the digital input bits. * '* * '* INPUT: None. * '* * '* CALLS: calldriver * '* * '* OUTPUT: None. * '* * '****************************************************************************} CLS PRINT " QSAMPLE5.BAS : AD8-16 DIGITAL INPUT" PRINT PRINT "This is a demonstration program to be used with the AD8 A/D board." PRINT "The program will constantly read the digital input until a key is pressed." PRINT "When a key is pressed the program exits." 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 "Digital value read:" PRINT : PRINT : PRINT : PRINT PRINT "Press any key to terminate the program." task% = 2 ' Read digital input task WHILE INKEY$ = "" ' loop until key is pressed GOSUB calldriver IF status > 0 THEN ' if error then exit CLS END END IF LOCATE 7, 21 PRINT USING "###"; param%(1) ' print the digital value 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