BDF Byte Reading c#

Post Reply
huanzhong
Posts: 2
Joined: Sat Jan 19, 2008 10:43 pm
Location: North Dakota

BDF Byte Reading c#

Post by huanzhong »

Hi, i am trying to read bdf data in my program, i have not being able to convert the 24 bit data (as described in the BDF format) into integer that makes sense. I did read all the header info right. So, i was wondering if there is an example of conversion anywhere. For example, the 3 bytes i read from the 256 hz sample data provided for channel 1, sample 1, is:
40 190 255 which is (LSB) 00101000 10111110 11111111 (MSB), how to convert this to an integer? Since the gain is 31nv/1uV, what voltage does it represent? From some other packages i have, it is around -526.6251uV, correct?

Thanks.

Dan

Coen
Site Admin
Posts: 1124
Joined: Fri Mar 26, 2004 7:00 pm
Location: Amsterdam, Netherlands
Contact:

Post by Coen »

The answers is found in the LabVIEW code of the BDF reader. Add an extra least significant (zero) byte to generate an I32. In your example you will then have 00000000 00101000 10111110 11111111, with a value -8580096. Divide this by 8192 (256*32) to convert to uV. So, the first value is -1047.375 uV. (approx -1 mV)

Best regards, Coen (BioSemi)

huanzhong
Posts: 2
Joined: Sat Jan 19, 2008 10:43 pm
Location: North Dakota

Thanks

Post by huanzhong »

Thanks. That explains it.
One more question: How to convert the status channel data? I see also 3 bytes of data in the sample 256HZ file. 255 0 28 for example, or 254 0 28? What does that translate to?

Thanks

Coen
Site Admin
Posts: 1124
Joined: Fri Mar 26, 2004 7:00 pm
Location: Amsterdam, Netherlands
Contact:

Post by Coen »


egkatsuranis
Posts: 1
Joined: Wed Apr 02, 2008 7:41 pm
Location: UC Davis

Post by egkatsuranis »

Can someone explain in more detail (and perhaps give a general case) how to convert from the integer value to the uV value.

In the previous example, why divide by 8192 or (256*32)? Is the 256 the sample rate and 32 the gain rounded up? If so, why round up? Also, would the duration (assuming it was not one second) effect the calculation?

Thanks!

Coen
Site Admin
Posts: 1124
Joined: Fri Mar 26, 2004 7:00 pm
Location: Amsterdam, Netherlands
Contact:

Post by Coen »

LSB of the 24-bit value is 31.25 nV, or 1/32th uV. For the I32 (extra least significant byte added), division by an additional factor of 256 is necessary.

Best regards, Coen (BioSemi)

marialaura
Posts: 17
Joined: Mon Apr 21, 2008 10:58 pm
Location: Italy

Post by marialaura »

Hi, a question rise from this post.

Status channel data 255 0 28, in binary format
(LSB) 00000000 11111111 00000000 00011100 (MSB) [I32],

if I don't get wrong in the last byte (on the right) I can read that the speed bit 2, CMS and speed bit 3 are high....How can I conclude the speedmode set up in the front panel of Actiview (hardware side)?

Thanks very much!

Coen
Site Admin
Posts: 1124
Joined: Fri Mar 26, 2004 7:00 pm
Location: Amsterdam, Netherlands
Contact:

Post by Coen »

In your example, speedmode (bit 0 ..bit3) would be 0011 which would mean speedmode = 12. Speedmode 12 is not used on any ActiveTwo, so you must be doing something wrong.

Best regards, Coen (BioSemi)

marialaura
Posts: 17
Joined: Mon Apr 21, 2008 10:58 pm
Location: Italy

Post by marialaura »

Thank you very much!
Of course something is wrong I exchange LSB and MSB (not 00011100 but 00111000), but a part from my error you help me!

Best regards,
Maria Laura

Post Reply