unit sample0u; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, StdCtrls; type TSample0Form = class(TForm) TitleLabel: TLabel; CardName: TLabel; Memo1: TMemo; ExitButton: TButton; ISAPanel: TGroupBox; HexLabel: TLabel; BaseEdit: TEdit; TestButton: TButton; ErrorStatus: TStatusBar; ChannelBox: TGroupBox; ChannelLabel1: TLabel; ChannelLabel2: TLabel; ChannelLabel3: TLabel; ChannelLabel4: TLabel; ChannelLabel5: TLabel; ChannelLabel6: TLabel; ChannelLabel7: TLabel; ChannelLabel8: TLabel; ChannelLabel9: TLabel; ChannelLabel10: TLabel; ChannelLabel11: TLabel; ChannelLabel12: TLabel; ChannelLabel13: TLabel; ChannelLabel14: TLabel; ChannelLabel15: TLabel; ChannelLabel16: TLabel; TestTimer: TTimer; 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 15 do (ChannelBox.Controls[x] as TLabel).Caption := Format(' Channel %1x 0 0',[x]); ErrorStatus.SimpleText := ''; TestButton.Caption := 'Start Test'; end else begin TestTimer.Enabled := True; TestButton.Caption := 'Abort Test'; end end; { end TestButtonClick } procedure TSample0Form.TestTimerTimer(Sender: TObject); var base : Word; channel, counts, i : integer; volts : Double; begin base := StrToInt('$'+BaseEdit.Text); OutPortB(base+2, $F0); { Set scan from Ch0 to Ch15 } repeat OutPortB(base, 0); { Start A/D conversion } i := 0; { Wait for EOC or timeout } while ( ((InPortB(base+8) and $80) = $80) and (i < 32000) ) do i := i+1; if (i >= 32000) then begin { if timeout, display error & quit } channel := InPortB(base) and $0F; ErrorStatus.SimpleText := Format('Error: Timeout on channel %1x', [channel]); exit; end; { end if } channel := InPortB(base) and $0F; { Get channel number } counts := InPort(base) shr 4; { Get channel counts } { Scaling 5v range on 12 bit device = 0.00244v/count } volts := (counts-2048)*0.00244; (ChannelBox.Controls[channel] as TLabel).Caption := Format(' Channel %1x %4d %12.3f',[channel,counts,volts]); until ((InPort(base) and $0F) = $0F); { end repeat } 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.