unit Sample0Unit; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, StdCtrls; type TSample0Form = class(TForm) CardName: TLabel; Memo1: TMemo; ExitButton: TButton; ISAPanel: TGroupBox; HexLabel: TLabel; BaseEdit: TEdit; TestButton: TButton; ChannelBox: TGroupBox; ChannelLabel0: TLabel; ChannelLabel1: TLabel; ChannelLabel2: TLabel; ChannelLabel3: TLabel; ChannelLabel4: TLabel; ChannelLabel5: TLabel; ChannelLabel6: TLabel; ChannelLabel7: TLabel; TitleLabel: TLabel; Label1: TLabel; Label2: TLabel; CountsLabel0: TLabel; CountsLabel1: TLabel; CountsLabel2: TLabel; CountsLabel3: TLabel; CountsLabel4: TLabel; CountsLabel5: TLabel; CountsLabel6: TLabel; CountsLabel7: TLabel; VoltsLabel1: TLabel; VoltsLabel2: TLabel; VoltsLabel3: TLabel; VoltsLabel4: TLabel; VoltsLabel5: TLabel; VoltsLabel6: TLabel; VoltsLabel7: TLabel; VoltsLabel0: TLabel; ErrorStatus: TStatusBar; TestTimer: TTimer; procedure FormCreate(Sender: TObject); procedure ExitButtonClick(Sender: TObject); procedure TestButtonClick(Sender: TObject); procedure TestTimerTimer(Sender: TObject); published function CheckForEOC(Address: Integer): Boolean; private { Private declarations } public { Public declarations } end; var Sample0Form: TSample0Form; CountsLabels: array[0..7] of TLabel; VoltsLabels: array[0..7] of TLabel; Address: LongWord; implementation uses ACCES32; {$R *.DFM} procedure TSample0Form.FormCreate(Sender: TObject); begin CountsLabels[0] := CountsLabel0; CountsLabels[1] := CountsLabel1; CountsLabels[2] := CountsLabel2; CountsLabels[3] := CountsLabel3; CountsLabels[4] := CountsLabel4; CountsLabels[5] := CountsLabel5; CountsLabels[6] := CountsLabel6; CountsLabels[7] := CountsLabel7; VoltsLabels[0] := VoltsLabel0; VoltsLabels[1] := VoltsLabel1; VoltsLabels[2] := VoltsLabel2; VoltsLabels[3] := VoltsLabel3; VoltsLabels[4] := VoltsLabel4; VoltsLabels[5] := VoltsLabel5; VoltsLabels[6] := VoltsLabel6; VoltsLabels[7] := VoltsLabel7; 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; procedure TSample0Form.ExitButtonClick(Sender: TObject); begin Close; end; procedure TSample0Form.TestButtonClick(Sender: TObject); begin if (TestTimer.Enabled = True) then begin TestTimer.Enabled := False; ErrorStatus.SimpleText := ''; TestButton.Caption := 'Start Test'; BaseEdit.Enabled := True; end // end if else begin Address := StrToInt('$' + BaseEdit.Text); TestButton.Caption := 'Abort Test'; BaseEdit.Enabled := False; TestTimer.Enabled := True; end; // end else end; procedure TSample0Form.TestTimerTimer(Sender: TObject); var chan, counts: Integer; timeout: LongWord; volts: Double; begin for chan := 0 to 7 do begin timeout := 65535; OutPortB(Address + 2, chan or $08); // write channel while (not(CheckForEOC(Address)) and (timeout > 0)) do dec(timeout); if (timeout = 0) then begin ErrorStatus.SimpleText := 'A/D timeout on Channel ' + IntToStr(chan); CountsLabels[chan].Caption := 'A/D Timeout'; VoltsLabels[chan].Caption := 'A/D Timeout'; end // end if timeout else begin counts := InPort(Address + 2) and $0FFF; volts := ((counts xor $800) - $800) * 0.00244; CountsLabels[chan].Caption := IntToStr(counts); VoltsLabels[chan].Caption := FloatToStr(volts); end; // end else end; // end for chan end; function TSample0Form.CheckForEOC(Address: Integer): boolean; var EOCCheck: Byte; begin EOCCheck := InPortB(Address); result := ((EOCCheck and $80) = $80); end; end.