Kamis, 01 Mei 2014

Modul Praktikum Antarmuka dengan Port Paralel (Output)



Antarmuka dengan Port Paralel (Output)

Tujuan
      Mahasiswa mampu mengantarmukakan hardware dengan PC melalui port parallel.
      Mahasiswa mampu mengeluarkan data dari PC melalui port parallel.
      Mahasiswa mampu membuat aplikasi menggunakan bahasa pemrograman Borland Delphi untuk antarmuka melalui port paralel. 

Dasar Teori
 Port  paralel  banyak  digunakan  dalam  berbagai  macam  aplikasi  antarmuka. Port ini  hanya  membutuhkan  rangkaian eksternal sederhana untuk melakukan suatu tugas tertentu. Port paralel ini terdiri dari 4 jalur kontrol, 5 jalur status dan 8 jalur data. Biasanya dapat Anda jumpai sebagai  port pencetak (printer), dalam bentuk konektor DB-25 betina (female).


 Cara paling sederhana untuk mengeluarkan data melalui port paralel adalah dengan mengirimkan data ke alamat register Data yaitu alamat base+0. Jika alamat dasar yang digunakan adalah 378h, maka data dikirim ke alamat 378h untuk mengeluarkan data melalui port paralel pin nomor 2 sampai dengan 9.

   Tabel Alamat register
Register Name
Address
Direction
Data
Base + 0
Out
Status
Base + 1
In
Control
Base + 2
In/Out


Alat dan Bahan
      Satu set PC 
      Tool Pemrograman Borland Delphi.
      Kabel LPT
      LED sebanyak 8 buah

Prosedur
a. Mengeluarkan data dengan masukan dari Tedit

3.      Komponen/Objek yang digunakan dan pengaturan propertiesnya adalah :


Komponen
Properti
Nilai
Label11
Caption
Data yg dikirim
 Edit1
Text
1
Button1
Caption
Send
Shape1
Shape
StCircle
Shape2
Shape
StCircle
Shape3
Shape
StCircle
Shape4
Shape
StCircle
Shape5
Shape
StCircle
Shape6
Shape
StCircle
Shape7
Shape
StCircle
Shape8
Shape
StCircle

             
4.      Masukkan perintah-perintah pada kejadian/event disetiap komponen di bawah ini.
 Nama Komponen
 Event
 Perintah
Deklarasi
-
var
  Form1: TForm1;   data:  integer;

implementation

{$R *.dfm} procedure Out32(PortAddress:smallint;Value:smallint); stdcall; external 'inpout32.dll'; function Inp32(PortAddress:smallint):smallint;stdcall;  external 'inpout32.dll';
 Button1
 OnClick
 procedure TForm1.Button1Click(Sender: TObject);
begin  
data:=strtoint(edit1.Text);   out32($378,data);  
if (data and 1)=1 then shape8.Brush.Color:=clred     else shape8.Brush.Color:=clwhite;  
if (data and 2)=2 then shape7.Brush.Color:=clred     else shape7.Brush.Color:=clwhite;  
if (data and 4)=4 then shape6.Brush.Color:=clred     else shape6.Brush.Color:=clwhite;
 if (data and 8)=8 then shape5.Brush.Color:=clred     else shape5.Brush.Color:=clwhite;  
if (data and 16)=16 then shape4.Brush.Color:=clred     else shape4.Brush.Color:=clwhite;  
if (data and 32)=32 then shape3.Brush.Color:=clred     else shape3.Brush.Color:=clwhite;  
if (data and 64)=64 then shape2.Brush.Color:=clred     else shape2.Brush.Color:=clwhite;  
if (data and 128)=128 then shape1.Brush.Color:=clred     else shape1.Brush.Color:=clwhite; end;


5.      Simpan semua file dpr dan unit kemudian jalankan program.
6.      Masukkan sembarang nilai, klik tombol send, kemudian  amati apa yang terjadi pada komponen shape dan LED. 

Kesimpulan







b. Mengeluarkan data untuk display LED

3.      Komponen/Objek yang digunakan dan pengaturan propertiesnya adalah :
Komponen
Properti
Nilai
Timer1
Enabled
FALSE
 
Interval
100
Button1
Caption
Start
Button2
Caption
Stop
Shape1
Shape
StCircle
Shape2
Shape
StCircle
Shape3
Shape
StCircle
Shape4
Shape
StCircle
Shape5
Shape
StCircle
Shape6
Shape
StCircle
Shape7
Shape
StCircle
Shape8
Shape
StCircle

4.      Masukkan perintah-perintah pada kejadian/event disetiap komponen di bawah ini.

 Nama Komponen
 Event
 Perintah
Deklarasi
-
var
  Form1: TForm1;   i,data:  integer; implementation {$R *.dfm} procedure Out32(PortAddress:smallint;Value:smallint); stdcall; external 'inpout32.dll'; function Inp32(PortAddress:smallint):smallint;stdcall;  external 'inpout32.dll';
 Button1
 OnClick
procedure TForm1.Button1Click(Sender: TObject); begin
  timer1.Enabled:=true;
  i:=0; end;
 Button2
 OnClick
procedure TForm1.Button2Click(Sender: TObject); begin   timer1.Enabled:=false; end;
Timer1
OnTimer
procedure TForm1.Timer1Timer(Sender: TObject); const k: array[0..7] of integer = ($01,$02,$04,$08,$10,$20,$40,$80); begin   data:=k[i];   out32($378,data);
  inc(i);   if i=8 then i:=0;   if (data and 1)=1 then shape8.Brush.Color:=clred     else shape8.Brush.Color:=clwhite;   if (data and 2)=2 then shape7.Brush.Color:=clred     else shape7.Brush.Color:=clwhite;   if (data and 4)=4 then shape6.Brush.Color:=clred     else shape6.Brush.Color:=clwhite;   if (data and 8)=8 then shape5.Brush.Color:=clred     else shape5.Brush.Color:=clwhite;   if (data and 16)=16 then shape4.Brush.Color:=clred     else shape4.Brush.Color:=clwhite;
  if (data and 32)=32 then shape3.Brush.Color:=clred     else shape3.Brush.Color:=clwhite;
  if (data and 64)=64 then shape2.Brush.Color:=clred     else shape2.Brush.Color:=clwhite;   if (data and 128)=128 then shape1.Brush.Color:=clred     else shape1.Brush.Color:=clwhite; end;

5.      Simpan semua file dpr dan unit kemudian jalankan program.
6.      Klik tombol start, kemudian  amati apa yang terjadi pada komponen shape dan LED.
7.      Klik tombol stop, kemudian  amati apa yang terjadi pada komponen shape dan LED. 

Kesimpulan

1 komentar:

  1. Titanium-arts.com - T-Bone Arts
    ‎Titanium-arts.com titanium exhaust · galaxy watch 3 titanium ‎Titanium-arts.com 1xbet korean · ford ecosport titanium ‎Titanium-arts.com · titanium drill bits ‎TITanium-arts.com

    BalasHapus