unit sample0u; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls; type TSample0Form = class(TForm) CardName: TLabel; Memo1: TMemo; ExitButton: TButton; ISAPanel: TGroupBox; HexLabel: TLabel; BaseEdit: TEdit; TestButton: TButton; TestTimer: TTimer; ChannelBox: TGroupBox; ChannelLabel1: TLabel; ChannelLabel2: TLabel; ChannelLabel3: TLabel; ChannelLabel4: TLabel; ChannelLabel5: TLabel; ChannelLabel6: TLabel; ChannelLabel7: TLabel; ChannelLabel8: TLabel; TitleLabel: TLabel; ErrorStatus: TStatusBar; procedure ExitButtonClick(Sender: TObject); procedure TestButtonClick(Sender: TObject); procedure TestTimerTimer(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Sample0Form: TSample0Form; implementation uses ACCES32; {$R *.DFM} procedure TSample0Form.ExitButtonClick(Sender: TObject); begin Close(); end; procedure TSample0Form.TestButtonClick(Sender: TObject); var x : integer; begin if TestTimer.Enabled = True then begin TestTimer.Enabled := False; for x := 0 to 7 do (ChannelBox.Controls[x] as TLabel).Caption := Format(' Channel %1d 0 0',[x]); ErrorStatus.SimpleText := ''; TestButton.Caption := 'Start Test'; end else begin TestTimer.Enabled := True; TestButton.Caption := 'Abort Test'; end end; procedure TSample0Form.TestTimerTimer(Sender: TObject); var base : Word; channel, counts, i, j: integer; volts : Double; RangeString : String; begin base := StrToInt('$'+BaseEdit.Text); for channel := 0 to 7 do begin OutPortB(base+2, channel); // Set channel if (channel mod 2 = 0) then begin // Set gain: OutPortB(base+3, $00); // +/-5v range on even chans RangeString := '±5V'; end // end if else begin OutPortB(base+3, $08); // +/-10v range on odd chans RangeString := '±10V'; end; // end else for i := 0 to 32000 do; // Wait for settle count, this is an empty loop OutPortB(base+1, 0); // Start A/D conversion j := 0; // Wait for EOC or timeout while (((InPortB(base+2) and $80) >= $80) and (j < 32000)) do j := j+1; if j >= 32000 then begin ErrorStatus.SimpleText := Format('Timeout on Channel %1x',[channel]); exit; end; // end if counts := InPort(base) shr 4; { Read count data } { Scaling 5v range on 12 bit device = 0.00244v/count } volts := (counts-2048.0)*0.00244; { Display results } (ChannelBox.Controls[channel] as TLabel).Caption := Format(' Channel %1x %4d %12.3f %4s',[channel,counts,volts,RangeString]); end; { end for } end; { end TestTimerTimer } procedure TSample0Form.FormCreate(Sender: TObject); begin if (InPortB($61) = $AA55) then begin Application.MessageBox('ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.', 'Warning', IDOK); end; end; end.