Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
running a protocol triggered by TTL
#1
Hi there,

I would like to know if it is possible to trigger/start a protocol thanks to a TTL send to the Bpod?
If yes, what would be the function in the code matlab to able the protocol to get started only when triggered by a TTL input.

Kind regards,
Sarah
Reply
#2
Hi Sarah,

In your protocol file, you can run a state machine before your main loop, which waits for a TTL and then exits:

Code:
sma = NewStateMachine();

sma = AddState(sma, 'Name', 'WaitForTTL', ...
   'Timer', 0,...
   'StateChangeConditions', {'BNC1High', '>exit'},...
   'OutputActions', {});

SendStateMachine(sma);
RawEvents = RunStateMachine;

for currentTrial = 1:nTrials

%... your code...%

end
Reply
#3
Thank you, this was very helpful.
It allows me to trigger the bpod for each trial.
And what about if I wanted to trigger it before the main loop, I am not sure what the code would be.

Kind regards,
Sarah
Reply
#4
Hi Sarah,

In the example above, 

Code:
for currentTrial = 1:nTrials

is the main loop.

-Josh
Reply


Forum Jump: