Manually deliver liquid - Printable Version

+- Forums (
+-- Forum: Bpod (
+--- Forum: Software (
+--- Thread: Manually deliver liquid (/showthread.php?tid=953)

Manually deliver liquid - ccz - 10-03-2020

We are using Bpod for a 2AFC task. We are using 8 valves attached to a valve module for the central spout, and 2 valves directly attached to the state machine for the lateral spouts. All the spouts deliver liquid. We are wondering if there is a way to manually deliver liquid with a set valve opening time?

RE: Manually deliver liquid - Josh - 10-09-2020


The valve driver firmware doesn't support timed pulses - so all timing information has to come from the state machine.
If you're manually delivering between trials, or while not running a session, you can create a function to do the override:

function OverrideValveModule(valveID, valveDuration)
sma = NewStateMachine();
sma = AddState(sma, 'Name', 'ValveOpen', ...
'Timer', valveDuration,...
'StateChangeConditions', {'Tup', 'ValveClose'},...
'OutputActions', {'ValveModule1', ['O' valveID]});
sma = AddState(sma, 'Name', 'ValveClose', ...
'Timer', 0,...
'StateChangeConditions', {'Tup', 'Exit'},...
'OutputActions', {'ValveModule1', ['C' valveID]});
RawEvents = RunStateMachine;

To open valve 3 for 0.5s, you'd call it from the command line as:
OverrideValveModule(3, 0.5);

The situation is a bit more complicated if you want to manually override while a trial is running.
You'd add the states above to your state machine description, and trigger them from MATLAB using a soft code as in this example.
If you can't have an interruption of the valve-open time, you can link the valve open and close instructions to a global timer as in this example, then step into a state to trigger the global timer and immediately step back to resume the flow of states in your protocol. 
You can also create a GUI button to trigger the soft code, as we use to manually flash the port lights in the LightChasing example protocol.

I hope this helps!