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 := True; 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 4.'); WriteLn('Specs for mode 4:'); WriteLn(' Software initiated (SEL3).'); 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(' Switches A and B should be OFF, 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 (PIN 10) high. The SSH-0x'); WriteLn('card will then gather eight data points, one from each channel.'); WriteLn('(If you are using an SSH-04 card, channels 4-7 should be ignored).'); WriteLn('When acquisition is completed, the card will be placed back into'); WriteLn('sample mode and the values will be displayed.'); WriteLn('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; 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 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 4 9 : Data buffer is buf } Sample; error := PerformSSHDataAcquisition(0,7,2,1,0,LoadValue,0,4,buf); if (error <> 0) Then Begin ExitProgram(error); Halt(error); End; EnableHold; 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('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 4 Program...'); End.