Uses Crt; {$I SSH0XDRV.INT} Const BaseAddress : Word = $350; Function Deci(DS : String) : Word; Var BS : String; Er : Integer; DI : Word; Begin BS := '$' + DS; Val(BS, DI, Er); Deci := DI; End; Function Hex(BB : Word) : String; Var AA, CC : Byte; DD : String; HexTable : String; Begin HexTable := '0123456789ABCDEF'; DD := '000'; DD[3] := HexTable[(BB AND $00F) + 1]; DD[2] := HexTable[((BB AND $0F0) SHR 4) + 1]; DD[1] := HexTable[((BB AND $F00) SHR 8) + 1]; Hex := DD; End; Procedure ExitProgram(errorCode : Integer); Begin ClrScr; WriteLn('A fatal error occured, program halted!'); WriteLn('Error code returned was ', errorCode); End; function AskForBaseAddress(OldOne : String) : Word; const Msg : string[4] = '0'; var NewOne, Success, Dummy, Error : Word; AddrInputPosX, AddrInputPosY : Word; begin if (OldOne = 'OLD') then OldOne := Msg; WriteLn('Please enter the Base Address (0000-FFFF) for your card (in hex)'); WriteLn('or press ENTER for ', OldOne, '. '); Write('>'); AddrInputPosX := WhereX; AddrInputPosY := WhereY; repeat GotoXY(AddrInputPosX, AddrInputPosY); ClrEol; Readln(Msg); Val('$' + Msg, NewOne, Error); if (error=0) then begin Success := 1; Dummy := NewOne; end else if (Msg = '') then begin GotoXY(AddrInputPosX, AddrInputPosY); WriteLn(OldOne); Msg := OldOne; Success := 1; Val('$' + Msg, Dummy, Error); end; until (Success = 1); AskForBaseAddress := Dummy; end; { end of AskForBaseAddress } Var buf : PWord; Choice : Boolean; error, i : Word; Key : Char; Begin GetMem(buf, 8); Choice := True; ClrScr; BaseAddress := AskForBaseAddress('350'); { Prompt for base addr } error := SetBaseAddress(BaseAddress); { Tell driver base addr } WriteLn('Pascal Language Sample for SSH-0x. Version 1.06'); WriteLn; WriteLn; WriteLn('This sample will show how to use the driver in mode 0.'); WriteLn('Specs for mode 0:'); WriteLn(' Total Software control.'); WriteLn(' OP3 (PIN 10) controls HOLD.'); WriteLn; WriteLn('A/D Card setup:'); WriteLn(' Card is at base address ', Hex(BaseAddress), ' Hex.'); If (AD_NAME = AD128CARD) Then WriteLn(' Remove jumpers D0-D3 on your AD12-8 card.'); WriteLn; WriteLn('SSH-0x Card setup:'); WriteLn(' Please place the A/D CH SEL jumper at 0.'); WriteLn(' Switches A, B, and C of MODE CONTROL should all be OFF.'); If ((AD_NAME = AD128CARD) OR (AD_NAME = AD1216CARD)) Then WriteLn(' MASTER, 2, and 3 should be ON. Switches 1 and 4 should be OFF.') Else WriteLn(' MASTER, 1, and 4 should be ON. Switches 2 and 3 should be OFF.'); WriteLn; WriteLn('Press any key to continue... '); WriteLn; Key := ReadKey; ClrScr; WriteLn('The card will now be placed in Hold mode by setting OP3 high.'); WriteLn('Eight data points will be taken from the SSH-0x card, one from'); WriteLn('each channel. (If you are using an SSH-04 card, channels 4-7'); WriteLn('should be ignored). The card will then be placed back into Sample'); WriteLn('mode and the values will be displayed. Press a key to proceed...'); Key := ReadKey; ClrScr; While (Choice) Do Begin { Continue as long as user wants to } { Call driver --- Parameter list 1 : First channel is channel number 0 2 : Last channel is channel number 7 3 : Repeat for only 1 scan 4 : Trigger source is by software 5 : No initial delay 6 : Acquistion not controlled by counters, so period is 0 7 : IRQ not necessary, set to 0 8 : Use Mode 0 9 : Data buffer is buf } error := PerformSSHDataAcquisition(0,7,1,1,0,0,0,0,buf); if (error <> 0) Then Begin ExitProgram(error); Halt(error); End; ClrScr; WriteLn; WriteLn(' Channel Volts '); WriteLn; i := 0; For i := 0 To 7 Do { display data for 8 channels } WriteLn(' ', i, ' ', ((Buf^[i] * (10.0 / 4096.0)) - 5.0):6:3); { display in volts } WriteLn; WriteLn; WriteLn('Press the space bar to repeat or any other key to exit...'); Choice := ReadKey = ' '; { repeat as long as user presses the spacebar } End; WriteLn('Exiting Sample 0 Program...'); End.