I am doing a project with two mpu6050 and Arduino Uno,I use Matlab to read the data from Arduino,
but I want to calculate the time of peak-to-peak,how should I know Arduino sample rate?I don't know how fast the Arduino read each data.
Can I use Arduino simultaneously?I know mpu6050 works on the different address.
Help will be appreciated!
The sample rate of a Uno is approximately 10K per second.
However if you want to be more precise use the micros timer.
Grumpy_Mike:
The sample rate of a Uno is approximately 10K per second.
However if you want to be more precise use the micros timer.
Here is my loop code:
void loop() {
// put your main code here, to run repeatedly:
// read raw accel measurements from device
accelIC1.getAcceleration(&ax1, &ay1, &az1);
accelIC2.getAcceleration(&ax2, &ay2, &az2);
#ifdef OUTPUT_BINARY_ACCELGYRO
Serial.write((uint8_t)(ax1); //Serial.write((uint8_t)(ax1 & 0xFF));
Serial.write((uint8_t)(ax2); //Serial.write((uint8_t)(ax2 & 0xFF));
#endif
#ifdef OUTPUT_READABLE_ACCELGYRO
// display tab-separated accel x values
Serial.print("a:\t");
Serial.print(ax1); Serial.print("\t");
Serial.println(ax2);
#endif
delay(33);
}
Can you teach me how to use?
Because I need to collect many data, I hope my time to be more precise
Thanks
Sorry but we need to see all the code not just a bit. You also need to post code correctly here, see the how to use this forum sticky post.
If you are trying to do things as fast as possible why use delay at all?
To time that you need to make a note of the current values of the micros counter. Then do your measurements say a thousand times in a for loop, then the current values in the micros counter minus the value before you started the loop will be the time for 1000 samples.
Do not use delay or print in the measurement loop because that will take time giving you a false reading for your measurements.