Go Down

Topic: Massive sensor noise/problems? (Read 2 times) previous topic - next topic

kriista

Aha!

So my accel/gyro are 10bit and the magnetometer is 16bit? I'm guessing the onboard Arduino ADC is the 10bit and the i2c is 16bit input?

So how do I get that data into Max if not using Serial.write?

kriista

Looking through an older version of my code I noticed I was using this:

Code: [Select]
  Serial.write(highByte(z));
  Serial.write(lowByte(z));


Instead of just using Serial.print

Should I be doing that? (splitting each sensor into two bytes)
Or maybe using Serial.println and sending it as ASCII?

I think I started using bytes when I wanted to get the message sent as small as possible (for minimal latency).

corb

That's exactly what you should do.  On the other end you'll need to recombine those two bytes into an int.  you should be able to find easilly find some sample code that does the lowbyte/write and then on the read recombines.

kriista

Perfect.

Now just need to figure out how to fuse the bytes together in Max.

Does it matter what order I send the bytes in?

Code: [Select]
  Serial.write(highByte(z));
  Serial.write(lowByte(z));


or

Code: [Select]
  Serial.write(lowByte(z));
  Serial.write(highByte(z));

kriista

Finally got it working. For people searching for the similar problem in the future, here is the Max code that merges the bytes.

Code: [Select]
----------begin_max5_patcher----------
828.3oc6XstSaCCE92sOEQQZ+Yqqy2iyDBo8bflPtMFvrboJwkwFh284KMsz
aotrR.jnRMwI1Ge9Ne9bN1m7vvAwSptW1DG88nKhFL3ggCF3dk8ECV77f3Bw
8SyEMtgEWLOWqZxUYx53Q99mIzSuQUd8k0xoZ+bQ.iAihvb2MHD6twGCh9Yq
LRwulVkWU6GOXLIkCvoi1YK3SDbpnLSYtH4sRBPIDJzMdRBf5jjBfoL3djjr
Tm3TDjYGOyLb.21BXlBNecImIpEERsr9RYoXRtzJOXQekyKTk4RsicfapJZq
pnbBFRrJfuBtXHNAutpppUxRsPqpJ2PKUy0spA0plpRclPK1opSZUMOwpaqB
QNMZaAITPJeO7CtURTpkFcPEBSXTaqDyLfXa.ZGzz+YlzKYb7Hy+kc2H0FNx
3EsbEacwUYNOqpI29UDIdSzvZkJAa+4VivTTpiLS3bDltG6.0JYq0ZrHi+DB
YagoLNqk7sB93vg1KiBLN3p7JyhxgCAnta9qHv+iS0UlU6F0ecCDhF2sqwVK
IF7Jz10kIhxqi2I2iiehlJMfy00OpUh73mACUJ+sYZamSs7dGwD+sHFkhoiO
L0g7TGYKpaM5AcLzCra5YmzBrWnkubP9.4ylx4iou77gpbOrA3zxFSqJJLI7
1hNxq5fOfXOg.89IftcPNp3Gv1lLj2Ol7MpNLYVuZwI8hK+YmEwOrWOcQdz9
HKv975gzSLgLuXRmmeB5WngouQ18vRLcs2Aum4Gx6K5g0KwSexDrvBvoxSdj
W0HJTuvHmed.YXfj2BYXNs7QfmN8czgSOwNLGSYrnOph8ipXOlpXwuWJhcOo
M+bnkn4qHgRecqPiDVpAmnw4pxM+fWNyy990Yplp40Sa0daAxQqrwLYiVUtz
I+hUeAimLnaTYYx0BBxTM1nOG7A6bMKX7.CAO39COfPvCr2vCOD3XwLrWfis
HhvvS+POr.fyFX9E06AE.d5ufKRHryaJzfN.ZJTYypLm+bQ1ORp86HAgL+ga
V8zJ0b5b8C.9r9ySK.zv6MzDzlJnmIb764IlM6NYcyh4zgDy4.t0erU1H2ip
R+itYLtVdmpc7zg1Y6wg+CvmzqdZ
-----------end_max5_patcher-----------


I also ended up with a weird problem in my parsing code (in Max) that meant the bytes were not coming in the correct order (which breaks everything). Once that was sorted everything came in nice and smooth. So satisfying to see that steady stream just rolling on in.

Go Up