'********************************************************************* '* * '* QuickBASIC SAMPLE 2:QSAMPLE2.BAS * '* * '* This sample demonstrates the use of timer driven interrrupt data * '* acquisition. Only the eight channels of the AIO8 are used. * '* * '* LAST MODIFICATION: 2/4/98 * '* * '********************************************************************* '--------------------------------------------------------------- ' This sample program requires the following setup on the Aio8 ' IRQ jumper to IRQ5, external connector pin 24 jumnper to pin 6 '--------------------------------------------------------------- ' Dimension the parameter passing variables. DIM TASK%, stat%, PARAM%(5) ' Dimension some buffers. You need data and point buffers. DIM DATBUF%(20), PNTBUF%(20) ' Place all arrays in same segment for use with driver in QB environment COMMON SHARED PARAM%(), DATBUF%(), PNTBUF%() ' This is the driver entry point declaration DECLARE SUB AIO8DRV (TASK%, BYVAL PARAM%, stat%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) CLS PRINT " SAMPLE 2 : AIO8" PRINT PRINT "This sample will display eight channels using timer driven interrupts." PRINT : PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- Base Address is "; HEX$(Address%); " hex" PRINT " -- Jumper IRQ5 should be installed (required)" PRINT " -- Jumper external connector pin 24 to pin 6 (required)" PRINT " -- All remaining jumper settings are irrelevant." PRINT : PRINT : PRINT : PRINT PRINT "Please press return to continue."; INPUT "", xx$ ' initialize the driver TASK% = 0 PARAM%(1) = Address% 'starting base address PARAM%(2) = 1 'manual initialization mode PARAM%(3) = 1 'manual gain mode for AIM-16, used when no AIM-16 GOSUB HANDLER 'program the base address and int # 'set the sample and hold settle count, used for faster computers TASK% = 11 PARAM%(1) = 5 PARAM%(2) = 25 GOSUB HANDLER ' scale each channel for milli volts, for the AIO8 range of +/- 5 volts, this ' is -5000mV to 5000mV. FOR I = 0 TO 7 TASK% = 10 PARAM%(1) = 3 PARAM%(2) = I * 16 'point address PARAM%(3) = -5000 'lower limit is -5000 mV PARAM%(4) = 5000 'upper limit is 5000 mV GOSUB HANDLER NEXT I 'set up counter 2 to supply the interrupts TASK% = 14 PARAM%(1) = 2 'counter 2 PARAM%(2) = 3 'used mode3, square wave PARAM%(3) = 5000 'divide clock by 5000 GOSUB HANDLER C$ = " " DO UNTIL C$ = CHR$(27) TASK% = 11 'TASK 11 PARAM%(1) = 1 'reset the point list index back to 0 GOSUB HANDLER ' setup the interrupt process in the driver TASK% = 9 PARAM%(1) = 1 'subtask 1 PARAM%(2) = 5 'IRQ 5 PARAM%(3) = 8 'take 8 samples PARAM%(4) = VARPTR(DATBUF%(1)) 'location to place data PARAM%(5) = VARPTR(PNTBUF%(1)) 'location to place gain/point address GOSUB HANDLER 'call driver ' wait for the driver to complete comversions TASK% = 9 PARAM%(1) = 2 'subtask 2 DO UNTIL PARAM%(2) = 0 GOSUB HANDLER 'call driver LOOP CLS ROW = 5 COL = 10 LOCATE ROW, COL: PRINT "CH DATA " ROW = ROW + 1 LOCATE ROW, COL: PRINT "--- -------" ROW = ROW + 1 FOR I = 0 TO 7 CH = (PNTBUF%(I + 1) AND &HFF00) / 256 DAT = DATBUF%(I + 1) * .001 LOCATE ROW + I, COL: PRINT USING "### ##.###"; CH; DAT NEXT I '----------------------- 'Wait for the operator. '----------------------- LOCATE ROW + 9, 10 PRINT PRINT "Press any key to rescan for data; press the [Esc] key to Quit"; C$ = INPUT$(1) LOOP CLS 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 AIO8DRV(TASK%, VARPTR(PARAM%(1)), stat%) IF stat% AND stat% <> 14 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