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 = 1 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 2." PRINT "Specs for mode 2:" PRINT " Software initiated (SEL3)." 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 " Switches B should be ON, A and C should be OFF 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 (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 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 WHILE 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 software ' 5 : No initial delay ' 6 : Acquistion controlled by counters, so period is LoadValue ' 7 : IRQ not necessary, set to 0 ' 8 : Use Mode 2 ' 9 : Data buffer is buf CALL Sample ErrorCode = PerformSSHDataAcquisition(0, 7, 2, 1, 0, LoadValue, 0, 2, VARSEG(Buf(1)), VARPTR(Buf(1))) IF (ErrorCode <> 0) THEN CALL ExitProgram CALL EnableHold 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 "Press the space bar to repeat or any other key to exit..." WhatKey$ = "" WHILE WhatKey$ = "" WhatKey$ = INKEY$ WEND IF WhatKey$ = " " THEN Choice = 1 ELSE Choice = 0 ' repeat as long ' as user presses ' the spacebar WEND PRINT "Exiting Sample 2 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