Hi Josh,
We have Bpod v2.3 and firmware v22, and we would like to use more than the 16 global timers that are defined by default in this configuration.
Thus, I have edited the firmware to increase the MAX_GLOBAL_TIMERS
parameter. Accordingly, I can now setup more than 16 global timers in MATLAB (and recover the MAX_GLOBAL_TIMERS
parameter there). However, I was surprised to see that I could still only trigger (as output of a state) global timers #1 to #16. Global timers with IDs larger than 16 simply don’t seem to execute.
In the firmware, I have verified that the GLOBALTIMER_TRIG_BYTEWIDTH
was indeed increased to 4 (leading to iuint32_t
variables) as a result of the increase in the maximum number of global timers. On MATLAB side, the transformation of the SMA to the 8-bit matrix for serial communication also seems fine.
I think I am missing something and I am sure you will be able to point me to the right direction 🙂
Maxime
In the firmware:
#define MAX_GLOBAL_TIMERS 20
#define MAX_GLOBAL_COUNTERS 1
#define MAX_CONDITIONS 1
In MATLAB:
% Display the number of available global timers
% N.B. Should match MAX_GLOBAL_TIMERS in firmware
global BpodSystem;
fprintf('%i global timers supported\n', BpodSystem.HW.n.GlobalTimers);
% Define parameters
nFlash = 9;
initialDelay = 0.100; % (mili)second
flashDur = 0.300; % (mili)second
interFlashDur = 0.300; % (mili)second
flashPorts = [1, 3]; % PWM ports
pokePort = 2; % PWM port
% Define option of global timers
GToptfun = @(d,c) {'Duration', flashDur, 'OnsetDelay', d, 'Channel', ...
sprintf('PWM%i', c), 'PulseWidthByte', 255, 'GlobalTimerEvents', 1};
% Prepare flash sequence
sma = NewStateMatrix;
nFlashPorts = numel(flashPorts);
fprintf('%i global timers created\n', nFlashPorts * nFlash);
for iFlash = 1:nFlash
delay = initialDelay + (flashDur + interFlashDur) * (iFlash-1);
for iPort = 1:nFlashPorts
GTopt = GToptfun(delay, flashPorts(iPort));
sma = SetGlobalTimer(sma, 'TimerID', iFlash + nFlash * (iPort-1), GTopt{:});
end
end
% Wait for poke in center port
sma = AddState(sma, 'Name', 'WaitForPoke', ...
'Timer', 0, ...
'StateChangeConditions', {sprintf('Port%iIn', pokePort), 'FlashPres'}, ...
'OutputActions', {sprintf('PWM%i', pokePort), 10});
% Trigger flash sequence (and leave by poking out)
% N.B. we trigger all global timers at once
% N.B. only the first 16 (out of the 2*9=18 setup ones) will start
sma = AddState(sma, 'Name', 'FlashPres', ...
'Timer', 0, ...
'StateChangeConditions', {sprintf('Port%iOut', pokePort), '>exit'}, ...
'OutputActions', {'GlobalTimerTrig', repmat('1', 1, nFlashPorts * nFlash)});
% Run trial
SendStateMatrix(sma);
RawEvents = RunStateMatrix;