I can try to clarify some of your confusion.
A parallel port has 25 pins, and 8 of these pins are called data pins. These are pins that can be set to either 0 (low) or 1 (high). On a parallel port, the data pins are specifically pins 2-9. You can choose a certain pattern of 0s and 1s to represent a certain event (e.g., trial onset). The collection of 8 bits is also known as a byte (1 byte = 8 bits). However, you can also convert the byte into a decimal value (see here). So then, the following values are equivalent:
Pin | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | Total |
---|---|---|---|---|---|---|---|---|---|---|
Byte (8-bits) | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | - |
Decimal calculation | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 (2^1) | 1 (2^0) | 2+1 = 3 |
As @FrankS probably already explained to you, the utility he wrote sets pins 2-9 to a byte value (i.e., a pattern of 0s and 1s across 8 bits). Giving a value of 3 translates to setting pins 2 and 3 high. Similarly, in the PsychoPy parallel package, using the setData()
function will set pins 2-3 to 1 and keep all others 0, until you set all pins back to 0.
While setData()
is probably what you need, the parallel package allows you to set specific data pins to 0 or 1, if you wanted. So the following are equivalent:
- Setting the whole byte at once:
port.setData(3)
- Setting the two pins specifically with
port.setPin(pin_number, 0 or 1)
:port.setPin(2, 1)
port.setPin(3, 1)
And two last things on the logistics of sending the trigger using PsychoPy:
- You can choose whatever byte you want
- See this post for how to send the trigger and set the duration
Hope that helps!