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; LoadValue : Word; Begin GetMem(buf, 16); Choice := False; ClrScr; BaseAddress := AskForBaseAddress('350'); { Prompt for base addr } error := SetBaseAddress(BaseAddress); { Tell driver base adr } WriteLn('Pascal Language Sample for SSH-0x. Version 1.06'); WriteLn; WriteLn; WriteLn('This sample will show how to use the driver in mode 6.'); WriteLn('Specs for mode 6:'); WriteLn(' External Trigger initiated.'); WriteLn(' Hardware timed periodic acquisition, w/o initial delay.'); WriteLn(' Process is gated by SEL3.'); WriteLn; WriteLn('A/D Card setup:'); WriteLn(' Card is at base address ', Hex(BaseAddress), ' Hex.'); WriteLn; WriteLn('SSH-0x Card setup:'); WriteLn(' Please place the A/D CH SEL jumper at 0.'); WriteLn(' Switch A should be OFF, B and C should be ON on MODE CONTROL.'); 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('Hold will be enabled by setting OP3 high.'); WriteLn('When you set EXTTRG low, eight data points will be taken from'); WriteLn('the SSH-0x card, one from each channel. (If you are using an'); WriteLn('SSH-04 card, channels 4-7 should be ignored). When EXTTRG is'); WriteLn('set high again the card will then be placed back into Sample mode'); WriteLn('and the values will be displayed. Press a key to proceed...'); Key := ReadKey; ClrScr; { The clock input is 1Mhz for the AD12-8G card, because of this, the input to the second counter will be 500000Hz. A load value of 50000 is required to achieve a 10Hz sampling rate. } If AD_NAME = AD128GCARD Then LoadValue := 50000; { The same applies to the AIO8 card. } If AD_NAME = AIO8CARD Then LoadValue := 50000; WriteLn('Set external trigger (EXTTRG) low to start, or press a key to exit.'); Repeat Until (ReadTriggerStatus <> 0); While (NOT 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 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 6 9 : Data buffer is buf } error := PerformSSHDataAcquisition(0,7,2,0,0,LoadValue,0,6,buf); if (error <> 0) Then Begin ExitProgram(error); Halt(error); End; EnableHold; ClrScr; If (ReadTriggerStatus = 1) Then Begin WriteLn('You must release the trigger to continue.'); Repeat Until (ReadTriggerStatus = 0); End; ClrScr; WriteLn(' Pass 1 Pass 2 '); WriteLn(' Channel Volts Channel Volts '); WriteLn; i := 0; For i := 0 To 7 Do { display data for 8 channels } { display in volts } WriteLn(' ', i, ' ',((Buf^[i] * (10.0 / 4096.0)) - 5.0):6:3, ' ', i, ' ',((Buf^[i + 8] * (10.0 / 4096.0)) - 5.0):6:3); WriteLn; WriteLn; WriteLn; WriteLn; WriteLn('Set external trigger (EXTTRG) low to continue or press a key'); WriteLn('to exit.'); Repeat Choice := Keypressed; { repeat as long as user doesn't press a key } Until ((ReadTriggerStatus = 1) OR Choice); End; WriteLn('Exiting Sample 6 Program...'); End.