Puck.js v2 Accelerometer/Gyroscope (LSM6DS3TR-C)

Posted on
  • Hello everyone,
    I'm trying to work with the accelerometer/gyroscope in the puck.js v2.

    I wrote a small script to transmitt accelerometer data over bluetooth as follows:

    var running = false;
    
    function accelHandlerTrigger(data) {
      console.log(data);
      var d = [
        "A",
        Math.round(data.acc.x),
        Math.round(data.acc.y),
        Math.round(data.acc.z)
      ];
      Bluetooth.println(d.join(","));
    }
    
    setWatch(function() {
      if (running) {
        Puck.accelOff();
        Puck.removeListener('accel', accelHandlerTrigger);
        running = false;
      } else {
        running = true;
        Puck.accelOn(52);
        Puck.on('accel', accelHandlerTrigger);
      }
    }, BTN, {repeat:true});
    

    However, the sensor measurements that I get seems to be too high. For example:

    "acc": { "x": -342, "y": 398, "z": 8270 }, 
    "gyro": { "x": 313, "y": -299, "z": -92 }
    
    "acc": { "x": -319, "y": 371, "z": 8098 }, 
    "gyro": { "x": 167, "y": -290, "z": -69 }
    

    From my understanding, the accelerometer default is ±2g and the gyroscope default is ±125 dps.

    Is this correct? or why are the values too high?

  • Hi,

    The values reported there are actually the raw values off the chip. Honestly, they should really have been scaled already, but now the Puck.js v2 is out there it's going to hard to change it without it being really confusing.

    • accelerometer: full-scale (32768) is 4g, so you need to divide by 8192 to get correctly scaled values
    • gyro: full-scale (32768) is 245 dps, so you need to divide by 134 to get correctly scaled values
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Puck.js v2 Accelerometer/Gyroscope (LSM6DS3TR-C)

Posted by Avatar for user116256 @user116256

Actions