Escolar Documentos
Profissional Documentos
Cultura Documentos
I. II.
JUDUL
TUJUAN : 1. Mahasiswa mampu membuat program simulasi DAC dengan tampilan Grafik, melalui bahasa pemrograman Delphi. 2. Mahasiswa mampu menempatkan Component Palette pada layar form dan menuliskan Code Editor procedure program pada layer editing atau bagian unit. 3. Mahasiswa mampu menggunakan parameter-parameter dalam pembuatan grafik, sesuai dengan tampilan yang diinginkan
III.
LANDASAN TEORI :
IV.
PERALATAN DAN BAHAN : 1. Personal Komputer (minimal P4 2.0 GHz, RAM 512 Mb) 2. Software Borland Delphi 6 or 7
V.
VI.
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls;
type TForm1 = class(TForm) GroupBox2: TGroupBox; S1: TButton; S2: TButton; S3: TButton; S4: TButton; S5: TButton; S6: TButton; S7: TButton; S8: TButton; GroupBox1: TGroupBox; Shape1: TShape; Shape2: TShape; Shape3: TShape; Shape4: TShape; Shape5: TShape; Shape6: TShape; Shape7: TShape; Shape8: TShape; Button9: TButton; GroupBox3: TGroupBox; Edit1: TEdit; GroupBox4: TGroupBox; Label1: TLabel;
Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Button10: TButton; Timer1: TTimer; Chart1: TChart; Series1: TLineSeries; Panel1: TPanel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label14: TLabel; procedure S1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button9Click(Sender: TObject); procedure S2Click(Sender: TObject); procedure Button10Click(Sender: TObject); procedure S3Click(Sender: TObject); procedure S4Click(Sender: TObject); procedure S5Click(Sender: TObject); procedure S6Click(Sender: TObject); procedure S7Click(Sender: TObject); procedure S8Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations }
end;
implementation
{$R *.dfm} Procedure switch_false; begin sw1:=false;sw2:=false;sw3:=false;sw4:=false; sw5:=false;sw6:=false;sw7:=false;sw8:=false; end; Procedure awal_caption; begin form1.Label1.Caption:='0'; form1.Label2.Caption:='0'; form1.Label3.Caption:='0'; form1.Label4.Caption:='0'; form1.Label5.Caption:='0'; form1.Label6.Caption:='0'; form1.Label7.Caption:='0'; form1.Label8.Caption:='0'; end;
tx:=(x1+x2+x3+x4+x5+x6+x7+x8); {var u/ digital input} y:=5*(tx/255); {Rumus DAC 8-Bit dng Step Size 20mV}
for i:=0 to chart1.SeriesCount-1 do {setting tampilan grafik} with chart1.Series [i] do add (y);
with chart1.bottomaxis do begin automatic:=false; maximum :=series1.XValues.last; minimum :=0; edit1.Text := inttostr (tx); timer1.Enabled :=true; end; end;
procedure TForm1.Button9Click(Sender: TObject); begin tx:=0; y:=0; timer1.Enabled:=false; awal_caption; buka:=false; switch_false; edit1.Text := inttostr (tx); series1.Clear; shape1.Brush.Color:=clwhite; shape1.Brush.Style:=bsDiagCross; shape2.Brush.Color:=clwhite; shape2.Brush.Style:=bsDiagCross; shape3.Brush.Color:=clwhite; shape3.Brush.Style:=bsDiagCross; shape4.Brush.Color:=clwhite; shape4.Brush.Style:=bsDiagCross; shape5.Brush.Color:=clwhite; shape5.Brush.Style:=bsDiagCross; shape6.Brush.Color:=clwhite; shape6.Brush.Style:=bsDiagCross; shape7.Brush.Color:=clwhite; shape7.Brush.Style:=bsDiagCross; shape8.Brush.Color:=clwhite; shape8.Brush.Style:=bsDiagCross; s1.Caption:='off'; s2.Caption:='off'; s3.Caption:='off'; s4.Caption:='off'; s5.Caption:='off'; s6.Caption:='off';
s7.Caption:='off'; s8.Caption:='off';
end; procedure TForm1.Button10Click(Sender: TObject); begin close; end; procedure TForm1.S1Click(Sender: TObject); begin if sw1=false then begin timer1.enabled :=true; x1:=128; sw1:=true; shape1.Brush.Style:=bssolid; s1.Caption:='On'; label1.Caption:='1'; shape1.Brush.Color:=clred; shape1.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x1:=0; y:=0; series1.xvalues.Last; sw1:=false; shape1.Brush.Style:=bsDiagCross; s1.Caption:='Off'; label1.Caption:='0'; shape1.Brush.Color:=clwhite; shape1.Brush.Style:=bsDiagCross; end; edit1.Text := inttostr (tx);
if sw2=false then begin timer1.enabled :=true; x2:=64; sw2:=true; shape2.Brush.Style:=bssolid; s2.Caption:='On'; label2.Caption:='1'; shape2.Brush.Color:=clred; shape2.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x2:=0; y:=0; series1.xvalues.Last; sw2:=false; shape2.Brush.Style:=bsDiagCross; s2.Caption:='Off'; label2.Caption:='0'; shape2.Brush.Color:=clwhite; shape2.Brush.Style:=bsDiagCross; end; edit1.Text := inttostr (tx);
end;
procedure TForm1.S3Click(Sender: TObject); begin if sw3=false then begin timer1.enabled :=true; x3:=32; sw3:=true; shape3.Brush.Style:=bssolid; s3.Caption:='On'; label3.Caption:='1';
shape3.Brush.Color:=clred; shape3.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x3:=0; y:=0; series1.xvalues.Last; sw3:=false; shape3.Brush.Style:=bsDiagCross; s3.Caption:='Off'; label3.Caption:='0'; shape3.Brush.Color:=clwhite; shape3.Brush.Style:=bsDiagCross; end;
end;
if sw4=false then begin timer1.enabled :=true; x4:=16; sw4:=true; shape4.Brush.Style:=bssolid; s4.Caption:='On'; label4.Caption:='1'; shape4.Brush.Color:=clred; shape4.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x4:=0; y:=0; series1.xvalues.Last; sw4:=false; shape4.Brush.Style:=bsDiagCross; s4.Caption:='Off';
end;
procedure TForm1.S5Click(Sender: TObject); begin if sw5=false then begin timer1.enabled :=true; x5:=8; sw5:=true; shape5.Brush.Style:=bssolid; s5.Caption:='On'; label5.Caption:='1'; shape5.Brush.Color:=clred; shape5.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x5:=0; y:=0; series1.xvalues.Last; sw5:=false; shape5.Brush.Style:=bsDiagCross; s5.Caption:='Off'; label5.Caption:='0'; shape5.Brush.Color:=clwhite; shape5.Brush.Style:=bsDiagCross; end; end;
timer1.enabled :=true; x6:=4; sw6:=true; shape6.Brush.Style:=bssolid; s6.Caption:='On'; label6.Caption:='1'; shape6.Brush.Color:=clred; shape6.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x6:=0; y:=0; series1.xvalues.Last; sw6:=false; shape6.Brush.Style:=bsDiagCross; s6.Caption:='Off'; label6.Caption:='0'; shape6.Brush.Color:=clwhite; shape6.Brush.Style:=bsDiagCross; end; end; procedure TForm1.S7Click(Sender: TObject); begin if sw7=false then begin timer1.enabled :=true; x7:=2; sw7:=true; shape6.Brush.Style:=bssolid; s7.Caption:='On'; label7.Caption:='1'; shape7.Brush.Color:=clred; shape7.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x7:=0; y:=0; series1.xvalues.Last; sw7:=false;
procedure TForm1.S8Click(Sender: TObject); begin if sw8=false then begin timer1.enabled :=true; x8:=1; sw8:=true; shape8.Brush.Style:=bssolid; s8.Caption:='On'; label8.Caption:='1'; shape8.Brush.Color:=clred; shape8.Brush.Style:=bssolid; end else begin timer1.enabled :=true; x8:=0; y:=0; series1.xvalues.Last; sw8:=false; shape8.Brush.Style:=bsDiagCross; s8.Caption:='Off'; label8.Caption:='0'; shape8.Brush.Color:=clwhite; shape8.Brush.Style:=bsDiagCross; end; end;
end;
end.
VII.
HASIL PERCOBAAN :
VIII. ANALISA :
IX.
KESIMPULAN :