'********************************************************************* '* * '* QuickBASIC SAMPLE 5:QSAMPLE5.BAS * '* * '* AD12-8G Demonstration Data Acquisition Program * '* * '* This program demonstrates the following: * '* - How to initialize and configure the AD12-8G driver * '* - How to use Task 20 to measure frequency * '* '* LAST MODIFIED: 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) 'Main Program CLS PRINT " QSAMPLE5.BAS : AD12-8G MEASURE FREQUENCY" PRINT PRINT "This sample demonstrates the use task 20 to measure the frequency" PRINT "of an unknown TTL waveform." PRINT PRINT Address% = AskForBaseAddress!(&H350) CLS PRINT : PRINT : PRINT PRINT "Board Configuration:" PRINT PRINT " -- The Base Address is at "; HEX$(Address%); " hex" PRINT " -- The sub-multiplexer is set to programmable gains (required)" PRINT " -- The following connections must be made: (required)" PRINT " PIN 4 (CLK1) TO PIN 6 (OUT2)" PRINT " PIN 5 (OUT1) TO PIN 26 (IP2) AND PIN 21 (GATE0)" PRINT " -- Connect the unknown waveform to PIN 2 (CLK0) and PIN 11 (COMMON)" PRINT " -- All remaining jumper settings are irrelevant" PRINT : PRINT : PRINT : PRINT PRINT "Press any key to start." C$ = INPUT$(1) '--------------------------- ' 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) = 1 'programmable gains on the sub-multiplexer GOSUB handler 'program the base address and int # DO UNTIL C$ = CHR$(27) CLS TASK% = 20 param%(1) = 1000 GOSUB handler PRINT "The frequency is "; param%(2) '----------------------- 'Wait for the operator. '----------------------- PRINT "Press any key to rescan the data; press the [Esc] key to Quit"; C$ = INPUT$(1) PRINT 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