Reply To: BerryIMU and Matlab

Home Forums Forums Technical Support for BerryIMU BerryIMU and Matlab Reply To: BerryIMU and Matlab

#6171
nightpoison
Participant

so that section of my code has changed. as you mentioned before I would be getting 1 byte of information from the high low, then when combined its a 2 byte signed. so what I ended up doing is first the OR operation, then converted into a signed 16 bit , then did the shifting.

acc_combined = bitor(acc_low, acc_high);
acc_combined = int16(acc_combined);
acc_combined = bitshift(acc_combined, 8);

what your saying is I need to do this in one line? I’m not sure if I can do that. I wasn’t able to shift by 8 bits before as matlab defaults to unsigned 8 bit precision. When I shifted by 8 it would just zero out the value. I can’t find any information on casting to signed 16. Ill need to look into that.

It looks like, from this:

gyr_combined = bitor(gyr_low, bitshift(gyr_high, 8));

I’m only shifting the high value by 8 bits, is that correct?

Blip, blop, bloop…