'********************************************************************* '* * '* QuickBASIC SAMPLE 3:QSAMPLE3.BAS * '* * '* AD12-8G Demonstration Data Acquisition Program * '* * '* This program demonstrates the following: * '* - How to initialize and configure the AD12-8G driver * '* - How to set the programmable gain amplifier on the AD12-8G * '* '* LAST MODIFED: 2/4/98 '********************************************************************* ' Dimension the parameter passing variables. DIM TASK%, STAT%, param%(5) ' Dimension some buffers. You need data and point buffers. DIM DATBUF%(200), PNTBUF%(200) COMMON SHARED param%, DATBUF%, PNTBUF% ' This is the driver entry point declaration DECLARE SUB A12GDRV (TASK%, BYVAL param%, STAT%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) '------------------------ 'Ask for the Base Address '------------------------ CLS PRINT " QSAMPLE3.BAS : AD12-8G DEMONSTRATION DATA ACQUISITION " PRINT PRINT "This program demonstrates the use of driver Task 18, Set Programmable Gain." PRINT "After prompting for a channel number, the program performs nine reads from" PRINT "the card using a gain at each read. The data is constantly refreshed until" PRINT "a key is pressed." PRINT : PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- Base Address is at "; HEX$(Address%); " hex" PRINT " -- All remaining jumper settings are irrevelant" PRINT : PRINT : PRINT PRINT "Press ENTER to scan the data" INPUT ""; Msg$ '--------------------------- ' Initialize Driver TASK% = 0 param%(1) = Address% '<- assign the base address param%(2) = 5 'interrupt number is 5 - has no effect on this sample param%(3) = 0 'No sub-multiplexer present GOSUB handler 'program the base address and int # DO UNTIL c$ = CHR$(27) CLS DO UNTIL INKEY$ <> "" x% = 0 LOCATE 1, 10 DO UNTIL x% = 8 userchan% = x% * 16 gaincode% = x% IF gaincode% <> 0 THEN gaincode% = gaincode% + 8 TASK% = 18 param%(1) = gaincode% GOSUB handler TASK% = 6 param%(1) = userchan% GOSUB handler PRINT "channel: "; x%; " with gain code: "; gaincode%; " data: "; param%(2); " " x% = x% + 1 LOOP LOOP '----------------------- 'Wait for the operator. '----------------------- LOCATE 18, 10 PRINT "Press any key to rescan the data; press the [Esc] key to Quit"; c$ = INPUT$(1) LOOP END '************************************************************* ' DRIVER HANDLER ' ' This following section of code will call the driver for you ' handling the argument passing convention, then check the ' status after it returns and provide a couple of options if ' there was an error. '************************************************************* handler: STAT% = 0 CALL A12GDRV(TASK%, VARPTR(param%(1)), STAT%) IF STAT% THEN PRINT "TASK"; TASK%; "has error code"; STAT% DO PRINT "Try to continue with program or Exit (C/E)"; INPUT ans$ ans$ = UCASE$(ans$) IF ans$ = "C" THEN EXIT DO IF ans$ = "E" THEN END LOOP 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