Hi Josh,
I have recently started to use Trial Manager for a version of AFC task, and I am getting a bunch of variegated timer errors.
I call TrialManager.getCurrentEvents with states as an argument which, themselves, last a very short time, but are followed by one state which lasts 0.75 s before the trial ends:
currentTrialEvents = TrialManager.getCurrentEvents({'LeftReward', 'RightReward'})
if BpodSystem.Status.BeingUsed == 0; return; end % If user hit console "stop" button, end session
t1 = tic;
[sma, S] = PrepareStateMachine(S, odorList, TrialTypes_LR, delays, currentTrial+1, currentTrialEvents); % Prepare next state machine.
fprintf('prepared sma for trial \t%d in: \t%3.4f secs\n\n', currentTrial+1, toc(t1))
[...]
sma = AddState(sma, 'Name', 'LeftReward', ...
'Timer', LeftValveTime,... % duration of valve on
'StateChangeConditions', {'Tup', 'WaitForLeftPoke'},...
'OutputActions', {'ValveState', 1, 'PWM1', S.LedLickPortIntensity});
sma = AddState(sma, 'Name', 'WaitForLeftPoke', ...
'Timer', 0, ...
'StateChangeConditions', {'Port1In', 'LeftDrinking'},...
'OutputActions', StimulusOutput);
sma = AddState(sma, 'Name', 'LeftDrinking', ...
'Timer', 0,...
'StateChangeConditions', {'Condition1', 'LeftDrinkingGrace'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'LeftDrinkingGrace', ...
'Timer', 0.75,...
'StateChangeConditions', {'Tup', 'exit', 'Port1In', 'LeftDrinking'},...
'OutputActions', {});
The errors I get (very often, at least once per session) are like these, where the timer referred by the error changes every time and the range is not limited to what I illustrate here:
Mouse 1:
prepared sma for trial 10 in: 0.0131 secs
Error while evaluating TimerFcn for timer 'timer-4'
Error: The USB serial port did not return the requested number of bytes.
prepared sma for trial 11 in: 2.6123 secs
Mouse 2:
prepared sma for trial 11 in: 0.0125 secs
Error while evaluating TimerFcn for timer 'timer-6'
Error: Unknown event code returned: 190
Mouse 3:
prepared sma for trial 13 in: 0.0125 secs
Error while evaluating TimerFcn for timer 'timer-7'
Error: Unknown event code returned: 245
From the first error, I deduce that sometimes my Win computer slows down significantly, but I don't know if there could be any other explanations.
I don't have any other programs running. I tried to monitor the activity in Task Manager but so far I haven't caught the culprit.
Do you have any suggestions? Are timer number and event code informative?
I appreciate your help.
Paola