Hi,
I'm a relative newcomer to Bpod, and am having trouble communicating with the Analog Input module...
I am using Matlab and PsychToolBox in Ubuntu, and can successfully connect and run some of the example Bpod protocols that make use of other modules e.g. HiFiSound2AFC works fine with the HiFi module, suggesting the general Bpod installation is okay. The AI module is detected in the Bpod console tab, and I have paired it with a USB port.
However, I cannot connect to the module from the Matlab cmd line:
A = BpodAnalogIn(BpodSystem.ModuleUSB.AnalogIn1);
Error: unable to connect to Bpod Analog Input module.
If I remove the config string in line 121 ArCOMObject_Ain.m
from this:
obj.Port = IOPort('OpenSerialPort', portString, 'BaudRate=256000, OutputBufferSize=100000, InputBufferSize=100000, DTR=1');
to this:
obj.Port = IOPort('OpenSerialPort', portString);
I can at least find and connect the module:
A = BpodAnalogIn(BpodSystem.ModuleUSB.AnalogIn1);
Analog Input Module found.
and I can open the oscilloscope GUI by executing A.Scope
But when I click 'Run' in the scope GUI I get the following warnings:
"Error while evaluating TimerFcn for timer 'timer-2'
Index exceeds the number of array elements. Index must not exceed 64."
And when I click 'Stop' I get the following error messages:
"Index exceeds the number of array elements. Index must not exceed 64.
Error in ArCOMObject_Ain/read (line 303)
varargout{i} = uint8(ByteString(Pos😛os+nValues(i)-1)); Pos = Pos + nValues(i);
Error in BpodAnalogIn/scope_StartStop (line 657)
obj.Port.read(obj.Port.bytesAvailable, 'uint8');
Error in BpodAnalogIn>@(h,e)obj.scope_StartStop() (line 541)
'Callback',@(h,e)obj.scope_StartStop(), 'BackgroundColor', [0.7 0.7 0.7], 'FontSize', TitleFontSize,...
Error while evaluating UIControl Callback."
I can trace i issue to ArCOMObject_Ain.m here
switch obj.Interface
case 0
ByteString = fread(obj.Port, nTotalBytes, 'uint8')';
case 1
ByteString = IOPort('Read', obj.Port, 1, nTotalBytes);
case 2
ByteString = srl_read(obj.Port, nTotalBytes);
end
Where IOPort Read returns a 64 length vector in ByteString that does not match nTotalBytes.
I'm guessing there is something going wrong with the serial port communication somewhere but any tips would be much appreciated thanks!
Oli