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);
delay(1000);
SCB_AIRCR = 0x05fa0004;
break;
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
stopPlayback();
SCB_AIRCR = 0x05fa0004;
break;
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');
pause(1);
BpodSystem.PluginObjects.SoundServer.Port.write('Q','uint8')
pause(1);
BpodSystem.SerialPort.write('Q', 'uint8');
Just a thought to maybe include in other module firmware if people are having any issues.
Chuck