unit Sample0; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, aio1616f, acces32, ComCtrls; type TForm1 = class(TForm) Label1: TLabel; Addr: TEdit; BeginBTN: TButton; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; GroupBox1: TGroupBox; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; chnl0EDIT: TEdit; chnl1EDIT: TEdit; chnl2EDIT: TEdit; chnl4EDIT: TEdit; chnl3EDIT: TEdit; chnl5EDIT: TEdit; chnl6EDIT: TEdit; chnl7EDIT: TEdit; chnl8EDIT: TEdit; chnl9EDIT: TEdit; chnl10EDIT: TEdit; chnl11EDIT: TEdit; chnl12EDIT: TEdit; chnl13EDIT: TEdit; chnl14EDIT: TEdit; chnl15EDIT: TEdit; Timer1: TTimer; Label18: TLabel; Label19: TLabel; dac0EDIT: TEdit; dac1EDIT: TEdit; dac0LBL: TLabel; dac1LBL: TLabel; dac0Spin: TUpDown; dac1SPIN: TUpDown; Stop: TButton; procedure FormActivate(Sender: TObject); procedure BeginBTNClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure dac0SpinClick(Sender: TObject; Button: TUDBtnType); procedure dac1SPINClick(Sender: TObject; Button: TUDBtnType); procedure StopClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; channels : integer; dac0mult, dac1mult :double; implementation {$R *.DFM} procedure TForm1.FormActivate(Sender: TObject); begin Addr.text := '300'; end; procedure TForm1.BeginBTNClick(Sender: TObject); begin //Get the address from the user and initialize the global variables and // then calibrate the card BASE :=strtoint('$' + addr.text); init; doCAL; //determine if card is in single ended or differential mode if (jumpers and $1) = 1 then channels := 16 else channels := 8 ; //determine the dac range and output it to the user if (dacArange and $1) = 1 then dac0LBL.Caption := 'DAC 0 output range is 0 to 5 volts' else dac0LBL.Caption := 'DAC 0 output range is 0 to 10 volts' ; if (dacBrange and $1) = 1 then dac1LBL.Caption := 'DAC 1 output range is 0 to 5 volts' else dac1LBL.Caption := 'DAC 1 output range is 0 to 10 volts' ; //tell the board which channels we are interested in. bits 0-3 are the start // channel and bits 4-7 are the end channel OutPortB(BASE + $02, (channels - 1) * $10); //start the timer Timer1.Enabled := true; end; procedure TForm1.Timer1Timer(Sender: TObject); var count : integer; bpAdjust : double; gainAdjust : double; value : double; begin timer1.Enabled := false; //determine the range and if the card is unipolar or bipolar // this is used to convert the counts to volts If ((jumpers shr 1) And $1) = 1 Then bpAdjust := 0.5 Else bpAdjust := 0.0 ; If ((jumpers shr 2) And $1) = 1 Then gainAdjust := 10.0 Else gainAdjust := 20.0 ; //tell the card to take one reading per channel for count := 0 to (channels - 1) do OutPortB(BASE, 0); //read the values from the FIFO, convert to volts, and display // to the user value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl0EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl1EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl2EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl3EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl4EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl5EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl6EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl7EDIT.Text := floattostr(value); if channels = 16 then begin value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl8EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl9EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl10EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl11EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl12EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl13EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl14EDIT.Text := floattostr(value); value := ((InPort(BASE)/65536.0) - bpAdjust) * gainAdjust; chnl15EDIT.Text := floattostr(value); end; //output the dac values and then put outputted values to screen if (dacArange and $1) = 1 then value := DAC(0, dac0mult * 0.49) else value := DAC(0, dac0mult * 0.99) ; dac0edit.Text := floattostr(value); if (dacBrange and $1) = 1 then value := DAC(1, dac1mult * 0.49) else value := DAC(1, dac1mult * 0.99) ; dac1edit.Text := floattostr(value); timer1.Enabled := true; end; //adjust the multiplier for the DAC based on the user clicking the spinnner // buttons procedure TForm1.dac0SpinClick(Sender: TObject; Button: TUDBtnType); begin //do stuff if Button = btNext then dac0mult := dac0mult + 1.0 else dac0mult := dac0mult - 1.0 ; if dac0mult > 10.0 then dac0mult := 0.0 else if dac0mult < 0.0 then dac0mult := 10.0 ; ; end; //adjust the multiplier for the DAC based on the user clicking the spinnner // buttons procedure TForm1.dac1SPINClick(Sender: TObject; Button: TUDBtnType); begin if Button = btNext then dac1mult := dac1mult + 1.0 else dac1mult := dac1mult - 1.0 ; if dac1mult > 10.0 then dac1mult := 0.0 else if dac1mult < 0.0 then dac1mult := 10.0 ; ; end; procedure TForm1.StopClick(Sender: TObject); begin //stop the timer timer1.Enabled := false; end; end.