unit sample0u; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls; type TSample0Form = class(TForm) CardName: TLabel; Memo1: TMemo; ExitButton: TButton; ISAPanel: TGroupBox; HexLabel: TLabel; BaseEdit: TEdit; TestButton: TButton; TestTimer: TTimer; 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; TitleLabel: TLabel; 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; { end ExitButtonClick } 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); { Get User inputted base address } for channel := 0 to 15 do begin { Set Channel } OutPortB(base+2, (InPortB(base+2) and $F0) + channel); { Reset EOC interrupt } OutPortB(base+1, 0); { Start A/D conversion } OutPortB(base, 0); { Wait for EOC or timeout } i := 0; while ( ((InPortB(base+2) and $80) < $80) and (i <= 1000) ) do i := i + 1; { if timeout display error and exit program } if (i > 1000) then begin ErrorStatus.SimpleText := Format('Error: Timeout on channel %1x', [channel]); exit; end; { end if } { Get count data } counts := InPortB(base); { Scaling 5v range on 8 bit device = 0.039 volts/count } volts := (counts - 128) * 0.039; { Show data } (ChannelBox.Controls[channel] as TLabel).Caption := Format(' Channel %1x %4d %12.3f',[channel,counts,volts]); end; { end of for channel } 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.