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 7." PRINT "Specs for mode 7:" PRINT " External Trigger (EXTTRG) initiated." PRINT " Hardware timed periodic acquisition, with delay." PRINT " Process is gated by SEL3." PRINT PRINT "A/D card setup:" PRINT " Card is at base address "; HEX$(BaseAddress); "." PRINT PRINT "SSH-0x card setup:" PRINT " Please place the A/D CH SEL jumper at 0." PRINT " Switch A, B, and C should be ON on MODE CONTROL." PRINT " MASTER, 1, and 4 should be ON. Switches 2 and 3 should be OFF." PRINT PRINT "Press any key to continue... " WHILE INKEY$ = "" WEND CLS PRINT "After the user sets external trigger (EXTTRG) to ground," PRINT "counter 1 will be loaded with an initial count and will count" PRINT "down until it reaches zero. When it does, the following will" PRINT "occur:" PRINT "Hold will be enabled by setting OP3 (PIN 10) high. The SSH-0x" PRINT "card will then gather eight data points, one from each channel." PRINT "(If you are using an SSH-04 card, channels 4-7 should be ignored)." PRINT "When acquisition is completed, the card will be placed back into" PRINT "Sample mode and the values will be displayed." PRINT "Press a key to proceed..." WHILE INKEY$ = "" WEND CLS ' The clock input is 1MHz for the AD12-8G card, because of this, the input ' to the second counter will be 500,000Hz. A load value of 50000 is ' required to achieve a 10Hz sampling rate. IF ADNAME = AD128GCARD THEN LoadValue = 50000 ' The desired initial delay is 100ms. This requires a load value of 50000. IF ADNAME = AD128GCARD THEN InitDelay = 50000 ' The same applies to the AIO8 card. IF ADNAME = AIO8CARD THEN LoadValue = 50000 IF ADNAME = AIO8CARD THEN InitDelay = 50000 PRINT "Set external trigger (EXTTRG) low to start, or press a key to exit." WHILE ReadTriggerStatus = 1 WEND 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 : Initial delay is 100ms ' 6 : Acquistion controlled by counters, so period is LoadValue ' 7 : IRQ not necessary, set to 0 ' 8 : Use Mode 7 ' 9 : Data buffer is buf CALL Sample PRINT "Waiting for terminal count (about 100ms)...press a key to abort" ErrorCode = PerformSSHDataAcquisition(0, 7, 2, 0, InitDelay, LoadValue, 0, 7, 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 7 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