Paralel port atau sering disebut LPT memiliki tiga port, yaitu port data, port control, dan port status. Port-port ini memiliki alamat yang berurutan dengan alamat untuk port data sebagai alamat dasar. Alamat yang biasa digunakan untuk LPT adalah $378, $278 dan $38B. Dan alamat $378 merupakan alamat yang paling lumrah digunakan untuk LPT jika hanya ada sebuah port LPT yang terinstal. Dengan alamat dasar $378, maka ini berarti bahwa port data beralamat $378, port status pada $379 dan port control pada $37A.

Susunan pin untuk LPT pada konektor DB25 adalah sebagai berikut:

No.PinFungsiArahKeterangan
1Control bit 0 (strobe)KeluarDibalik
2-9Data (bit 0-bit 7)Masuk/keluar
10Status bit 6 (acknowledge)Masuk
11Status bit 7 (busy)MasukDibalik
12Status bit 5 (paper end)Masuk
13Status bit 4 (select)Masuk
14Control bit 1 (auto feed)KeluarDibalik
15Status bit 3 (error)Masuk
16Control bit 2 (init)Keluar
17Control bit 3 (select in)KeluarDibalik
18-25Ground

Kita bisa menggunakan 8 bit port data untuk mengendalikan berbagai peralatan. Misalnya untuk mengendalikan LED, relay, SCR, dan lain sebagainya.

Untuk kemudahan dalam pemrogramannya, saya membuat sebuah komponen yang bisa diinstal pada Delphi (LPTXP.dpk) ataupun Lazarus (LPTXP.lpk). Komponen ini menggunakan hwinterface.sys.

Setelah Anda menginstal komponen tersebut, Anda bisa mencoba program demo (LPTTest.dpr). Dengan program demo ini, Anda bisa mengatur keluaran dari port data dengan memberi centang pada CheckBox. Jika CheckBox dicentang, maka keluaran dari port data akan bernilai H. Sedangkan jika centangnya dibuang, maka keluaran port data akan bernilai L.

LPTTest
LPTTest

Untuk mempermudah dalam melihat keadaan port data, Anda bisa menyambungkan port data ke LED seperti gambar berikut:

Menghubungkan LED ke LPT
Menghubungkan LED ke LPT

Dengan membuat rangkaian LED seperti gambar di atas, Anda bisa mencoba mengendalikan nyala LED menggunakan CheckBox pada program LPTTest. Dan Anda akan mendapatkan Runnung LED yang sangat menarik jika Anda klik pada tombol Run. Pola penyalaan LED menggunakan file biner yang disusun menggunakan pola seperti pada BAB “LED berjalan 5” pada buku “Mudah dan Menyenangkan Belajar Mikrokontroler”.

Komponen LPTXP
Komponen LPTXP

Parallel port or LPT often referred to has three ports, i.e. data port, control port, and status port. These ports has a consecutive address with the address for the data port as the primary address. The address used for the LPT is $378, $280 and $38B. And $378 address is the most commonplace used if there is only one LPT port installed. With the basic address $378, then this means that the data port located $378, status port at $379 and control port on $37A.

The pin arrangement for the LPT connector DB25 is as follows:

Pin No.FunctionDirectionDescription
1Control bit 0 (strobe)OutReversed
2-9Data (bit 0 to bit 7)In/out
10Status bit 6 (acknowledge)In
117 bit Status (busy)InReversed
12Status bit 5 (paper end)In
13Status bit 4 (select)In
14Control bit 1 (auto feed)OutReversed
15Status bit 3 (error)In
16Control bit 2 (init)Out
17Control bit 3 (select in)OutReversed
18-25Ground

We can use 8 bit data port to control a range of equipment. For example to control LEDS, relays, SCR, etc.

For ease of programming, I created a component that can be installed on Delphi (LPTXP.dpk) or Lazarus (LPTXP.lpk). This component uses the hwinterface.sys.

After you install the component, you can try the demo program (LPTTest.dpr). With this demo program, you can set the output of the data port by giving check on the CheckBox. If the CheckBox is checked, then the output of the data port will be H. whereas if the check mark is removed, then the output port data will be L.

LPTTest
LPTTest

For ease in viewing the State of data port, you can connect the data port to the LEDS as shown below:

Connect the LEDS to the LPT
Connect the LEDS to the LPT

By creating a LED circuit as shown above, you can try to control the LED light using the Checkboxes on the LPTTest program. And you will get a very interesting LED Runnung if you click on the Run button. LED lighting patterns using binary files compiled using the pattern as in “CHAPTER, Running LED 5” on the books “Easy and Fun Learning Learning Microcontroller”.

LPTXP Componen
LPTXP Componen

10 Comments

Time limit is exhausted. Please reload the CAPTCHA.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

  • Mantab, ada komponen Lazarusnya.
    Btw, aku sudah download dan coba install package di Lazarus 0.9.30.2 / FPC 2.4.4, tapi gagal karena file LPT.pas tidak ditemukan. Mohon bantuannya. Terima kasih.

    1. Baik, komponen sudah bisa diinstal di Lazarus. Hanya saja sepertinya file form pada project lazarusnya tidak disertakan, sehingga project demo tidak bisa dijalankan. Thanks.

    2. Eh, tapi tidak kok, itu menggunakan file form yang sama dengan Delphi, jadi menggunakan dfm, bukan lfm. Coba lakukan konversi Delphi unit to Lazarus unit untuk unit UnitTest.pas.

  • Mas Sulhan,
    Saya coba install componentnya di lazarus 1.6 windows7 32bit, nggak bisa ya mas, apa memang tidak didesain utk windows7 ?, ada 3 error saat diinstall….

    Pertama, parport_rut_noDll.pas(77,7)Error: Can’t determine which overloaded function to call (di scrip menunjuk -> AssignFile(fb,path);)

    Kedua, parport_rut_noDll.pas(129,36)Error: Incompatible type for arg. 3: Got “PChar”, expected “LPPCSTR”

    Ketiga, parport_rut_noDll.pas(142,30)Error: Incompatible type for arg. 3: Got “PChar”, expected “LPPCSTR”

    Sedangkan LPTTest.exe bisa dijalankan dengan sempurna….

    Thanks sebelumnya

    1. Memang Lazarus ini kadang agak sulit karena dari versi ke versi kadang tidak kompatibel. Dicoba pada versi X berhasil, setelah sampai versi Y ternyata error. Saya barusan mencoba compile pada lazarus 1.6.2 dan penyelesaiannya:
      1) Untuk kesalahan pertama cukup dengan mengganti menjadi AssignFile(fb,pchar(path));
      2) Untuk error Got “PChar”, expected “LPPCSTR”, itu adalah ketidak cocokan tipe data untuk X. Jadi tinggal disesuaikan saja tipe X menjadi X:LPPCSTR; (pada baris 117)