Overview
The PC parallel port — also called the LPT port — is a 25-pin D-sub connector found on virtually every desktop PC manufactured before USB became ubiquitous. Originally designed for connecting printers, it exposes 8 bidirectional data lines, 4 control lines, and 5 status lines, making it one of the most convenient interfaces for hardware experimentation.
On the Linux PC Robot, the parallel port is used to interface the Velleman K8000 I²C bus controller board. The K8000 converts the parallel port signals into an I²C bus, which in turn communicates with the on-board DAC/ADC chips that drive the motor H-bridge amplifier.
Parallel Port Pin Assignment
The standard DB-25 parallel port connector has the following pin assignment. The Data pins (D0–D7) are the primary interface used by the K8000.
| Pin | Signal | Direction | Description |
|---|---|---|---|
| 1 | nStrobe | Output | Strobe (active low) |
| 2 | D0 | Bidir | Data bit 0 |
| 3 | D1 | Bidir | Data bit 1 |
| 4 | D2 | Bidir | Data bit 2 |
| 5 | D3 | Bidir | Data bit 3 |
| 6 | D4 | Bidir | Data bit 4 |
| 7 | D5 | Bidir | Data bit 5 |
| 8 | D6 | Bidir | Data bit 6 |
| 9 | D7 | Bidir | Data bit 7 |
| 10 | nAck | Input | Acknowledge (active low) |
| 11 | Busy | Input | Busy signal |
| 12 | PaperOut | Input | Paper out / PE |
| 13 | Select | Input | Printer selected |
| 14 | nLineFeed | Output | Line feed (active low) |
| 15 | nError | Input | Error (active low) |
| 16 | nInit | Output | Initialize printer |
| 17 | nSelectIn | Output | Select input (active low) |
| 18–25 | GND | — | Signal ground |
The Velleman K8000 and I²C
The Velleman K8000 is a kit-based interface board that attaches to the PC parallel port and presents an I²C (Inter-Integrated Circuit) bus to the outside world. I²C is a two-wire serial protocol — a clock line (SCL) and a data line (SDA) — capable of addressing up to 128 devices on a single bus.
The K8000 provides:
- 8-channel 8-bit DAC output (used to set motor drive voltage)
- 8-channel 8-bit ADC input (for sensor readings)
- 16 channels of digital I/O
The robot uses the DAC channels to send signed drive commands to the dual H-bridge motor amplifier. A value of 128 represents zero (stop), values above 128 drive forward, and values below 128 drive in reverse.
Linux Kernel Support
Linux provides two methods for accessing the parallel port:
-
/dev/parport0— the kernel's IEEE 1284 parallel port abstraction. User-space programs open this device and useioctl()calls to read/write data and control lines. Safe and portable, but has more overhead. -
Direct I/O port access — using
ioperm()oriopl()system calls, a privileged process can read and write the parallel port hardware registers directly at I/O addresses0x378(LPT1),0x278(LPT2), etc. Much faster and suitable for bit-banging I²C.
The K8000 Linux driver uses the i2c-parport kernel module, which implements
an I²C adapter on top of the parallel port using bit-banging on the data and status lines.
Once loaded, standard Linux I²C tools and the /dev/i2c-N device nodes are
used to communicate with the K8000's on-board I²C chips.
# Load the I2C parallel port module modprobe i2c-parport type=1 # Scan for I2C devices on the bus i2cdetect -y 0 # Write a value to a DAC channel (example) i2cset -y 0 0x20 0x01 0x80 # channel 1, value 128 (zero/stop)
BIOS Configuration
For direct I/O access or I²C bit-banging to work reliably, the parallel port must be configured in EPP (Enhanced Parallel Port) or ECP (Extended Capabilities Port) mode in the PC BIOS. Standard SPP mode may not support bidirectional data lines on all hardware. The BIOS setting is usually found under Integrated Peripherals → Parallel Port Mode.