Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signal input to port interface board
Hi, I am new to bpod system. I know the port interface board (Product ID: 1008) is designed for the usage of phototransistor. I am wondering if it is possible to modify it so that it can detect lever press if properly connected to a lever switch? If so, how should I do it? I am not sure how the signal input port (circled in the attached pic) works either.
Thank you!
[Image: view?usp=sharing]
Hello MiaoMiao,

The 'S' terminal on the port interface board is a 5V-tolerant digital input channel, pulled weakly high. A phototransistor is usually connected between 'S' and 'GND'. When IR light shines on the phototransistor, it creates a low resistance path to ground, pulling the line low. When something breaks the IR beam, the resulting low-->high transition is read by the state machine as a "PortXIn" event, where X is the port number. The next high --> low transition generates a "PortXOut" event.

You can create the same events with a pushbutton or switch. Simply connect the "S" terminal and the adjacent "GND" terminal on the port interface board to the switch terminals such that S is connected to GND when the switch is not pressed. Two things to be aware of: 1. If your switch is an SPDT type, one pole of the switch is connected to the output when the switch is at rest - you'll want to connect that pole to the "S" terminal. Connecting the other one will give you inverted logic. 2. You'll need to ensure that your state machine description can handle debouncing if the press duration is used as a behavioral contingency.

I hope this helps,
Hi Josh,
Thank you so much! It worked as I followed the instructions you provided :-)
One more question about debouncing: I am using Bpod State Machine r2 and not sure how should I set it to deal with debouncing of the lever.

Hi MiaoMiao,

Here's the answer in pseudo-code:

State1: If Port1In, goto State2
State2: Timer = 0.05s. If Tup, goto state3. If Port1Out, goto State1.
State3: Handle button press

For successful presses that progress to State3, the timestamp of the most recent entry to State2 is the button press onset time.

I hope this helps!
Hi Josh,
Yay! It works. Thank you so much :-)


Forum Jump: