motion sensor

Status
Not open for further replies.

hillerup

Member
motion sensor sample frequency

Hello,
Im using the Teensy 3.6 with the teensy Prop Shield With Motion Sensors (link: https://www.pjrc.com/store/prop_shield.html)

maybe i just can't find it, but it doesn't seem like the sample rate is stated for the teensy Prop Shield With Motion Sensors.
So I'm trying to find it on my own, however I'm not sure I'm doing it correctly. Right now I'm measuring the cycles it take to imu.readMotionSensor,
but from what i understand this would just be the cycles it take for the teensy 3.6 to execute the function and not necessarily the sampling rate of the Prop Shield With Motion Sensors
(I'm trying to find it in Hz)

Does anyone know what the sample frequency is for the Prop Shield or have a good idea how to determine it?


Code:
#include <NXPMotionSense.h>
#include <MadgwickAHRS.h>
#include <Wire.h>
#include <EEPROM.h>

NXPMotionSense imu;
Madgwick filter;

volatile int cycles;

float ax, ay, az;
float gx, gy, gz;
float mx, my, mz;

void setup() {
  Serial.begin(9600);
  imu.begin();
  filter.begin(100);
  while (!Serial);
  delay(100);
  ARM_DEMCR |= ARM_DEMCR_TRCENA;
  ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
}

void loop() {
  uint32_t startCycleCPU;
  startCycleCPU = ARM_DWT_CYCCNT;

  if (imu.available()) {
    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);
    cycles = (ARM_DWT_CYCCNT - startCycleCPU) - 1;
    Serial.print("cycles: ");
    Serial.println(cycles);
  }
}
 
Last edited:
I have a Prop Shield hooked to a Teensy 3.2, and it appear that imu.available() returns true about once every 10ms.
So the sample rate in that context is about 100hz.
(I think if you read faster than that you just get repeated values.)
 
Status
Not open for further replies.
Back
Top