'********************************************************************* '* * '* QuickBASIC SAMPLE 1:QSAMPLE1.BAS * '* * '* This sample demonstrates the use of an AIM-16 sub-mulitplexer card* '* with the AIO8. It also shows how to set up the driver to measure * '* temperature and to use the reference junction on the AIM-16. * '* * '* LAST MODIFICATION: 2/4/98 * '* * '********************************************************************* ' 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 1 : AIO8" PRINT PRINT "This sample will display sixteen analog inputs." PRINT : PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- Base Address is: "; HEX$(Address%); " hex" PRINT " -- Jumper EXT should be installed (required)" PRINT " -- Jumper IRQ5 should be installed (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% 'assigning the base address PARAM%(2) = 1 'manual initialization mode PARAM%(3) = 0 'AIM-16 in programmable gain mode GOSUB handler 'program the base address and int # 'clear the point list of standard setup TASK% = 11 PARAM%(1) = 2 GOSUB handler 'assign the first 16 point addresses to point list, which represents the 'an AIM-16 attached to channle 0 of the AIO8. TASK% = 5 PARAM%(1) = 0 'start at point address 0 PARAM%(2) = 15 'end at point address 15 GOSUB handler 'set the sample and hold settle count, used for faster computers TASK% = 11 PARAM%(1) = 5 PARAM%(2) = 25 GOSUB handler 'set up point address 0 as reference junction TASK% = 10 PARAM%(1) = 2 PARAM%(2) = 0 'point address 0 PARAM%(3) = 84 'ascii T for reference junction PARAM%(4) = 70 'ascii F for degress F GOSUB handler 'set up point address 1 as t type thermocouple TASK% = 10 PARAM%(1) = 2 PARAM%(2) = 1 'point address 0 PARAM%(3) = 116 'ascii t for type t thermocouple PARAM%(4) = 70 'ascii F for degress F GOSUB handler 't type thermocouple requires a gain of 200 which is gain code 5 'set up point address 1 as t type thermocouple TASK% = 4 PARAM%(1) = 1 'point address range is 1 PARAM%(2) = 1 PARAM%(3) = 5 'gain code of 5 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 ' Get and display 16 points TASK% = 8 PARAM%(1) = VARPTR(DATBUF%(1)) 'location to place data PARAM%(2) = VARPTR(PNTBUF%(1)) 'location to place gain/point address PARAM%(3) = 16 'requested # of samples GOSUB handler 'call driver CLS ROW = 5 COL = 10 LOCATE ROW, COL: PRINT "CH DATA GAIN" ROW = ROW + 1 LOCATE ROW, COL: PRINT "--- ------- ----" ROW = ROW + 1 FOR I = 0 TO 15 CH = (PNTBUF%(I + 1) AND &HFF00) / 256 DAT = DATBUF%(I + 1) * .1 GAIN = PNTBUF%(I + 1) AND &HFF LOCATE ROW + I, COL: PRINT USING "## ###.# #"; CH; DAT; GAIN NEXT I '----------------------- 'Wait for the operator. '----------------------- LOCATE ROW + 16, 10 PRINT PRINT "Press any key to rescan for 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 AIO8DRV(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