'***************************************************************************** '* QSAMPLE5.BAS : DIGITAL OUTPUT * '* LAST MODIFICATION: 2/3/98 * '*****************************************************************************/ ' Dimension the paramter passing variables. DIM task%, stat%, param%(5) COMMON SHARED param% ' This is the driver entry point declaration DECLARE SUB A16DRV (task%, BYVAL param%, stat%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) CLS PRINT " QSAMPLE5.BAS : DIGITAL OUTPUT" PRINT PRINT " This is a demonstration program to be used with the AD12-16 A/D" PRINT " board. The program will prompt the user for a digital value, output it" PRINT " to the digital outputs, then read the digital inputs. This program" PRINT " demonstrates initializing the driver(task 0), outputing to digital" PRINT " (task 13) reading the digital inputs (task 14)." PRINT PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- Base address is "; HEX$(Address%); " hex" PRINT " -- IRQ5 is used for interrupts (required)" PRINT " -- Polarity set to bipolar (required)" PRINT " -- Range is from 0 to 5 volts (required)" PRINT " -- DMA channel 1 (required)" PRINT " -- On board clock set to 1 MHz (required)" PRINT " -- Also, the following jumps should be installed." PRINT " -- OP0 pin 23 to IP0 pin 25" PRINT " -- OP1 pin 4 to IP1 pin 6" PRINT " -- OP2 pin 22 to IP2 pin 24" PRINT " -- OP3 pin 3 to IP3 pin 5" PRINT " -- All remaining jumper settings are irrelevant." PRINT PRINT PRINT PRINT "Press ENTER to continue" INPUT ""; Msg$ ' Initialize Driver task% = 0 param%(1) = Address% 'assign base address param%(2) = 5 'set IRQ5 param%(3) = 1 'set DMA channel 1 GOSUB HANDLER 'program the base address and int # 'set mux channel scan limits task% = 1 param%(1) = 0 'lower channel limit is 0 param%(2) = 0 'upper channel limit is 0 GOSUB HANDLER DO CLS ' get digital output from user INPUT "INPUT A DIGITAL VALUE (0 - 15):"; param%(1) ' output the counts to the digital outputs task% = 13 GOSUB HANDLER 'read back the digital inputs task% = 14 GOSUB HANDLER PRINT PRINT USING " The value read is: ##"; param%(1) PRINT 'Wait for the operator. PRINT "Press any key to rescan the data; press the [Esc] key to Quit"; C$ = INPUT$(1) IF C$ = CHR$(27) THEN CLS SYSTEM END IF LOOP END '***************************************************************************** '* FUNCTION: HANDLER -- local routine * '* * '* PURPOSE: Performs the call to the driver package. * '* * '* INPUT: None. * '* * '* CALLS: ao16drv - entry point to driver package. * '* * '* OUTPUT: Returns the error code supplied by the driver routine. * '* * '*****************************************************************************/ HANDLER: stat% = 0 CALL A16DRV(task%, VARPTR(param%(1)), stat%) IF stat% THEN 'error has occurred PRINT "TASK"; task%; "has error code"; stat% PRINT "PROGRAM TERMINATED.." SYSTEM 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