How To Drive Paralel Port

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

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Please notice that comment or question submitted should match the topic. Otherwise, we will delete that comment or question :!:

10 Comments
  1. 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.

    • mungkin bisa diatasi dengan menambahkan -Fu dengan path dari LPT.pas

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

    • Oia, ada yg tertinggal. thanks infonya 😀

    • 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.

    • Sip, project bisa dicompile sampai jadi .exe, tapi form tetap tidak muncul.

  2. Mas bs minta program LPTTest nya mas? makasih

    • Download saja LPTXP.7z yang di bawah, di dalamnya ada demo yang berisi LPTTest.exe maupun source code-nya

  3. 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

    • 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)

Leave a comment

Before making a comment, make sure you have read the previous comments. Do not make the questions have been asked. Note also the links in the article. Take a look at those links before you create the questions, as it may be an explanation of your questions have been answered in that link.

Comments that do not follow these rules will be deleted!

(required)

(required)


Time limit is exhausted. Please reload the CAPTCHA.