DECLARE FUNCTION AskForBaseAddress% (OldOne AS INTEGER) DECLARE FUNCTION Deci% (DS AS STRING) DECLARE SUB ExitProgram () DIM SHARED ErrorCode ' $INCLUDE: 'SSH0XDRV.INC' BaseAddress% = &H350 DIM Buf(1 TO 16) AS INTEGER Choice = 0 CLS BaseAddress = AskForBaseAddress(BaseAddress%) ' Prompt for base addr ErrorCode = SetBaseAddress(BaseAddress%) ' Tell driver base addr CLS PRINT "Microsoft QuickBasic Language Sample for SSH-0x. Version 1.06" PRINT PRINT PRINT "This sample will show how to use the driver in mode 3." PRINT "Specs for mode 3:" PRINT " External Trigger initiated." PRINT " Hardware timed periodic acquisition, w/o initial delay." PRINT " Process is gated by SEL3." PRINT PRINT "A/D card setup:" PRINT " Card is at base address "; HEX$(BaseAddress); "." IF (ADNAME = AD128CARD) THEN PRINT " Remove jumpers D0-D3 on your AD12-8 card." PRINT PRINT "SSH-0x card setup:" PRINT " Please place the A/D CH SEL jumper at 0." PRINT " Switch C should be OFF, A and B should be ON on MODE CONTROL." PRINT " MASTER, 2, and 3 should be ON. Switches 1 and 4 should be OFF. " PRINT PRINT "Press any key to continue... " WHILE INKEY$ = "" WEND CLS PRINT "Hold will be enabled by setting OP3 high." PRINT "When you set EXTTRG low, eight data points will be taken from" PRINT "the SSH-0x card, one from each channel. (If you are using an" PRINT "SSH-04 card, channels 4-7 should be ignored). When EXTTRG is set high" PRINT "again the card will then be placed back into Sample mode and the" PRINT "values will be displayed. Press a key to proceed..." WHILE INKEY$ = "" WEND CLS ' The clock input for the AD12-8 card is 14.318Mhz / 32 ' The first counter is loaded with the value 2, so that the input ' to the second counter is approximately 223721.5908Hz ' With a load value of 22372, we will get a 10Hz sampling rate. IF ADNAME = AD128CARD THEN LoadValue = 22372 ' Assuming the clock jumper is set for a 1Mhz input, the input to ' the second counter will be 500000Hz. A load value of 50000 is ' required to achieve a 10Hz sampling rate. IF ADNAME = AD1216CARD THEN LoadValue = 50000 PRINT "Set external trigger (EXTTRG) low to start, or press a key to exit." WHILE NOT Choice ' Call driver ' Parameter list ' 1 : First channel is channel number 0 ' 2 : Last channel is channel number 7 ' 3 : Repeat for 2 passes ' 4 : Trigger source is by EXTTRG going low ' 5 : No initial delay ' 6 : Acquistion controlled by counters, so period is LoadValue ' 7 : IRQ not necessary, set to 0 ' 8 : Use Mode 3 ' 9 : Data buffer is buf ErrorCode = PerformSSHDataAcquisition(0, 7, 2, 0, 0, LoadValue, 0, 3, VARSEG(Buf(1)), VARPTR(Buf(1))) IF (ErrorCode <> 0) THEN CALL ExitProgram CALL EnableHold CLS IF (ReadTriggerStatus = 1) THEN PRINT "You must release the trigger to continue." WHILE ReadTriggerStatus = 1 WEND END IF CLS PRINT PRINT " Pass 1 Pass 2" PRINT " Channel Volts Channel Volts" PRINT i = 0 FOR i = 1 TO 8 ' display data for 8 channels PRINT " "; i; " "; PRINT USING "+#.###"; ((Buf(i) * (10! / 4096!)) - 5!); ' display in volts PRINT " "; i, " "; ((Buf(i + 8) * (10! / 4096!)) - 5!) NEXT i PRINT PRINT PRINT PRINT PRINT "Set external trigger (EXTTRG) low to continue or press a key" PRINT "to exit." WhatKey$ = "" WHILE (WhatKey$ = "") AND (ReadTriggerStatus = 0) WhatKey$ = INKEY$ WEND IF WhatKey$ = "" THEN Choice = 0 ELSE Choice = 1 ' repeat as long ' as user presses ' the spacebar WEND PRINT "Exiting Sample 3 Program..." 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 FUNCTION Deci% (DS AS STRING) Deci% = VAL("&H" + DS) END FUNCTION SUB ExitProgram PRINT "ErrorCode: "; ErrorCode END END SUB