dstorace wrote[quote='dstorace' pid='4493' dateline='1666122802']
Josh wrote[quote='Josh' pid='4492' dateline='1666120798']
Hello Doug,
re: 1. Correct, you'd use bin2dec. Your example raises a (pretty major) issue with PulsePalModule firmware - if the module receives code 255 from the state machine, it will return its self-description instead of triggering channels, which is not what you want. All other bytes should work fine. This will require a firmware update with a new serial scheme (the original PulsePal firmware was designed and prototyped with the 4-channel module). In the meantime, if you need to trigger all 8 together, you can add a 100?s onset delay to channels 1-7, and trigger channel 8 from the subsequent state.
re: 2. Confirmed.
re: 3. There's no way to change resting voltage from the state machine. You can make a pulse train with both Phase1Duration and PulseTrainDuration up to 72 minutes long, if that would work for your application.
-Josh
Good to know! I will make sure to work around that issue for now.
Regarding re 3 -- I think this can work (since our sequences generally don't go longer than a few minutes). Because the channels with those 72 minute long pulse trains will need to get interrupted -- I think this requires that I set the trigger mode to 1?
Thanks!
Expanding on the last post -- I'm trying to trigger a pulsetrain on channel 7 of the analogout pulsepal module based on user entered values in the GUI. Upon detecting a BNCHigh, I call a softcode function from an output action which updates phase1Duration and pulseTrainDuration.
P1 = PulsePalModule(BpodSystem.ModuleUSB.PulsePal1);
global S
S = struct;
S.GUI.Duration_1 = 1; % phase1Duration.
for currentTrial = 1:MaxTrials
S = BpodParameterGUI('sync', S);
sma = AddState(sma, 'Name', 'WaitingForTrigger', ...
'Timer', 0,...
'StateChangeConditions', {'BNC1High', 'ResponseToTrigger'},...
'OutputActions', {'SoftCode', 1});
sma = AddState(sma, 'Name', 'ResponseToTrigger', ...
'Timer', 0,...
'StateChangeConditions', {'Tup', '>exit'},...
'OutputActions', {'PulsePal1', bin2dec('01000000'), 'PulsePal2', bin2dec('01000000')});
end
function SoftCodeHandler(softCode)
global BpodSystem
global P1
global S
S = BpodParameterGUI('sync', S);
P1.phase1Voltage(7) = 5;
P1.phase1Duration(7) = S.GUI.Duration_1;
P1.pulseTrainDuration(7) = S.GUI.Duration_1;
P1.pulseTrainDelay(7) = 0;
(some details were left out of code to simplify things)
The complication is that although the bpod detects the BNC and does something -- if the user changes the GUI value, the first BNCHigh (after the user change) results in the program using the previous GUI value. However, subsequent triggers use the updated value. For example:
S.GUI.Duration_1 = 1 by default. If I change it to 2, then the first trigger (after I press enter to update the GUI) generates a 1-s pulse, but subsequent triggers correctly generate a 2-s pulse.
This wasn't happening when I was updating everything in the softcode.
Please advise!