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);?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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()
andwake()
functions in the code?4) For instance, in the
sleep()
function, why runpuckjsv2-accel-movement.off()
, thenwake()
, thenpuckjsv2-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 withPuck.accelWr(0x11,0);
?