Cyton 8 channel data format

edited August 2018 in Cyton
Hi All,

After going through:
I was able to control the board over terminal.

When I send "b" which is Start Streaming Data, I got a lot of data.
Unfortunately, I missed the description how to parse the data.

Is there any chance, anybody could give me a hint about the incoming data format?

I would greatly appreciate that.

Comments

  • Hi William,

    Thank you for your reply!

    I have a couple of more questions..
    1. Looks like we should get 250 samples per second, but all the log files have 256 samples per sec.
    Should I normalize the data or it's just a counter and I should take just 250 per sec?

    2. OpenBCI created a file: OBCI_XX.TXT:
    %STOP AT
    0000BD1A
    00,0A36A2,0847ED,F74B95,EDFC0D,EDE65F,F3D175,EF6BD9,F65B33,FFB0,0630,0E40
    ...
    after converting (4.5 / 24/*gain*/ / (2^23 - 1)) I have the following:
    00, 0.0150, 0.0121, -0.1747, -0.1611, -0.1610, ...

    if I convert the txt file using openBCI_GUI:
    *.txt:
    %OpenBCI Raw EEG Data
    %
    %Sample Rate = 250.0 Hz
    %First Column = SampleIndex
    %Last Column = Timestamp 
    %Other Columns = EEG data in microvolts followed by Accel Data (in G) interleaved with Aux Data
    0, 14961.05, 12130.31, -12751.11, -26389.79, -26513.84, -17844.45, -24285.24, -14126.59, -0.010, 0.198, 0.456, 16:03:41.506

    *.csv:
    %OBCI SD Convert - 2018-09-08_18-25-44
    %
    %Sample Rate = 250.0 Hz
    %First Column = SampleIndex
    %Last Column = Timestamp
    %Other Columns = EEG data in microvolts followed by Accel Data (in G) interleaved with Aux Data
    48410.0
    0,14961.05,12130.313,-12751.111,-26389.787,-26513.84,-17844.447,-24285.236,-14126.593,-0.010000001,0.19800001,0.45600003

    Looks like, the order is slightly off, am I doing something wrong here?

     

  • wjcroftwjcroft Mount Shasta, CA
    Sample rate is 250 Hz. But sample clock is not precisely crystal controlled @ 250, so may have plus or minus some samples per second. But rate is constant, with minimal drift.

    I'm not sure what is going on with your conversion. The docs pages have the precise formulas. You can also check the GUI source code.  See lines 1461 to the end.


  • Dear William,

    Thank you for your reply and I thought I resolved this, but looks like I'm lost in weeds...

    I took the interpret24bitAsInt32 function from 
    and created simple sketch:

    public class MainClass {
    int interpret24bitAsInt32(byte[] byteArray) {     
        int newInt = (  
         ((0xFF & byteArray[0]) << 16) |  
         ((0xFF & byteArray[1]) << 8) |   
         (0xFF & byteArray[2])  
        );  
        if ((newInt & 0x00800000) > 0) {  
          newInt |= 0xFF000000;  
        } else {  
          newInt &= 0x00FFFFFF;  
        }  
        return newInt;  
    }  

    public static void main(String[] args) {
    byte[] byteArray = {0x0a,0x36,(byte) 0xa2};
    MainClass m = new MainClass();
    int newInt = m.interpret24bitAsInt32(byteArray);
    System.out.println(String.format("%02X", byteArray[0]) 
    + String.format("%02X", byteArray[1]) 
    + String.format("%02X", byteArray[2])
    + " = " + newInt);
    double scale = 4.5 / 24 / (2^23 - 1);
    double scaled = newInt * scale;
    System.out.println(newInt + " * scale = " + scaled);
    }
    }

    The output is:
    0A36A2 = 669346
    669346 * scale = 6275.11875

    I supposed to get 14961.05(this is what GUI returned), but even so, is this in volts?

    I tried your suggestion and went through the code here:

    is unhex() a library function?

    I'd really appreciate precise formulas, my assumption is its a complimentary 1, but I don't see such conversion anywhere...

    Sorry, if I'm making too many problems

Sign In or Register to comment.