sandeepmistry / node-sensortag

Node.js lib for the TI SensorTag
MIT License
218 stars 111 forks source link

Magnetometer cannot be enabled when accelerometer and gyro are enabled #64

Closed zywind closed 8 years ago

zywind commented 8 years ago

Seems this change broke something: https://github.com/sandeepmistry/node-sensortag/commit/a99854261d8961fd9c4243823eb8a21cbc298ef9

When revert the flag to 0x007f, I can enable magnetometer again.

theavijitsarkar commented 8 years ago

I agree

sandeepmistry commented 8 years ago

@zywind @snowbreeze have you looked into fixing?

It feels like a firmware bug to me, and we're battling between fixing the either #62 or this behaviour.

zywind commented 8 years ago

Is node-sensortag using a wrong mask for the accelerometer? The table: Bits Usage 0 Gyroscope z axis enable 1 Gyroscope y axis enable 2 Gyroscope x axis enable 3 Accelerometer z axis enable 4 Accelerometer y axis enable 5 Accelerometer x axis enable 6 Magnetometer enable (all axes) 7 Wake-On-Motion Enable 8:9 Accelerometer range (0=2G, 1=4G, 2=8G, 3=16G) Using the old 0x007f mask worked because it simply puts 1 on all 7 bits. Gyro's mask is 0x0007 which puts 111 on the first three bits. Accelerometer's mask is 0x0238. This doesn't seem right. Should it be 0x0038? Magnetometer's mask is 0x0040, which looks right.

Update: Sorry, I see now that accelerometer's mask is also for setting the accelerometer range. All masks look good then. Hmm. Now I really don't know why.

zywind commented 8 years ago

By the way, when I revert the mask to 0x007f, I still have the 8G accelerometer range. I am not sure why, but this means that if we set the mask to 0x007f, #62 won't be an issue.

sandeepmistry commented 8 years ago

@zywind good to know 8G range is still enabled with mask 0x007f, I am seeing the same here with f/w 1.20 (Jul 28 2015).

Accelerometer's mask is 0x0238. This doesn't seem right. Should it be 0x0038? Magnetometer's mask is 0x0040, which looks right.

The 0x0200 was to enable 8G range, but it doesn't look like it does anything. I would say there's a bug in the firmware or misinformation in the wiki page.

Anyways, I've reverted a99854261d8961fd9c4243823eb8a21cbc298ef9, so the old style is now used (af260cfe9a6d6720e93dc1f0228f513dadefe0e0).