'***************************************************************************** '* SAMPLE1.BAS : DATA ACQUISITION USING POLLING * '* LAST MODIFICATION: 2/3/98 * '*****************************************************************************/ ' Dimension the paramter passing variables. DIM task%, stat%, param%(7) COMMON SHARED param%() ' Dimension some buffers. You need data and point buffers. DIM datbuf%(200) COMMON SHARED datbuf%() DIM pntbuf%(200) COMMON SHARED pntbuf%() ' This is the driver entry point declaration DECLARE SUB AA16DRV (task%, BYVAL param%, stat%) DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) CLS PRINT " SAMPLE1.BAS : DATA ACQUISITION USING POLLING" PRINT PRINT "The program will display sixteen channels using polling." PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- Base address is "; HEX$(Address%); " hex" PRINT " -- Polarity set to bipolar -- S2 TO BIP (required)" PRINT " -- 16 channel single ended mode -- S3 TO 16CH (required)" PRINT " -- Both TMP jumpers must be installed (required)" PRINT " -- The offset must be on standard (STD) position (required)" PRINT " -- One jumper must be on position OV0; none on OT (required)" PRINT " -- All other jumper settings are irrelevant" PRINT PRINT : PRINT PRINT "Press ENTER to continue" INPUT ""; Msg$ ' Initialize Driver task% = 0 param%(1) = Address% 'set base address param%(2) = 5 'voltage range is 5 GOSUB HANDLER ' Set the sample and hold settle count, this is only required for faster ' machines, such as 386's task% = 11 param%(1) = 5 'sub task 5, set settle count param%(2) = 50 '50 settle counts GOSUB HANDLER ' Clear the point list task% = 11 param%(1) = 2 'sub task 2, clear point list GOSUB HANDLER ' Assign the first 16 point addresses to the point list, these correspond to ' a single AIM-16P attached to channel 0 of the A/D task% = 5 param%(1) = 0 'lower point address in range param%(2) = 15 'upper point address in range GOSUB HANDLER ' Assign reference junction to point address 0 task% = 10 param%(1) = 2 'sub task 2, assign curve to point address param%(2) = 0 'assign point address 0 param%(3) = 84 'ASCII T = reference junction param%(4) = 70 'ASCII F = degrees F for unit of measure GOSUB HANDLER ' Assign a type "t" thermocouple to point address 1 task% = 10 param%(1) = 2 'sub task 2, assign curve to point address param%(2) = 1 'assign point address 1 param%(3) = 116 'ASCII t = type t thermocouple param%(4) = 70 'ASCII F = degrees F for unit of measure GOSUB HANDLER ' Assign proper gain code for the thermocouple task% = 4 param%(1) = 1 'lower point address in range param%(2) = 1 'upper point address in range param%(3) = 5 'gain code of 5 for t type thermocouples GOSUB HANDLER ' execute this loop until user enters and ESC at the prompt DO ' Reset point list index to start of point list task% = 11 param%(1) = 1 'sub task 1, reset point list index GOSUB HANDLER ' Gather point data via polling, routine will not exit until all ' conversions have occured CLS task% = 8 param%(1) = VARPTR(datbuf%(1)) 'offset of data buffer param%(2) = VARPTR(pntbuf%(1)) 'offset of point buffer param%(3) = 16 'take 16 conversions GOSUB HANDLER ' Write the results to the screen CLS PRINT " POINT ADDRESS GAIN DATA" PRINT " ------------- ---- -----" FOR I = 1 TO 16 PRINT USING " ## # #####"; pntbuf%(I) / 256; pntbuf%(I) AND 255; datbuf%(I) NEXT I ' Wait for the user. PRINT 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: aa16drv - entry point to driver package. * '* * '* OUTPUT: Returns the error code supplied by the driver routine. * '* * '*****************************************************************************/ HANDLER: stat% = 0 CALL AA16DRV(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