Hi Perla,
With the default firmware (WavePlayer), the analog output module plays sequences of voltages at its configured sampling rate. If you want to create a state that sets WavePlayer to a specific voltage, you would:
-Configure the analog output module (in the beginning of your protocol, before the main loop):
Create a WavePlayer object in MATLAB: W = BpodWavePlayer(MyPort);
Set WavePlayer's sampling rate to 1Hz: W.SamplingRate = 1;
Create a work-day's worth of samples at your desired voltage (let's say 5V): MyWave = ones(1,30000)*5;
Set the WavePlayer trigger to "Master Mode" so that new playback instructions can override current playback: W.TriggerMode = 'Master';
Load the waveform to an empty slot on the WavePlayer (let's say, slot#3): W.loadWaveform(3, MyWave);
-Configure the state machine to trigger the analog output module (let's say channels 1 and 2) using a message (let's say, message#5)
LoadSerialMessages('WavePlayer1', ['P' 3 1], 5);
Note: see 'P' op in WavePlayer serial interface for more options: https://sanworks.github.io/Bpod_Wiki/serial-interfaces/waveplayer-serial-interface/
-Create a state that changes the output voltage by playing the waveform loaded earlier:
sma = AddState(sma, 'Name', 'SetVoltage', ...
'Timer', 0,...
'StateChangeConditions', {'Tup', 'NextState'},...
'OutputActions', {'WavePlayer1', 5}); % Send message#5 (programmed with LoadSerialMessages) to the analog module
Admittedly, WavePlayer is not the ideal way to do something this simple, and I see the need - I'll make a point to prioritize development of a firmware and MATLAB class for setting fixed voltages on the output channels during specific states.
Best,
-Josh