Start/Stop logging analog input module in outputActions of state

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start/Stop logging analog input module in outputActions of state
I have an analog rotary encoder for a mouse treadmill and I would like to send its signal to the analog input module of bpod. 
To have timestamps that I can sync with bpod timestamps later, I thought I could start/stop logging data at the outputActions of one of my states.
For example:

sma = NewStateMatrix();
sma = AddState(sma, 'Name', 'baseline','Timer', 0.05,'StateChangeConditions', {'Tup', 'baseline'},'OutputActions', {'AnalogInput1, 1'});

Do you think that's possible? If so could you send me an example code? Particularly what is the code for 'start' or 'stop' I should use at the action?
Hi Gabriela,

The bytes you need to send are documented here: ['L' 1] to start logging, and ['L' 0] to stop logging.

Each state can send one byte by default in output actions: {'AnalogIn1', B} where B is the byte you want to send.
So one (hacky) option is to use two states.
You can make it cleaner by programming the state machine's message library. This allows you to program each byte to equal a string of up to 3 bytes - so before building your state machine you'd use: 

LoadSerialMessages('AnalogIn1', {['L' 1], ['L' 0]});

Then, trigger start and stop as messages 1 and 2 using output actions: {'AnalogIn1', 1} to start and {'AnalogIn1', 2} to stop.

FYI we know this is an awkward way to send byte strings. In our next software and firmware update (we hope to release by January) you'll be able to skip LoadSerialMessages, and simply use paste the byte string you want to send into the output actions, e.g. {'AnalogIn1', ['L' 0]} However, use of LoadSerialMessages will still be available for backwards compatibility.

I hope this helps
Thank you for your reply.
I think i am still missing something. 
The implementation you suggested works if I initialize the object with the function ArCOMObject but not with BpodAnalogIn (botton example suggested here).
If it's the first case, I can't retrieve the data with the getData or read functions suggested.
Can you point to each function to open the object and how to read?
(I am using Windows 7 Matlab 2018a with PTB-3 installed)
Thank you again!
Hi Gabriela,

I'm not sure I understand what "initialize the object with the function ArCOMObject" means.

Also, what happens when you try to use getData?

If you post the code you're trying to run and the error messages you're seeing, I can be more helpful.


Forum Jump:

Users browsing this thread: 1 Guest(s)