Jump to content
I2Cdevlib Forums

DMP polling (no interrupt/FIFO)


Recommended Posts

I'm designing a quadcopter at school and we are using an Arduino Mega, it has 6 INT pins, 2 share the I2C pins, and the other 4 are being used for RPM detection, we are implementing a PI controller for each motor as well as a roll/pitch PID controller for correction estimations. 

 

I'm currently reading raw values for gyro and accel when I want to (polling) and fusing them together using the complimentary filter to describe the YPR attitude. Unfortunately, my fusion is not as accurate as I had hoped it to be. 

 

Is there a quick and easy way to poll the DMP? I'm thinking that it is possible to poll without an interrupt with data available/ready in the FIFO.

 

I have looked at the dmpGetQuaterian and dmpGetYPR methods but not sure if its as simple as that.

 

I would poll the MPU every loop (its okay if it still has the last value as long as there is a value) and I will be executing a PID loop on an interval of about 100 Hz.

 

Thanks in advance for any help provided!

Link to comment
Share on other sites

YES, try to use DMP, check the example DMP sketch and adapt it to your project.

 

I believe you can work without the interruptions, but you will need to read the fifo buffer at least at the same frecuency (I recommend higher) that the DMP is working.

You can change DMP's frecuency to your needs. If you read at lower frecuency it will overflow and start giving errors.

 

Just mopdify the example sketch and erase the interruption part, put a delay to get the frecuency you want (just to try) and check that it works.

If using DMP you will also need to calibrate your MPU.

Link to comment
Share on other sites

Limon, I can't exactly answer your PI equation, that part of the project is my group members' responsibility. 

 

Our instructor has told us to use a PI controller for each motor independently.   

 

If you look at a lot of the open source quadcopter projects, they implement a PID for roll/pitch/yaw and these correction values get put into a motor control loop.  The idea that our instructor wants us to implement is take the new motor values, as inputs to a motor PI loop using an RPM detection algorithm that we came up with. 

 

Basically the following is comprised of PID for r p and y. Our goal is to add a PI at the end of the set of equations below to improve reaction time of the motors. 

 

  motorCommand[FRONT_LEFT]  = throttle - motorAxisCommandPitch + motorAxisCommandRoll - (YAW_DIRECTION * motorAxisCommandYaw);
  motorCommand[FRONT_RIGHT] = throttle - motorAxisCommandPitch - motorAxisCommandRoll + (YAW_DIRECTION * motorAxisCommandYaw);
  motorCommand[REAR_RIGHT]  = throttle + motorAxisCommandPitch - motorAxisCommandRoll - (YAW_DIRECTION * motorAxisCommandYaw);
  motorCommand[REAR_LEFT]   = throttle + motorAxisCommandPitch + motorAxisCommandRoll + (YAW_DIRECTION * motorAxisCommandYaw);
 
This code was adapted from aeroquad code.
Link to comment
Share on other sites

 

Limon, I can't exactly answer your PI equation, that part of the project is my group members' responsibility. 

 

Our instructor has told us to use a PI controller for each motor independently.   

 

If you look at a lot of the open source quadcopter projects, they implement a PID for roll/pitch/yaw and these correction values get put into a motor control loop.  The idea that our instructor wants us to implement is take the new motor values, as inputs to a motor PI loop using an RPM detection algorithm that we came up with. 

 

Basically the following is comprised of PID for r p and y. Our goal is to add a PI at the end of the set of equations below to improve reaction time of the motors. 

 

  motorCommand[FRONT_LEFT]  = throttle - motorAxisCommandPitch + motorAxisCommandRoll - (YAW_DIRECTION * motorAxisCommandYaw);
  motorCommand[FRONT_RIGHT] = throttle - motorAxisCommandPitch - motorAxisCommandRoll + (YAW_DIRECTION * motorAxisCommandYaw);
  motorCommand[REAR_RIGHT]  = throttle + motorAxisCommandPitch - motorAxisCommandRoll - (YAW_DIRECTION * motorAxisCommandYaw);
  motorCommand[REAR_LEFT]   = throttle + motorAxisCommandPitch + motorAxisCommandRoll + (YAW_DIRECTION * motorAxisCommandYaw);
 
This code was adapted from aeroquad code.

 

 

Thank you for your answer!

 

The equations you wrote here are clear for me. And how are you going to use PI controller at the end?

Am I right? :

for example you have calculated the new value for front left motor. His new rate shoul be 1500 (motorCommand[FRONT_LEFT]). Now he has rate of 1400 (oldRate[FRONT_LEFT]).

After this you are going to use PI controller instead of the direct setting motor rate:

 

motorCommand[FRONT_LEFT] = .........; //1500

front_left_motor.setRate(motorCommand[FRONT_LEFT]); //was

front_left_motor.setRate( pi_controller.update(motorCommand[FRONT_LEFT] - oldValue[FRONT_LEFT], deltaTime)  );

 

Something like that? If no, please explain to me, it is vefy interesting :-)

Link to comment
Share on other sites

  • 2 years later...

I'm designing a quadcopter and my current task is getting values of yaw,pitch and roll. I am using ESP8266 with Mpu6050. I want to read values from FIFO using interrupt pin i written code for it but after uploading without connecting to interrupt pin i'm getting yaw ,pitch and raw values. So from which i getting these values and are these values are correct.

 

i uploaded the file so check it and Thanks in advance.

 

new_imufile.txt

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...