connect AO with a state

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connect AO with a state
#1
Hi,

While the documentation says in each state the output action is limited to the events given. We want to know how to customize the states using the Analog output module to set the output channel high or low by simply adding a state containing such an action.

Thanks,
Perla
Reply
#2
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) -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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)