Using the Parallel Port

Jump to: navigation, search

[edit] Using PEBL with a parallel Port

Starting with Version 0.12, PEBL can send and receive information via a stan- dard parallel (printer) port. These don’t appear on many computers anymore, but you can still get them, and they are still important ways to interface with hardware devices such as EEG and MRI machines and homebrew button boxes.

Currently, parallel port access is fairly limited to setting and getting the state of the 8 data bits. Parallel ports have a number of bits you can play with, but currently PEBL only supports the basic 8 data bits. Basically, you can set the state of the bits or read the state of the bits, which can either control things like LEDs, or be impacted by making connections between the ground and the data bit.

If you have a parallel port, it is mapped to one of three ports: LPT1, LPT2, or LPTX. To initialize access to a port, you must call OpenPPort with the name of your port:

port <- OpenPPort("LPT1")

You can then use the port object to access the port (sending or receiving information). Parallel ports have two modes, input and output. To read data in, it needs to be in input mode; to change the state of the bits, it needs to be in out- put mode. Set the state with:




To access the state of a port, use

val <- GetPPortState(port)

It will return a string of ”—” separated 1s and 0s, which specify the state of each of the 8 bits. This string can be matched to particular string templates, or transformed into a list of values.

To set the state of the port, use:


state should be a list of 8 0s or 1s:

 SetPPortState(port, [0,0,0,0,0,0,0,1])
Personal tools