Question on data transferred via P2 protocol

Started by asc, February 04, 2014, 09:05:25 AM

Previous topic - Next topic

asc

Hi,

Using parsing code to read the P2 data streaming from an EEG-SMT unit you can get something like this type of output:

version 2 [protocol version P2]
count 6 [packet count]
data [61, 478, 608, 669, 686, 673]
switches 15 [jumper switch configuration]

In this case both channels are in use. So for the values in data are these assumptions correct?
data [61, 478, 608, 669, 686, 673]

The first four values represent  +ch1, -ch1, +ch2, -ch2.

In that case, if only two channels are in use what do the last two values represent exactly? Reference values from DRL?

Appreciate your response.

Thanks,
asc

BMcFrizzle

As far as I know, they are meaningless. It's odd because you would expect those bytes to be completely empty since that part of the packet isn't "populated". But from what I understand, you use the first 2 bytes for ch1, the second 2 bytes for ch2, and toss the rest. After all, the SMT only provides a 10-bit resolution (according to the firmware) -- so even more bits (6) are "useless" in the two channels that you do get data from.

In your example, you would only use the first two values, representing the 2 channels of the SMT board. Note that each value in your array is made from 2 Bytes that are "concatenated" to give you a 10-bit number (0-1023). Of course it is really a 16-bit number in the firmware, but the SMT only populates the first 10 bits.

I'm pretty sure the P2 format was originally to support up to 6 channels -- that's why you are seeing all six. It's just that the SMT only supports 2 of the six and populates the first two values (4 bytes) in the data array.

To be clear, you are wrong in saying that you use the first 4 values in the array -- you use the first 4 Bytes for the two channels, which are the first two values in the array. Each value in your array is made of 2 Bytes. You received a total of 12 Bytes in a P2 packet for the data. Since a Byte is 8 bits, you combine 2 Bytes to make a 16-bit number, which 10 of the bits are actually used.

Also, a channel is made of a positive and negative electrode. Think about voltages -- a voltage is relative to some reference (grnd or -). So a channel is the voltage drop between the positive and negative electrodes and is represented by a single value (the voltage). So the first 2 values are:

[voltage(ch1+, ch1-), voltage(ch2+, ch2-), ...<garbage>...]

Where voltage(x,y) is the voltage drop between the two electrodes.


Hopefully this helps.

asc

Thanks for the clear and detailed answer, that was awesome BMcFrizzle!

Really appreciate.

Best,
asc