Hi Josh,
This is the code I am using:
% Configure Flex I/O Channels
BpodSystem.FlexIOConfig.nReadsPerSample = 1;
BpodSystem.FlexIOConfig.analogSamplingRate = 1000;
BpodSystem.FlexIOConfig.channelTypes = [4 4 4 4];
BpodSystem.FlexIOConfig.channelTypes(1) = 2; % 0 Digital in; 2 Analog In
BpodSystem.FlexIOConfig.thresholdMode(1) = 1;
BpodSystem.FlexIOConfig.threshold1(1) = 2.1;
BpodSystem.FlexIOConfig.polarity1(1) = 0;
BpodSystem.FlexIOConfig.threshold2(1) = 2;
BpodSystem.FlexIOConfig.polarity2(1) = 1;
%--- Initialize plots and start USB connections to any modules
BpodParameterGUI('init', S); % Initialize parameter GUI plugin
% Initialize analog viewer GUI (online monitor of FlexIO analog inputs, not necessary for data logging)
BpodSystem.startAnalogViewer;
% Main loop (runs once per trial)
for currentTrial = 1:maxTrials
S = BpodParameterGUI('sync', S);
sma = NewStateMachine();
sma = AddState(sma, 'Name', 'Start', ...
'Timer', 1,...
'StateChangeConditions', {'Tup', 'Start2'},...
'OutputActions', {'PWM3', 025, 'AnalogThreshEnable', 1});
sma = AddState(sma, 'Name', 'Start2', ...
'Timer', 5,...
'StateChangeConditions', {'Tup', 'exit','Port3In','stateTurnLedRedOn','Flex1Trig1','stateTurnLedRedOn'},... %Flex1Trig1 // Flex1High
'OutputActions', {'PWM3', 0, 'PWM4', 0});
sma = AddState(sma, 'Name', 'stateTurnLedRedOn', ...
'Timer', 1,...
'StateChangeConditions', {'Tup', 'exit','Port3Out','Start2','Flex1Trig2','Start2'},... % Flex1Trig2 // Flex1Low
'OutputActions', {'PWM4', 255});
I have tried using every Flex IO channel in my bpod machine and I also tried the bpod machine of a colleague of mine. I still don't get any change of state using the analog input mode. I tried different threshold values and threshold modes. As I mentioned earlier, if I set the Flex IO channel as digital input and the OutpuActions to Flex1High/Flex1Low the transitions work as expected.
Cheers,
Gregorio