Decoding Cyton data format with Matlab code

edited May 2017 in Cyton
Hi all,

I am trying decoding the 8-channel data format in a matlab function. I have implemented the following code (once I've opened the serial port), but I am getting no-sense value (looking at the acquisitions using the OBCI GUI):

*****************************************************
data = fread(s,33,'uint8');

if data(1) == 160            
            n=1;
            for i=3:3:24    %%3 bytes per canale [3,4,5], ..., [24,25,26]
                byte1=double(typecast(uint8(data(i)),'int8'));
                byte2=double(typecast(uint8(data(i+1)),'uint8'));
                byte3=double(typecast(uint8(data(i+2)),'uint8'));
                ch(n)=byte3*(2^16)+byte2*(2^8)+byte1;
                n=n+1;
            end
end
*****************************************************

Any suggestion is welcome, thanks in advance.
Roberto

Comments

Sign In or Register to comment.