Avatar for BrianH

BrianH

Member since Oct 2020 • Last active Jan 2021
  • 1 conversations
  • 8 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    Thanks so much for the insights, @Gordon & @SimonT. Your thorough explanations are most helpful!

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    Ok, after a bunch of messing around I figured out what's been giving me trouble. In the process, I've learned a few things, but now have a bunch more questions... hehehe.

    1) Is it true that the gyro is the more "power hungry" part of the IMU vs the accelerometer?

    2) The puckjsv2-accel-movement module puts the accel/gyro sensor in a low power mode mostly by turning off the gyro, correct? Why does it put CTRL1_XL to 12.5Hz?

    3) Would you be willing to make some more comments about the sleep() and wake() functions in the code?

    function wake() {
      digitalPulse(LED1,1,10); // indicate awake red
      timeStationary = 0;
      advCounter = 0;
      Puck.removeAllListeners('accel');
      Puck.on("accel", onAccel);
      Puck.accelOn(26); // 26Hz
      Puck.accelWr(0x11, Puck.accelRd(0x11)|0b00001100); // scale to 2000dps
    }
    
    function sleep() {
      digitalPulse(LED2,1,10); // indicate sleeping green
      var last = getTime()+2;
      Puck.removeAllListeners('accel');
      Puck.on('accel',function(a) {
        if (getTime()<last) return; // ignore events while accelerometer settles
        require("puckjsv2-accel-movement").off()­;
        wake();
      });
      require("puckjsv2-accel-movement").on();­
    }
    

    4) For instance, in the sleep() function, why run puckjsv2-accel-movement.off(), then wake(), then puckjsv2-accel-movement.on() in that order?

    5) I seem to be seeing some lag in the gyro output immediately after waking from sleep(). Is that to be expected? Does the gyro take a moment to turn on after being shut off with Puck.accelWr(0x11,0);?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    Hi Gordon,

    I've been playing around with the puckrotate code you have added to the Espruino App loader. I really like how you've added the sleep/awake functionality. However, I'm running into a bit of trouble after the Puck wakes (using the "puckjsv2-accel-movement" module) from the first time it has fallen asleep. The scaling that was initially, say 12.5Hz/2000dps, set seems to be erased (or overwritten) and where a single revolution might have outputted 1.00, now outputs as 4 or 5 revolutions.

    This only happens after the Puck is waken from its first sleep, and the only way I can seem to set the device straight again is by power cycling it. This makes me think that the issue is with the accel/gyro chip itself, perhaps? It's almost as if the 12.5Hz data rate gets stuck at 26Hz and can't be changed back by writing to that register again.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    Wow! Thanks, Gordon. Both of those examples seem to be working well. A couple questions:

    1) In both examples, the gyro z-axis data is added to itself, then divided by a constant (64,000 or 128,000). Could you help me understand where you got those numbers from?

    2) The second example uses a.mag and a.ang... I don't see these referenced in the API docs. Is 'mag' using the magnetometer? If so, what for? Where do I find more info about these two properties?

    3) The math in the second example gets over my head. Any insight into that would be great (but don't feel obligated if there is not a simple way to explain it.)

    Thanks again!

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    Thanks Gordon, I was able to get better readings from the IMU after using Puck.accelOn()

    The application I'm working on is a bit unique. I need to count revolutions of a spindle with the Puck mounted inside the spindle itself. I can't use any external reference source like a magnet or light to count the revolutions. The spindle will spin infrequently, and at varying velocities (think of pulling a length of paper from a roll).

    I'm hoping the gyroscope might be a reliable source of data for this application (spinning on the z axis). If I can get the gyro to reliably output scaled values in degrees or revolutions per second, would it just be a matter of dividing the the output by the amount of time that it spun? Or is the math not that simple?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    Hi Gordon,

    If I divide the raw gyroscope values by the numbers you mentioned above, will that give me the scaled output in degrees per second? Or is it radians per second, maybe?

    Also, is there a way to change the full-scale sensitivity setting for the accel or gyro programmatically? The default setting sensitivity setting is too high for my project as I'm working with slightly higher RPMs.

    Thanks!

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    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.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for BrianH

    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!

Actions