Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading real-time data from analog input module
Hi Josh,

I am now trying to record analog signals from a joystick using the analog input modules and send these data to a PC (MATLAB) to control the movement of a virtual object on the screen in real-time. 

I have read the Bpod wiki and learned that the way to do this should probably be using the 'startUSBStream()' function within 'BpodAnalogIn'. However, I am a bit confused about the data that, 'uint16') returns. Does each columns represent the sample from each channels? If that's the case, I am not sure why the values of the bits aren't changing when I push the joystick. I have used the GUI of 'scope()' to verify that my joystick is functioning so it shouldn't be a hardware problem.

Alternatively, do you know if there is a better way to achieve my goal?

Thank you in advance!

Hi Tin,

The format of the data stream for each sample is:


where R is character 'R' (byte 0x82)
and XY are two bytes representing an unsigned 16-bit integer for each channel that is enabled.

So if 3 channels are enabled (you'd have to keep track of which 3) and there are two samples in the buffer you'll get:

Lines 860-873 of BpodAnalogIn.m provide one way of parsing the data - and I'm sure it can be done more efficiently depending on your application.

I hope this helps!
Thank you very much Josh!


Forum Jump: