unit Main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ExtCtrls, StdCtrls; type TMainForm = class(TForm) GroupRange: TRadioGroup; GroupOutput: TGroupBox; Value: TTrackBar; LOutput: TLabel; Label2: TLabel; GroupChannel: TRadioGroup; StatusBar1: TStatusBar; Memo1: TMemo; ExitButton: TButton; Initialize: TButton; ISAPanel: TGroupBox; Label1: TLabel; ISAEdit: TEdit; procedure UpdateDAC; function ConvertForOutput(V:longword):longword; procedure ValueChange(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ExitButtonClick(Sender: TObject); procedure InitializeClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure GroupRangeClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var MainForm: TMainForm; implementation {$R *.DFM} uses ACCES32; //global variables for internal use const span:double=-10.0; Offset:double=-5; CurVal:word=0; maxch:integer=2; var Address : WORD; RunFlag:Boolean; function TMainForm.ConvertForOutput(v:longword):longword; var i:integer; begin v:=v;//bipolar ranges are inverted offset binary if (GroupChannel.ItemIndex < maxch) then //the last item in the channel list is ALL outport(Address+(GroupChannel.ItemIndex*2),v*16) else //"all channels" is selected, use simul mode for i:=0 to maxch-1 do outport(Address+(i*2)+4,v*16);//use simul mode result:=v; end; function IntToBin(input:longword):string; var temp:string; i:word; f:double; begin //this for loop converts to binary temp:=''; for i:=11 downto 0 do begin if (input AND (1 shl i))=0 then temp:=temp+'0' else temp:=temp+'1'; end;//for; temp:=temp+'xxxx'; f:=((input) * span / 4096 - offset);//volts temp:=temp+' '+inttohex(input,3)+' '+floattostrf(f,ffFixed,6,3); if (MainForm.GroupRange.ItemIndex=4) then result:=temp+' mA' else result:=temp+' Volts'; end; procedure TMainForm.UpdateDAC; begin LOutput.Caption:=IntToBin(ConvertForOutput(CurVal)); end; procedure TMainForm.ValueChange(Sender: TObject); begin CurVal:=value.position; UpdateDAC; end; procedure TMainForm.FormCreate(Sender: TObject); var i: Integer; begin GroupChannel.Items.Clear;//create channel list for i:=1 to maxch do GroupChannel.Items.Append('Channel '+inttostr(i-1)); GroupChannel.Items.Append('All Channels'); GroupChannel.ItemIndex:=0; memo1.lines.append(''); memo1.lines.append('Please configure the dialog options shown to reflect the'+ ' settings on the card that is installed. The card''s output voltage shown'+ ' onscreen will only be correct if these settings are correct.'+ ' Refer to the card''s manual for specifics about jumper settings and switches.'); Memo1.ScrollBars:=ssVertical; 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 TMainForm.ExitButtonClick(Sender: TObject); begin close; end; procedure TMainForm.InitializeClick(Sender: TObject); var code,data:integer; begin {$R-} val('$'+ISAEdit.Text,data,code); {$R+} if ((data>$100) and (data<$3ff)) then begin Address:=data; runflag:=True; end else Beep; if runflag then begin GroupOutput.visible:=True; GroupOutput.enabled:=True; end; end; procedure TMainForm.FormActivate(Sender: TObject); begin FocusControl(IsaEdit); end; procedure TMainForm.GroupRangeClick(Sender: TObject); begin case GroupRange.itemindex of 0:begin offset:=-5;span:=-10;end; 1:begin offset:=-10;span:=-20;end; 2:begin offset:=0;span:=5;end; 3:begin offset:=0;span:=10;end; 4:begin offset:=-4;span:=16;end; end;//case UpdateDAC; end; end.