Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disorder Serial.print in Multi-IMU using #34

Open
GUIMINLONG opened this issue May 26, 2023 · 3 comments
Open

Disorder Serial.print in Multi-IMU using #34

GUIMINLONG opened this issue May 26, 2023 · 3 comments

Comments

@GUIMINLONG
Copy link

Hi Homer,
Veyry appreciate for your work in this build this library.

I am new learner in this. When I try the "Simp;e+MPU6050_4_MPUs_Example", signal transmitted to serial port is disoreder as figure below:
image

I want record all data via seral port. Therefore, I want signal from different sensor are delivered Data from in a synchronized or orderly manner like "sensor1,sensor2,sensor3,sensor4; sensor1,sensor2,sensor3,sensor4;.....". I have tried to read all the code to find a way modify the disoreder data flow, but I am not familiar with this coding languages, and can not find a way to dealing with this. Could you please tell me if there are any solution to realize an order serial.print based your library. Thanks

@GUIMINLONG
Copy link
Author

The problem already solved. I realize it by replacing the original "mpu.dmp_read_fifo(0);" with "while (!(mpu.dmp_read_fifo(0))){}"

1685173242220

@ZHomeSlice
Copy link
Owner

Sorry for the delayed post.
The code is designed to capture the packets on a first come basis. or to retrieve the packet as soon as it is available no matter which MPU this could be.
just adjust the code so it calls them in order and waits for the next packet before moving on.
everything will become available within the time period set by:
mpu.Set_DMP_Output_Rate_Hz(5); // Set the DMP output rate from 200Hz to 5 Minutes.
//mpu.Set_DMP_Output_Rate_Seconds(10); // Set the DMP output rate in Seconds
//mpu.Set_DMP_Output_Rate_Minutes(5); // Set the DMP output rate in Minute

Example "in order" code:

void loop() {
digitalWrite(6, !(MPUNumber == 1)); // when MPUNumber == 1 set pin 6 LOW
digitalWrite(7, !(MPUNumber == 2)); // when MPUNumber == 2 set pin 7 LOW
digitalWrite(8, !(MPUNumber == 3)); // when MPUNumber == 3 set pin 8 LOW
digitalWrite(9, !(MPUNumber == 4)); // when MPUNumber == 4 set pin 9 LOW
if(mpu.dmp_read_fifo(0)) MPUNumber++;// When we get the packet from the FIFO buffer for the MPU requested then advance one
if (MPUNumber == 5) MPUNumber = 1; // start over
}

Z

@GUIMINLONG
Copy link
Author

Sorry for the delayed post. The code is designed to capture the packets on a first come basis. or to retrieve the packet as soon as it is available no matter which MPU this could be. just adjust the code so it calls them in order and waits for the next packet before moving on. everything will become available within the time period set by: mpu.Set_DMP_Output_Rate_Hz(5); // Set the DMP output rate from 200Hz to 5 Minutes. //mpu.Set_DMP_Output_Rate_Seconds(10); // Set the DMP output rate in Seconds //mpu.Set_DMP_Output_Rate_Minutes(5); // Set the DMP output rate in Minute

Example "in order" code:

void loop() { digitalWrite(6, !(MPUNumber == 1)); // when MPUNumber == 1 set pin 6 LOW digitalWrite(7, !(MPUNumber == 2)); // when MPUNumber == 2 set pin 7 LOW digitalWrite(8, !(MPUNumber == 3)); // when MPUNumber == 3 set pin 8 LOW digitalWrite(9, !(MPUNumber == 4)); // when MPUNumber == 4 set pin 9 LOW if(mpu.dmp_read_fifo(0)) MPUNumber++;// When we get the packet from the FIFO buffer for the MPU requested then advance one if (MPUNumber == 5) MPUNumber = 1; // start over }

Z

Thanks for update.

Besides, very appreciate for alll your work. The whole library is very helpful for me to get a quick start with MPU imus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants