You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi - what you've got there looks pretty good to me. The magnetometer has a DC offset on it, so you need to account for that with min/max which is what you're doing.

    Are you sure that when you upload this you're turning the Puck 360 degrees around (and maybe rolling at different angles as well) first? That allows min/max to be calibrated and will give you much more accurate readings.

    You'd hope that when you do this, vmax.sub(vmin) will have roughly the same values in each axis (which would be the earth's magnetic field strength), and if you measure c.mag() that should stay about the same size no matter where you hold the Puck too.

    edit: just to add the Puck would also need to be held perpendicular to the magnetic field when using Math.atan2(c.x,c.y) - if it's off-axis then some of the field ends up in c.z which will make the values for angle seem very nonlinear

About

Avatar for Gordon @Gordon started