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):
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.
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.
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.
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 usePuck.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):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.