• Just received my puck and was tinkering around with it and noticed that calls to Puck.mag() show varying responses over time with no movement of the puck. Currently I've updated to 2v14 and the responses I've seen polling at ~1 second apart look similar to:

    {x: -32768, y: -32768, z: -32768}
    {x: -121, y: 749, z: -219}
    {x: -32768, y: -32768, z: -32768}
    {x: -32768, y: -32768, z: -32768}
    {x: -112, y: 752, z: -201}
    {x: -32768, y: -32768, z: -32768}
    

    I've tried checking the forum for anything similar but not seen anything returning such wild jumps. I thought at first maybe I was making calls to fast as I wasnt calling Puck.magOn() but Im not positive.

    Is there something I might be missing ( or maybe im just in a big magnetic field??)
    Thanks!

  • Hi! Sorry about this - that's an odd one. Just to confirm, what does your Puck's PCB say on the rear? Puck.js 2.1a?

    So I imagine right now you're doing something like:

    setInterval(function() {
      print(Puck.mag());
    }, 1000);
    

    But what happens if you do this instead?

    Puck.magOn();
    Puck.on('mag', print);
    

    Or you can literally just add Puck.magOn(); to your code.

    What I think might be happening is the magnetometer is taking a little bit more time to power up than we're giving it - so Puck.mag() (which powers on the magnetometer, takes a reading, and powers it off unless Puck.magOn() had been called beforehand) is getting bad readings sometimes.

    By calling Puck.magOn() you're leaving the magnetometer on, and it may fix this issue for you.

    I've just tested here and while an 'old' batch of Puck.js 2.1a works fine, it seems the most recent batch must be using a slightly different batch of magnetometer (it's the exact same type) which takes a bit longer to start up. I'll make a firmware tweak here and see if I can fix it

  • Ok, just fixed - so if you try the latest cutting edge build it'll work as expected now

  • Thats Ace! Thanks @Gordon! Yes you nailed it , just polling with a set interval as you showed and yes I've got a 2.1a as well. I didnt give a proper test yet by calling Puck.magOn() but i did just try using the cutting edge build and it now seems to be working as expected!

    Ill give shoot with using Puck.magOn() as well as I think that might be better in the long run for me. Would this "slower startup" cause eventually cause issues if you called Puck.mag() too quickly? Im fairly fresh to messing with this so far but didnt know if it would be more power efficient to leave the magnometer on for an extended period or just get single calls over a quick interval.

    Thanks again!

  • Would this "slower startup" cause eventually cause issues if you called Puck.mag() too quickly?

    Not really - it just means slightly higher power usage.

    Im fairly fresh to messing with this so far but didnt know if it would be more power efficient to leave the magnometer on for an extended period or just get single calls over a quick interval.

    It's definitely more power efficient to just leave the magnetometer on and respond to Puck.on('mag' events when they happen - that way the Puck is able to be asleep most of the time and to only respond when it knows there's a new reading.

    You can supply an argument to Puck.magOn() to say how often you'd like to get readings.

    But either way Puck.mag() should have worked reliably regardless of how it was called, so it's good to get that fixed :)

  • Awesome, thanks again!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Mag readings are showing various responses under no change

Posted by Avatar for khicksiv @khicksiv

Actions