Replies: 3 comments 3 replies
-
For understanding Sake :) we will go through the process so I can understand what is happening and what needs to change. we depart from the While loops and get the last packet before leaving. So I ran a test in my loop() I Delayed "delay(77);" for 77 Milliseconds Each packet takes 1.273 milliseconds to retrieve your Serial.println("b6"); takes an additional 0.2 milliseconds to execute this will execute with your print statements in (1.27 + .2 + .4) = 1.8 milliseconds So when you say:
this is where we literally wait for that next packet because our code took longer than 77ms to get to here! an extra 10ms won't hurt anything if we tried to empty the buffer one byte at a time it would take longer than getting the next packet which would take no more than 10ms to arrive.
Conclusion If you would like to see the process in coming up with this routing, see the lengthy thread here: #479 Hope this helps. Z |
Beta Was this translation helpful? Give feedback.
-
Thank you so much Z! So my thoughts around creating a packet and retrieving it and the timings around it is that the inner loop has a time-based robustness control and there is no feedback loop to take care of the robustness of the inner while algorithm. I didn't quite get what code are you referring to that solved your problems. |
Beta Was this translation helpful? Give feedback.
-
Guyz I think I have found a solution here: https://www.youtube.com/watch?v=n5jQXuhLJtU Just add these lines at the end of the 'setup' function, Wire.setWireTimeout(3000, true) ; My code is not frozen till now by using this, tried 10 times by commenting these lines and uncommenting it again....belive me it is not freezing now....Please check and let me know if it works for you as well |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have been trying to figure out why sometimes MPU6050 freezes when I'm using this library. I tracked it down to this part of the code.
The code keeps looping between b6,b7, and b8 and after a while, it keeps looping in b7 and b8. When the inner while loop is called (the case where fifoC < 200)), the process takes too long and the buffer keeps getting filled faster than it is being read. So, it keeps getting stuck in while(fifoC = getFIFOCount()) > length).
Also by not reading the packages and only resetting the buffer, what happens is that the code keeps returning 0. That's because it can get stuck in a state that the buffer fills up so it has to be reset and there won't be any packages, after returning 0 and next time calling this function, the buffer is full again. :)
Beta Was this translation helpful? Give feedback.
All reactions