Jump to content
I2Cdevlib Forums

Arduino, DMP example with delay(6) at loop hangs


Recommended Posts

Hello!

 

I am kindly asking for help with my small question:

 

I am writing some algorithm, which must work one time in one loop iteration. It takes him ~ 5-7 msec to proceed every loop().

I noticed, that my program hangs sometimes. Very rarely: ~ after 10 - 30 minutes of working.

 

Than I went to DMP example, added delay(6) at the end of a loop.... And the same result: sometimes it hangs (after 10 - 30 minutes of working).

 

I added Serial.println in the loop, where the program waits for interrupt, because it is the only one loop. Like this:

    while (!mpuInterrupt && fifoCount < packetSize) {
      Serial.println("Waiting...");
    }

And there is no "Waiting..." messages, when it hangs.

 

Here is a full code of "my" MPU DMP example. It is the same as standart exampe, except two of three lines. I also added the loop period counting and printed it with YPR data.

 

Also I tried it with two different MPU-6050...

 

Sory for my English :-)

Link to comment
Share on other sites

Hi to all again!

 

It semms I fixed this "bug". But there is no understanding of the reason:

 

I'v made this changings:

old:

        // read a packet from FIFO
        mpu.getFIFOBytes(fifoBuffer, packetSize);
        
        // track FIFO count here in case there is > 1 packet available
        // (this lets us immediately read more without waiting for an interrupt)
        fifoCount -= packetSize;

new:

    while (fifoCount >= packetSize){
        // read a packet from FIFO
        mpu.getFIFOBytes(fifoBuffer, packetSize);
        
        // track FIFO count here in case there is > 1 packet available
        // (this lets us immediately read more without waiting for an interrupt)
        fifoCount -= packetSize;
    }

now, I never see fifo overflows at all. Program never hangs. But... why it hanged??? I'v spend 5 hours of "debugging" and testing...

Link to comment
Share on other sites

  • 6 months later...

@luisrodenas

Hi!

I was reading serially all the topics, in search for an answer to something I still don't know how to ask. I believe you can help.

I seems to me, from what I read here and elsewhere, that the 6050 with Jeff's library, can be told at what time intervals to issue interrupts for data available. If that is wrong, than perhaps it can be told at what "frequency" to push newly processed data into the fifo, which evntually generates an interrupt. I am rambling, I know, but it seems to me that people coding control systems somehow KNOW the "frequency" with which new data becomes available to plug into their PID equations.

From your response above (DMP working at 100Hz...) I believe you could set me straight on the path to better understanding.

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...