Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
set a timer in the operant script
Hello everyone!
I am a new Bpod user and would like to set a timer to end a session.
Specifically, I am using the Bpod system in order to perform a sucrose preference test, so I need to know the number of licks of two Bpod systems. To do this I use the operant script but I would like to add a 30 minute timer for example. For now, I stopped the script manually...
Thank you in advance for your help,
Hello, you can use the tic and toc functions to measure time in Matlab like this:

tic % Store current time for reference with toc

for currentTrial = 1:nTrials
    % do your trial and log data

    if toc > 30 * 60 % toc will return time since tic in seconds

Hello Samira,

Another way is:

timeSinceSessionStart = now*100000 - BpodSystem.ProtocolStartTime;

This will return the time in seconds since the protocol started. Note that this time is measured by MATLAB, not the state machine clock. The two clocks will drift slightly, but if the point is to automate session-end, it should work.

This way of doing it will allow you to use tic/toc inside your code for debugging if necessary.


Forum Jump: