Puck.js v2 Accelerometer/Gyroscope output...

Posted on
  • Hi Everybody,

    I've just recently begun working with the Puck.js v2 board. I updated the firmware to "espruino_2v07" immediately after powering it up. I'm starting a project hoping to count revolutions on a rotating spindle with the Puck's onboard LSM6DS3TR-C. Two questions:

    1) Is counting revolutions this way even possible (versus using a more traditional optical encoder or magnetic sensor approach)?

    2) When I manually execute "Puck.accel();" in the command line repeatedly (without moving the sensor at all), I get a huge range of output. Why is "Puck.accel();" returning such a variation in values?

    Sometimes I'll just get a dead response and have to cycle the power to fix:

    >Puck.accel()
    ={
      acc: { x: -16056, y: -5125, z: -151 },
      gyro: { x: 0, y: 0, z: 0 }
     }
    >Puck.accel()
    ={
      acc: { x: -16056, y: -5125, z: -151 },
      gyro: { x: 0, y: 0, z: 0 }
     }
    >Puck.accel()
    ={
      acc: { x: -16056, y: -5125, z: -151 },
      gyro: { x: 0, y: 0, z: 0 }
     }
    

    And sometimes the gyro output seems totally random (without physically moving the Puck at all):

    >Puck.accel()
    ={
      acc: { x: -8001, y: 2134, z: 107 },
      gyro: { x: 200, y: -9329, z: -14452 }
     }
    >Puck.accel()
    ={
      acc: { x: -7988, y: 2153, z: 101 },
      gyro: { x: -949, y: -5207, z: -12287 }
     }
    >Puck.accel()
    ={
      acc: { x: -7973, y: 2136, z: 115 },
      gyro: { x: -1532, y: -5256, z: -12355 }
     }
    >Puck.accel()
    ={
      acc: { x: -8023, y: 2158, z: 123 },
      gyro: { x: -4909, y: -13612, z: -11337 }
     }
    

    Thanks!

  • Sun 2020.10.04

    'output seems totally random'

    There is a note concerning the mag, presumably the gyro also:

    http://www.espruino.com/Puck.js#magnetom­eter

    Has E.getBattery() been used to determine the amount of battery charge remaining?


    http://www.espruino.com/Puck.js#accelero­meter-gyro

    Are the same flutuations observed when using the low power module?

    source:    http://www.espruino.com/modules/puckjsv2­-accel-movement.js

  • Thanks for the tip regarding the battery charge. However, E.getBattery() returns a value of 100. I actually have the Puck wired to two new 1.5v AAA batteries.

    Unfortunately, using the puckjsv2-accel-movement.js module also returns the same unpredictable results.

  • 1) Is counting revolutions this way even possible (versus using a more traditional optical encoder or magnetic sensor approach)?

    Yes, however I'd say only if what you're attaching the Puck to is moving slowly. Since you're unlikely to be able to get the accelerometer at the centre of rotation, at higher speeds the centrifugal force could cause issues.

    2) When I manually execute "Puck.accel();" in the command line repeatedly (without moving the sensor at all), I get a huge range of output. Why is "Puck.accel();" returning such a variation in values?

    You mean for the gyro? The accelerometer itself looks pretty good.

    In the gyro case I think it's an issue with the accelerometer - basically because Espruino turns the accelerometer on, then takes the first reading, then turns it off, the gyro doesn't get time to 'settle' before a reading is made.

    I bet if you run Puck.accelOn() first (to leave the accelerometer on), and then use Puck.accel() you'll get much better readings. What I'd suggest is you just respond as soon as you get accelerometer data (rather than polling):

    Puck.on('accel', function(d) {
     // ...
    });
    Puck.accelOn(12.5);
    

    The other thing you could try for counting revolutions is the magnetometer. For instance you could stick a magnet on whatever is rotating and then have the Puck next to it. You could use the XYZ values from the magnetometer to get a pretty good idea of absolute position.

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

Puck.js v2 Accelerometer/Gyroscope output...

Posted by Avatar for BrianH @BrianH

Actions