laporan komdat ii

Post on 28-Nov-2014

141 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LAPORAN PRAKTIKUM KOMUNIKASI DATA II

PEMROGRAMAN PARALEL PORT

TUJUAN

1. Mahasiswa mengetahui transfer data menggunakan port parallel.

2. Mahasiswa dapat mengetahui konsep pemrograman port parallel.

3. Mahasiswa dapat membuat program parallel port tester.

DASAR TEORI

Port printer bisa digunakan sebagai I/O komputer yang bisa kita program, dan secara teknispun pemrograman menggunakan paralel port lebih gampang, dikarenakan tidak memerlukan hardware khusus/tambahan. Selain itu menggunakan proses transfer data pun dilakukan secara paralel, sehingga data yang terkirim lebih cepat apabila dibardingkan dengan secara serial. Pada paralel port menawarkan beragam sekali register yang bekerja, dengan adanya register tersebut kita bisa lebih fleksibel dalam penggunaannya.

ALAT dan BAHAN

1. Download dynamic link library (dll) dengan nama inpout32.dll di logix4u.net

2. Software builder Borland Delphi 7.0

LANGKAH PERCOBAAN

- Buatlah Rancangan interface program seperti dibawah ini

- Kemudian Tulis Scrip program dibawah ini sesuai procedurenya

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

TForm1 = class(TForm)

GroupBox1: TGroupBox;

Shape1: TShape;

Shape2: TShape;

Shape3: TShape;

Shape4: TShape;

Shape5: TShape;

Shape6: TShape;

Shape7: TShape;

Shape8: TShape;

CheckBox1: TCheckBox;

CheckBox2: TCheckBox;

CheckBox3: TCheckBox;

CheckBox4: TCheckBox;

CheckBox5: TCheckBox;

CheckBox6: TCheckBox;

CheckBox7: TCheckBox;

CheckBox8: TCheckBox;

Button1: TButton;

procedure CheckBox1Click(Sender: TObject);

procedure CheckBox2Click(Sender: TObject);

procedure CheckBox3Click(Sender: TObject);

procedure CheckBox4Click(Sender: TObject);

procedure CheckBox6Click(Sender: TObject);

procedure CheckBox7Click(Sender: TObject);

procedure CheckBox8Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure CheckBox5Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

tmp : byte ;

implementation

{$R *.dfm}

function Out32(Addr:word;Out:byte):byte;

stdcall; external 'inpout32.dll';

function Inp32(Addr:word):byte; stdcall;

external 'inpout32.dll';

procedure TForm1.CheckBox1Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox1.Checked then

begin

Out32($378, tmp or $1);

Shape1.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $FE);

Shape1.Brush.Color := clWhite;

end;

end;

procedure TForm1.CheckBox2Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox2.Checked then

begin

Out32($378, tmp or $2);

Shape2.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $FD);

Shape2.Brush.Color := clWhite;

end;

end;

procedure TForm1.CheckBox3Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox3.Checked then

begin

Out32($378, tmp or $4);

Shape3.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $FB);

Shape3.Brush.Color := clWhite;

end;

end;

procedure TForm1.CheckBox4Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox4.Checked then

begin

Out32($378, tmp or $8);

Shape4.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $F7 );

Shape4.Brush.Color := clWhite;

end;

end;

procedure TForm1.CheckBox6Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox6.Checked then

begin

Out32($378, tmp or $20);

Shape6.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $DF);

Shape6.Brush.Color := clWhite;

end;

end;

procedure TForm1.CheckBox7Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox7.Checked then

begin

Out32($378, tmp or $40);

Shape7.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $BF);

Shape7.Brush.Color := clWhite;

end;

end;

procedure TForm1.CheckBox8Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox8.Checked then

begin

Out32($378, tmp or $80);

Shape8.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $7F);

Shape8.Brush.Color := clWhite;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

out32($378, 00);

Shape1.Brush.Color := clWhite;

Shape2.Brush.Color := clWhite;

Shape3.Brush.Color := clWhite;

Shape4.Brush.Color := clWhite;

Shape5.Brush.Color := clWhite;

Shape6.Brush.Color := clWhite;

Shape7.Brush.Color := clWhite;

Shape8.Brush.Color := clWhite;

CheckBox1.Checked:= False;

CheckBox2.Checked:= False;

CheckBox3.Checked:= False;

CheckBox4.Checked:= False;

CheckBox5.Checked:= False;

CheckBox6.Checked:= False;

CheckBox7.Checked:= False;

CheckBox8.Checked:= False;

end;

procedure TForm1.CheckBox5Click(Sender: TObject);

begin

tmp := Inp32($378);

If CheckBox5.Checked then

begin

Out32($378, tmp or $10);

Shape5.Brush.Color := clRed;

end

else

begin

Out32($378, tmp and $EF);

Shape5.Brush.Color := clWhite;

end;

end;

end.

HASIL :

TUGAS DALAM ANALISA

1. Jelaskan fungsi inpout32.dll pada program aplikasi tersebut.

2. Jelaskan fungsi procedure out32 pada listing program tersebut terhadap manajemen hardware?

3. Jelaskan fungsi function inp32 pada listing program tersebutterhadap manajemen hardware?

4. Apa perbedaan menggunakan kata procedure dan function pada dll tersebut?

JAWAB

1. Fungsi Inpout32.dll adalah untuk menghubiungkan Xp dengan delphi karena xp tidak mendukung dengan bahasa assembler

2. ....

3. Untuk menghubungkan tiap Port – port dengan program4. Procedure hanya bisa untuk output32, sedangkan function bisa untuk input maupun output

Pada gambar diatas salah dikarenakan dalam penulisan procedure tidak boleh terdapat titik balik (;bytes).

top related