Welcome, Guest
You have to register before you can post on our site.

Search Forums

(Advanced Search)

Latest Threads
Valve Driver Module vs Po...
Forum: Hardware
Last Post: Remi_tds
6 hours ago
» Replies: 2
» Views: 31
Unable to connect to Anal...
Forum: Software
Last Post: paulbanks
09-14-2020, 12:31 PM
» Replies: 5
» Views: 247
Arduino Due not showing
Forum: Hardware
Last Post: Josh
09-14-2020, 01:15 AM
» Replies: 8
» Views: 469
Ports 4-8 not registering...
Forum: Hardware
Last Post: LucasKin
09-13-2020, 10:40 AM
» Replies: 2
» Views: 82
Issue with nActiveChannel...
Forum: Software
Last Post: PrsaLab
09-10-2020, 11:26 AM
» Replies: 2
» Views: 94
Forum: Software
Last Post: bimac
09-04-2020, 08:08 AM
» Replies: 0
» Views: 101
Reading real-time data fr...
Forum: Software
Last Post: tly627
09-01-2020, 02:45 AM
» Replies: 2
» Views: 150
Not input detected by the...
Forum: Hardware
Last Post: Josh
08-25-2020, 06:55 PM
» Replies: 1
» Views: 365
1 Matlab controls 2 Pulse...
Forum: Software
Last Post: Josh
08-25-2020, 06:37 PM
» Replies: 3
» Views: 2,387
"Serial" Module BPOD
Forum: Hardware
Last Post: AlvaroLuna
08-24-2020, 04:23 PM
» Replies: 0
» Views: 160

  Bpod v2.3 ports half working
Posted by: ckopec - 03-25-2020, 07:43 PM - Forum: Hardware - Replies (6)

Josh (or anyone who may know),

Just tried building the new v2.3 Bpod (hold up in a my garage trying to keep busy as Princeton is now shut down).  Everything seemed good except when I connect a nose port to jacks 1 and 4. Poke in events are not detected (other port functions, LED, water valve work fine in all jacks) and poke in events are detected if I connect the same nose port to jacks 2 and 3.  I've been trying to hunt around on the board for a short (seeedstudio did once send us a circuit board that was wired incorrectly with a hidden short in one of the layers) but so far can't seem to find anything.  The voltage input to IC12 seems off for those 2 jacks so I think IC12 is functioning fine, it's just getting a bad input and passing that along.  When I test the pins on the ethernet port on the Bpod board with a nose port connected everything looks identical between a functioning jack (2 or 3) and the non-functioning jacks (1 and 4).  Finally I measured the voltage across the phototransistor on the nose port itself.  When connected to a functioning jack I see a voltage of 0.15V when poked out and 4.55V when poked in.  However, when I connect the same nose port to a non-functioning jack I see a voltage of 0.15V when poked out but only 0.65V when poked in.  I get the same result after removing the new 22k pull-up resistors.  If I measure the voltage across the pads for the new pull-up resistors I get a similar behavior.  Functioning jack, poke out 4.85V, poke in 0.15V.  Non-functioning jack, poke out 4.85V, poke in 4.15V.  Any thoughts on what could be causing this? Any other tests I should run to try to find the source of the problem (teensy?, IC12?, PCB?)


  Assembly instructions Bpod 2.0-2.3
Posted by: Max - 03-11-2020, 02:50 PM - Forum: Hardware - Replies (2)

I could not find the assembly instructions for the newer Bpod modules could someone point me in the right direction or share them with me  Smile

Best regards Max

  BNC input logic
Posted by: MarcoC - 03-10-2020, 01:54 PM - Forum: Software - Replies (1)

Hello everyone!
I was wondering if the State Machine accepts a 0-5V logic (I want to use an arduino's digital input to trigger a new state) with 0 being the LOW level and 5V being the HIGH.

Thanks in advance!
Have a great day

  Bpod Freezes after Set Amount of Time
Posted by: Adam - 03-08-2020, 07:46 PM - Forum: Software - Replies (8)


I am encountering a bug where Bpod freezes in the middle of a protocol: valves do not open/close, the trial does not advance, and the Bpod Console displays a single state with no transitions. This happens on only one of two Bpod machines that I have, despite the fact that they are running the exact same protocol. (They are, however, connected to different hardware, as I describe below.) I have to Ctrl+C in order to end the program, and when I do, the following error message is printed:

Operation terminated by user during ArCOMObject_Bpod/write (line 295)

In SendStateMachine (line 333)
                       BpodSystem.SerialPort.write(ByteString(i), 'uint8'); % send byte-wise, to avoid
                       HW timer overrun

In DistributionalRL_6Odours (line 236)
   SendStateMachine(sma); % With TrialManager, you can send the next trial's state machine while the
   current trial is ongoing

In run (line 91)
evalin('caller', strcat(script, ';'));

In NewLaunchManager>LaunchProtocol (line 748)

Interrupt while evaluating DestroyedObject Callback.

It appears that Matlab is failing to write information to the serial port, but I have no idea why that might be. This Bpod receives TTLs from a microscope in order to perform synchronization. It also sends a voltage out to trigger the microscope. Interestingly, the problem appears worse when the microscope is running (and Bpod is receiving TTLs). In this case, Bpod almost always freezes after exactly 31 trials. (If I run a slightly different protocol, it becomes ~30 trials, but a similar amount of time and TTLs.) However, it is worth noting that every so often (perhaps 10% of attempted runs?), the program does run successfully until completion, even when the microscope is also running. When the microscope is not running, Bpod generally runs longer without errors, and tends to have a higher success rate, but nonetheless still sometimes fails in the same manner, after around 80 trials. The other Bpod, which runs without error, is not connected to a microscope and never receives TTLs, but is otherwise configured in exactly the same way.

Perhaps related to this issue, I sometimes get a different error on the same Bpod State Machine:

Error using ArCOMObject_Bpod/read (line 359)
Error: The USB serial port did not return the requested number of bytes.

Error in TrialManagerObject/startTrial (line 89)
           SMA_Confirmed =, 'uint8');

Error in DistributionalRL_6Odours (line 189)
   TrialManager.startTrial(); % Start next trial's state machine (call with no argument since it was
   already sent)

Error in run (line 91)
evalin('caller', strcat(script, ';'));

Error in NewLaunchManager>LaunchProtocol (line 748)

359                 error('Error: The USB serial port did not return the requested number of bytes.')

Here, the problem is again with serial communication between Matlab and Bpod, but at the read step. I suspect these are related somehow, but I don't know in what way.

I have taken a variety of steps to debug (some of which are suggested in this thread), but none of them have been successful. They have been:

1. Re-installing the Bpod software
2. Re-uploading the firmware (v22). Verified that upload was successful through the USB native port.
3. Changing out the USB cable from Bpod to computer
4. Powering Bpod with a separate 12V DC adapter, as opposed to just the USB
5. Disabling unused inputs in the Bpod Console

I would greatly appreciate any help you could provide!


Bpod State Machine version 0.8
Latest Gen2 Bpod software
Bpod firmware version 22
Matlab 2019b 
Inspiron 3847 desktop with an Intel i7 processor and 16 GB of RAM
64-bit Windows 10 Pro OS
PsychToolbox is installed
Bpod is communicating with an 8-channel valve driver module and a port interface + valve
Only port 1 is selected in Bpod Console > Settings > Ports, corresponding to the lick sensor input
Other USB input is disabled in Bpod Console > USB module configuration menu
Only other USB devices connected to the computer are standard keyboard, mouse, and speakers

  Simple TTL out help
Posted by: k8flr - 03-06-2020, 04:22 PM - Forum: Software - Replies (4)


I am new to Bpod programming and running into some basic roadblocks as I learn to develop my own protocol. 

For now, I just want to generate a TTL pulse with a specific delay from a specific BNC port on my Bpod r2 state machine. I have managed to launch the code, however I keep getting error messages that do not indicate (to me) what I am doing incorrectly.

function TTLpulse
global BpodSystem

MaxTrials = 10;

S = BpodSystem.ProtocolSettings;
if isempty(fieldnames(S))
% no field names needed


for currentTrial = 1:MaxTrials
  S = BpodSystem.ProtocolSettings;

  sma = NewStateMachine()
  sma = AddState(sma, 'Name', 'Trigger1', 'Timer', 0, 'StateChangeConditions', {'BNC1', 'High'}, 'OutputActions', {});
  sma = AddState(sma, 'Name', 'Delay', 'Timer', 10, 'StateChangeConditions', {'Tup', 'exit'}, 'OutputActions', {});
  RawEvents = RunStateMatrix;



Thank you for any help, advice, or resources for programming BNC TTL pulses from a Bpod r2.

  Bpod becomes slower and slower as task code running
Posted by: CharlesYin - 02-25-2020, 10:40 PM - Forum: Software - Replies (3)

Hi Josh,

I'm using Bpod r2. I found my Bpod becomes slower and slower as the task code running. After 2 hours of running, there is an obvious gap between touching the sensor port and the start of the trial, which affects animal performance a lot. I'm wondering is this because of the problem inside Bpod or computer memory? How should I fix it?


  Serial Interface for PulsePalModule
Posted by: Jeff - 02-25-2020, 09:51 PM - Forum: Software - Replies (1)

Hi there...How can I run the Analog Output Module as a PulsePalModule using the serial interface? Is the syntax similar to running the module as a WavePlayer? Thanks in advance...

  Increasing max number of waveforms on AOM
Posted by: ckopec - 02-19-2020, 03:17 AM - Forum: Software - Replies (1)


Basically I'm just tinkering so I can better understand how these things work.  I wanted to see if it was possible to increase the number of sounds (waveforms) the AOM can play running the BpodAudioPlayer_Live firmware.  I presume the two lines I need to adjust are:

const byte maxWaves = 20;
const uint32_t bufSize = 2000;

As currently configured almost all the teensy 3.6's memory is used up.  Therefore I figured if I wanted to increase the number of waves I'd need to decrease the buffer size.  And while I can decrease the buffer size to 1000 (things still play fine if maxWaves stays at 20), and I can decrease the maxWaves value below 20 (things play fine keeping maxWaves at 20 even if I increase bufSize above 2000), if I try to increase the maxWaves, say to 21 or 22 and decrease bufSize so a comparable amount of memory is used ~95%, the sounds simply don't play.  There are no errors in either Arduino when compiling and uploading, or matlab when running, just no sound output. Is there another variable or line I need to change?


On a related note, are there any thoughts to upgrading Bpod and modules to run with teensy 4x at its core (high clock speed and more onboard memory could mean more sounds sampled at a higher rate than 44.1kHz)?


  System Reboot
Posted by: ckopec - 02-18-2020, 07:10 PM - Forum: Software - Replies (1)

We've found that occasionally rebooting the Bpod and AOM helps things run smoothly (occasionally the system can get in a non-functional state and this is the only way to get it out, though we're still trying to figure out exactly what's causing the non-functional state).  Since the power comes from the USB hub on the computer, rebooting or even powering the computer down does not cut power to the teensy.  So to force a reboot in the bpod we added the following code to the firmware in the section that starts

if ((PC.available() > 0) && (smaPending == false)) {
CommandByte = PC.readByte();

switch (CommandByte) {

case 'Q':  // SYSTEM RESET
          digitalWrite(GreenLEDPin, LOW);
          analogWrite(BlueLEDPin, 250);
          analogWrite(RedLEDPin, 128);
          SCB_AIRCR = 0x05fa0004;

Sending a Q causes the LED to turn magenta for 1s before it reboots and the LED goes back to blue flashing.

For the AOM we added the following in the section that starts

if (newOpCode) {
newOpCode = false;
switch(opCode) {

case 'Q': // SYSTEM RESET
        SCB_AIRCR = 0x05fa0004;

Sending a Q will stop sounds and reboot the teensy causing the orange light to blink. 

We've added these commands to the function EndBpod.m after the write Z command

 BpodSystem.SerialPort.write('Z', 'uint8');
 BpodSystem.SerialPort.write('Q', 'uint8');

Just a thought to maybe include in other module firmware if people are having any issues.


  DC Barrel Jack PCB cutout
Posted by: ckopec - 02-18-2020, 06:52 PM - Forum: Hardware - Replies (1)

Josh or other Bpoders

The drill holes in the PCB file for the DC barrel Jack on the Bpod v2.3  appear to be large circles rather than thin ovals.  Any reason for the change? The digi-key barrel jack part number is the same as listed on the wiki so I'm assuming it'll still fit.