DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) DECLARE FUNCTION CheckForBusy% (Baseaddr AS INTEGER) '**************************************************************************** ' Sample 0 '**************************************************************************** CLS TimeOut = 655354 PRINT "Sample 0" PRINT PRINT "This program will read data from all channels on the A/D card." Address% = AskForBaseAddress!(&H340) PRINT LOCATE 19, 1 PRINT "Press any key to exit." OUT Address% + 2, 0 OUT Address% + 0, &H4 ' wait for start conversion WHILE (INKEY$ = "") SLEEP 1 LOCATE 10, 1 FOR chan = 0 TO 7 TimeOut = 655354 OUT Address% + 2, chan FOR waste = 1 TO 6000: NEXT OUT Address% + 3, 0 WHILE (CheckForBusy%(Address%) AND (TimeOut > 0)) TimeOut = TimeOut - 1 WEND IF (TimeOut = 0) THEN PRINT "A/D timeout"; Data1 = INP(Address% + 6) Data2 = INP(Address% + 7) ' convert two bytes to word by converting to hex DataRead% = VAL("&H" + LEFT$(HEX$(Data2) + HEX$(Data1), 3)) PRINT "Chan "; chan; " Data Read: "; DataRead%; " " NEXT chan WEND LOCATE 20, 1 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 CheckForBusy% (Baseaddr AS INTEGER) CheckForBusy% = ((INP(Baseaddr + 2) AND &H80) = &H80) END FUNCTION