Public Data:

Popular Project Sites: Project Sites:

Luke Cole

Donate to Luke Cole
Locations of visitors to this page

Parallel Port PWM/Encoder Kernal Space Linux Driver

The parallel port PWM and/or encoder kernel space Linux driver allows open/closed loop control of motors using the parallel port.

Developed to provide a very cheap alternative for motor control, which is awesome news for the robotic hobbyist., wishing to control high powered motors cheaply.


  • PWM Frequency: 100Hz (thanks to 2.6.x Linux kernel 1kHz operating frequency).
  • PWM Resolution: 1ms (i.e. 10 Speed Levels)
  • Encoder Read Rate: 0.5ms or >= 1.0ms

Some Robots Using the Parallel Port PWM/Encoder Linux Driver


  1. Download the ParportPWMEncoderDriver-1.2 code tarball.
  2. Uncompress the tarball and untar the code.
    tar xvfz ParportPWMEncoderDriver-1.2.tgz
  3. Go to source directory.
    cd ParportPWMEncoderDriver-1.2
  4. Compile the code.
  5. Install the code (requires root/sudo access).
    sudo make install
  6. Install PWM kernel driver (requires root/sudo access).
    sudo insmod lp_pwm.ko
  7. (Optional) Install Encoder kernel driver.
    • Just use the encoder (requires root/sudo access):
      sudo insmod lp_encoder.ko
    • Or to link encoder input to pwm output, example:
      sudo insmod lp_encoder.ko lp_encoder_io_base=0x370,0x378 \
          lp_encoder_linked_encoders="","5+4" lp_encoder_int_output=1

      This means use two parallel ports, one at port 0x370 and one at 0x378 with the first port having no quadrature links, and the second having a link between pins 4 and 5. Also, integer output is in effect.

  8. Update the MakeDevice MAJOR variables with the determined character device MAJOR number (See dmesg), run the MakeDevice (requires root/sudo access).
    sudo ./MakeDevices
  9. To write a single PWM signal:
    • If module was installed with lp_pwm_int_input option, That is:
      insmod lp_pwm.ko lp_pwm_int_input=1
      Then the speed must be set between an integer 0 and 10:
      sudo echo "5" > /dev/pwm0
    • Otherwise the speed must be set between 0x00 and 0x7f:
      sudo echo "0x38" > /dev/pwm0
  10. To read a single encoder, simply:
    sudo echo /dev/encoder0


  • GNU/Linux
  • 2.6.x Linux Kernel. Ensure the system timing frequency is at 1000Hz, i.e. unsure the following options are set in /usr/src/linux/.config
    • CONFIG_HZ_1000=y
    • CONFIG_HZ=1000
  • If you wish to control a motor you will need a motor controller (any simple H-Bridge or Motor Controller circuit with 5V control inputs will do).

Current Release


NOTE: A USB joystick command line program (jsRobot) to control one, two or four motors, locally or over the network using UDP packets, via this parallel port PWM/Encoder driver can be found within DROS under:

Release Notes

ParportPWMEncoderDriver-1.2 - June 23, 2007

Minor fix: updated changed DECLARE_WORK marco.

ParportPWMEncoderDriver-1.1 - April 5, 2007

Replaced deprecated MODULE_PARM() with module_param*() routines.

ParportPWMEncoderDriver-1.0 - February 25, 2005

Inital code release. This release contains a kernel space Linux driver to send PWM's and receive Encoder signals.

Useful Motor Controller Links


© 2000-2023 Luke Cole
All rights reserved