Forums

Welcome, Guest
You have to register before you can post on our site.

Search Forums

(Advanced Search)

Latest Threads
Speaker for Bpod HiFi Mod...
Forum: Hardware
Last Post: Josh
09-21-2022, 04:05 AM
» Replies: 1
» Views: 502
Unable to connect to Anal...
Forum: Software
Last Post: dbuehler
09-16-2022, 02:35 PM
» Replies: 0
» Views: 240
frequent Trial Manager ti...
Forum: Software
Last Post: paola
09-16-2022, 07:48 AM
» Replies: 4
» Views: 319
Bpod r1 RunStateMatrix se...
Forum: Software
Last Post: Josh
09-13-2022, 04:22 PM
» Replies: 3
» Views: 351
Bpod error during trial
Forum: Hardware
Last Post: Josh
09-06-2022, 01:19 AM
» Replies: 1
» Views: 467
Issue reading data from a...
Forum: Software
Last Post: Josh
09-01-2022, 04:27 PM
» Replies: 3
» Views: 1,144
set a timer in the operan...
Forum: Software
Last Post: Josh
09-01-2022, 04:24 PM
» Replies: 2
» Views: 298
State machine not recogni...
Forum: Hardware
Last Post: David_G
08-30-2022, 01:38 PM
» Replies: 2
» Views: 512
Hifi module bugs
Forum: Hardware
Last Post: Josh
08-29-2022, 04:36 PM
» Replies: 1
» Views: 595
Bonsai Softcode Connectio...
Forum: Software
Last Post: Josh
08-08-2022, 04:29 PM
» Replies: 1
» Views: 623

 
Wink Unable to connect to AnalogInput Module after stopping previous session
Posted by: dbuehler - 09-16-2022, 02:35 PM - Forum: Software - No Replies

Dear Bpod Users,
I am new here and slowly trying to read into the bpod scripts.
For some time now, I have been having problems starting a new session after previously ending the previous session via stop button.
I get the following error message:


Code:
Error in Light2AFC_AnalogStreaming (line 47)
    A = BpodAnalogIn(BpodSystem.ModuleUSB.AnalogIn1);

Error in run (line 91)
evalin('caller', strcat(script, ';'));

Error in NewLaunchManager>LaunchProtocol (line 717)
run(ProtocolPath);
 
Error while evaluating DestroyedObject Callback



Is it because the AnalogInput module is not exiting properly? I also get this error message when I run the test script "Light2AFC_AnalogStreaming"
The last lines of code look like this:


Code:
SendStateMatrix(sma);
    RawEvents = RunStateMatrix;  
    if ~isempty(fieldnames(RawEvents)) % If trial data was returned
        BpodSystem.Data = AddTrialEvents(BpodSystem.Data,RawEvents); % Computes trial events from raw data
        BpodSystem.Data.TrialSettings(currentTrial) = S; % Adds the settings used for the current trial to the Data struct (to be saved after the trial ends)
        BpodSystem.Data.TrialTypes(currentTrial) = TrialTypes(currentTrial); % Adds the trial type of the current trial to data
        UpdateSideOutcomePlot(TrialTypes, BpodSystem.Data);
        SaveBpodSessionData; % Saves the field BpodSystem.Data to the current data file
    end
    HandlePauseCondition; % Checks to see if the protocol is paused. If so, waits until user resumes.
    if BpodSystem.Status.BeingUsed == 0
        A.scope_StartStop; % Stop Oscope GUI
        A.endAcq; % Close Oscope GUI
        A.stopReportingEvents; % Stop sending events to state machine
        return
    end


Does anyone have a solution for this? 
Many thanks in advance
Cheers,
Daniel


  Speaker for Bpod HiFi Module HD
Posted by: malda - 09-13-2022, 09:09 PM - Forum: Hardware - Replies (1)

I am completely new to Bpod system and trying to use Bpod HiFi Module HD. I would appreciate it if someone could recommend a few affordable options for the speaker to use with it. The doc says any "amplified speaker" will do, but not sure what exactly that means. For e.g., how do I tell if a speaker is an amplified speaker or not or more generally if it would work with Bpod HiFi Module HD? Will Bpod HiFi Module HD be able to control volume and tone frequency in any such speakers through its Matlab interface?


  frequent Trial Manager timer errors
Posted by: paola - 09-13-2022, 10:30 AM - Forum: Software - Replies (4)

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:

Code:
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:


Quote: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


  Bpod error during trial
Posted by: Kovax - 09-05-2022, 12:37 PM - Forum: Hardware - Replies (1)

Hi!

I had protocoll that works fine if the mouse not licks for a really long period of time. I am using Bpod statemachine r0.5 with firmwer build 5, and i noticed, that in some sessions (independent of what protocoll) if the mouse licks in one trial for like 1 minute than Bpod crashes. I am using matlab, and the error i get: 

Subscript indices must either be real positive integers or logicals.

Error in RunStateMatrix (line 205)
        if TimeStamps(end) < TrialStartMicroseconds


Is there a way to solve this issue, if i update the firmware will it help?

Thanks so much!

Péter


  Bpod r1 RunStateMatrix serial read error
Posted by: George - 09-05-2022, 07:24 AM - Forum: Software - Replies (3)

Hiya Josh,

We've got a setup running Bpod r1 and occassionaly it throws an error in RunStateMatrix:

Code:
201    nTimeStamps = BpodSerialRead(1, 'uint16');
202    TimeStamps = BpodSerialRead(nTimeStamps, 'uint32');
203            if TimeStamps(end) < TrialStartMicroseconds


The error is an indexing error in Line 203.

We've caught it once with the debugger and what's happening is that nTimeStamps is incorrect. The session was on trial 142 but it was just over 1300. I don't really understand serial reading but I'd guess that there weren't >1300 uint32 worth of bytes to read, so the next line returned TimeStamps as empty, and so line 203 errored.

I have a janky temporary fix, which I found when I used IOPort() to read a single int16 value while in the debugger and it returned the correct number of trials. I've got a janky fix where nTimeStamps is read again if TimeStamps is returned empty, but I don't know what's going on.

Any thoughts?


  set a timer in the operant script
Posted by: Samira - 08-31-2022, 06:47 AM - Forum: Software - Replies (2)

Hello everyone!
I am a new Bpod user and would like to set a timer to end a session.
Specifically, I am using the Bpod system in order to perform a sucrose preference test, so I need to know the number of licks of two Bpod systems. To do this I use the operant script but I would like to add a 30 minute timer for example. For now, I stopped the script manually...
Thank you in advance for your help,
Samira


  State machine not recognized by COM port after attempted firmware update
Posted by: David_G - 08-29-2022, 02:47 PM - Forum: Hardware - Replies (2)

Hi Josh (and friends)!

Immediately after attempting to manually update a state machine from v22 to v23 last night, the state machine (which has gone through a few successful firmware updates + was working fine up until this moment) turned off and stopped being recognized when plugged into COM ports. I tried power cycling the state machine and connecting it to different ports on different computers, but nothing worked (whenever I plugged it in, I got no response from the PC and no LED illumination on the state machine itself). Another state machine plugged into the same PC was immediately recognized. If it helps to know, I was using Arduino 1.8.16 and I confirmed that I was updating a teensy 3.6 board on the appropriate COM port before uploading. I got the "Done uploading" message after the pop up window appeared.

Do you have any ideas re: what might have precipitated this issue and how I can reconnect to my state machine?

Thanks so much!

-David


  Hifi module bugs
Posted by: themachine - 08-22-2022, 12:31 PM - Forum: Hardware - Replies (1)

Hello Josh,
 
my lab has some problems with the HD HiFi module. It used to work fine but for the past few weeks it is not playing sounds as it should.
- when playing at a high sampling rate (192kHz) it sounds as if there is a loop and there are pauses in between the playing of the sound, this gets somewhat better at lower sampling rates though.
- in protocols or when directly interacting with the Hifi module, it seems as if there are extra sounds which have not been removed from the storage and are playing beside the wanted sound or shortly before/after. This happens especially right after a change from one sound to another
We suspect it might be a software problem, especially due to the extra sounds being played, but we are not sure ourselves how to fix this.
- the sounds are often not playing for the full time specified (eg.: 1s or 2s)
- Playing different sounds in each speaker doesn't work reliably in protocols, although one side is usually somewhat louder
- there are always cracking noises while playing the sounds

We tried the Bpod developer and master versions, the Bpod firmware versions 22 and 23 and the Hifi firmware versions 1 and 3 and the problems still persist.
 
Do you have any suggestions what we can try to fix these issues?
I can send you recorded examples if needed but wasn’t able to upload them here.

Thank you

Jasper



Here is the code we used for directly interacting with the module:


% Connect to HiFi module
clear H;
H = BpodHiFi('COM4');

% Choose sampling frequency
SF = 192000; % hertz
% SF = 44100; % hertz


H.SamplingRate = SF;

% Display connection in command window
H.VerboseMode = 1;

% Create pure tone in only one speaker (nothing in the other)
tonefreq = 1000; % hertz
dur = 1; % second
waveform = [GenerateSineWave(SF, tonefreq, dur); zeros(1, SF*dur)];
% waveform = GenerateSineWave(SF, tonefreq, dur);

% Choose volume
H.DigitalAttenuation_dB = -20;

% Send the sound
H.load(1, waveform, 'LoopMode', 0);
H.push;

% Play the sound
H.play(1);
pause(dur+1);
H.stop;


  How to read licks from interface board
Posted by: rparpa - 08-08-2022, 11:12 AM - Forum: Hardware - Replies (1)

Dear fellow Bpod users,

I am using a external TTL pulse to trigger water reward for an experiment and I want to record when the animal is licking. 
I have been looking into how to detects licks using the Mouse Behavior Port connected to the interface Port Interface Board, but I could not find on the Wiki nor the forum. 
Could someone guide me on how to measure the licks during my experiment?

Thank you
Romain


  Bonsai Softcode Connection
Posted by: MarcoC - 08-04-2022, 05:28 PM - Forum: Software - Replies (1)

Hi everyone, 
Sorry to bother again!

I'm currently facing some issues when attempting to make Bpod communicate with Bonsai.

As of now, I'm able to connect via TCP and to send bytes to the state machine to trigger a state change via SoftCode when a certain condition is met (thanks to the SendMessage node). 

Code:
sma = NewStateMatrix();

sma = AddState(sma, 'Name', 'WaitingForBonsai', ...
   'Timer', 0,...
   'StateChangeConditions', {'SoftCode5', 'Triggered'},...
   'OutputActions', {});

sma = AddState(sma, 'Name', 'Triggered', ...
   'Timer', 1,...
   'StateChangeConditions', {'Tup', '>exit'},...
   'OutputActions', {});

However, what I'm struggling to accomplish is to have Bpod talking to Bonsai in the same way:

Code:
sma = NewStateMatrix();

sma = AddState(sma, 'Name', 'SendingBytesToBonsai', ...
   'Timer', 1,...
   'StateChangeConditions', {'Tup', 'Continuation'},...
   'OutputActions', {'SoftCode', 4});

sma = AddState(sma, 'Name', 'Continuation', ...
   'Timer', 1,...
   'StateChangeConditions', {'Tup', '>exit'},...
   'OutputActions', {});

Does not result in anything in the ReceiveMessage node within the same Bonsai instance.

Have you ever encountered similar problems as the one here?
Thanks in advance,
Marco