Open williamesp2015 opened 3 years ago
What's the printout from Serial.println(HZ__);
?
I select 1-8 to change setRate but it is not sensitive for raw data.
I'm asking because from your example it's not clear if you ever call NoDMPsetup()
@williamesp2015
The sequence of the MPU6050 startup is as follows deviation from this will likely cause difficulties (learned from experience)
int devAddr= [your devices address];
// reset device:
mpu.writeBit(devAddr, 0x6B, 7, 1);
delay(100);
mpu.writeBits(devAddr, 0x6A, 2, 3, 0b111);
delay(100);
// Load Settings
mpu.writeBytes(devAddr, 0x6B, 1, 0x00); //Power Management 1 -- Set to 0b00000000 Internal 8MHz oscillator
mpu.writeBytes(devAddr, 0x6C, 1, 0x00); //Power Management 2 -- Low power mode wakeup stuff (all off)
mpu.writeBytes(devAddr, 0x1A, 1, 0x03); //Configuration -- external Frame Synchronization (off) and DLPF setting accel Bandwidth 44Hz delay 4.9ms gyro Bandwidth 42Hz delay 4.8ms Fs 1kHz
//This sets the gyroscope frequency to 1kHz
//If you set this value to ZERO 0x00 the gyroscope Frequency will be 8kHz
mpu.writeBytes(devAddr, 0x1B, 1, 0x18); //Gyroscope Configuration -- set to 0b000 11 000 = 3 ± 2000 °/s
mpu.writeBytes(devAddr, 0x1C, 1, 0x00); //Accelerometer Configuration -- set to 0b000 00 000 = 00 ± 2g
mpu.writeBytes(devAddr, 0x23, 1, 0x00); //FIFO Enable (Off)
mpu.writeBytes(devAddr, 0x38, 1, 0x00); //Interrupt Enable (Off)
mpu.writeBytes(devAddr, 0x6A, 1, 0x04); //User Control -- FIFO Reset
mpu.writeBytes(devAddr, 0x19, 1, 0x04); //Sample Rate Divider -- for use with DMP I have set it to 4 = 200Hz as this is what it requires.
// 0x19 Sample Rate Divider Detailed Description:
//This register specifies the divider from the gyroscope output rate used to generate the Sample Rate for the MPU-6050.
//The sensor register output, FIFO output, and DMP sampling are all based on the Sample Rate.
//The Sample Rate is generated by dividing the gyroscope output rate by SMPLRT_DIV:
//Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)
//Gyroscope Output Rate = 8kHz when the DLPF is disabled (DLPF_CFG = 0 or 7), and 1kHz when the DLPF is enabled (see Register 26 aka 0x1A ).
//Note: The accelerometer output rate is 1kHz. This means that for a Sample Rate greater than 1kHz, the same accelerometer //sample may be output to the FIFO, DMP, and sensor registers more than once.
// start looking at the raw data now no DMP or FIFO has been started
So for your question, The sensor register output, FIFO output, and DMP sampling are all based on the Sample Rate.
Z
@williamesp2015 Does this answer your question? did you come up with any improvements to this library from your work? we would like to know what you've discovered.
Z
I'm using raw data example in the loop. I first initialize the mpu6050 by NoDMPsetup() without DMP initilizing but always sampling rate is 100 hz. mpu.setRate is not functioning void loop() { while (!mpu.getIntDataReadyStatus()) { delayMicroseconds(100); } mpu.getMotion6(&aaReal.x, &aaReal.y, &aaReal.z, &gy.x, &gy.y, &gy.z); Serial.print(millis()); } void NoDMPsetup(uint8t acc, uint8t gyr,uint8_t DHP,uint8_t DLP__,uint8_t HZ) { mpu.setClockSource(MPU6050_CLOCK_PLL_XGYRO);
}