Compass Motor Calibration Test Failure

I have been facing some compass interference issues from my battery (Li-ion). I tried every possible way to reduce the interference, so I finally thought to do compass motor calibration.

Before compass calibration, I moved and flipped the propellers so that they would not generate the thrust.

When I armed the drone and slowly increased the throttle, I noticed some strange behavior. Drone went to almost full throttle and tried its best to lift, but how could it happen? Is it because I tried in loiter mode or some other issue?

Here the interference issue is coming from the battery pack. I made the li-ion cells battery pack using nickel strips and as I increase the throttle the current from the strips will increase which leads to magnetic interference with the compass even with the external compass.

I have few queries and will be very happy if anybody helps to resolve them:

  1. How come my motors were running almost full throttle when I gave a very small throttle input during the test?
  2. How can I overcome the compass interference problem? when I am flying the same drone with a lipo battery it is flying absolutely perfectly. But as soon as I insert this li-ion pack, it shows the compass variance error after taking-off.
  3. Can I limit the peak current? because it can harm my li-ion battery and how stable will the drone react once the peak current exceeds?

Here is the flight log link:

Really looking for serious help.


Yes, it is because you used loiter mode. Do not do that. Use the compass motor calibration stuff. Do not throttle with the RC

Yes you can limit the current if you have a calibrated current sensor and activate current limitation on the parameters

1 Like

Forget about using that method, use Magfit for this. Its straight forward using MAVExplorer.
And don’t get hung up on the fact it’s Python. Page down to the MAVExplorer section and then watch Henry’s video. This should be the standard procedure for mag cal and compass motor cal.

1 Like

Thanks Dave for the Information and very sorry for the late update. I was not feeling well for past few weeks.

I have done the Motor Compass Calibration and this is the test flight log after calibration:

After the Calibration, It is flying good in loiter mode but I am seeing lot of vibrations (the drone is shaking too much) I guess I have to reset the harmonic notch filter.

But I just want to know for my understanding why suddenly the drone is shaking? Earlier it was flying good, what could be the reason? Is it because of the electromagnetic interference from the battery?

Battery Info: Earlier I was using the Tattu Li-po battery and drone was flying very good and stable then I changed the battery to Li-ion (which I assembled from the Li-ion 3.7v cells) to get more endurance. As I used Nickel strips to assemble the battery pack, So when the current flows through the Nickel strips it causes the electro magnetic interference. I insulated the battery pack to minimize the interference but I guess interference is inevitable.

Now I have one serious doubt, I did the motor compass calibration on ground with the mauch sensor and I went only to 60% throttle (because my new battery pack can’t withstand the current more than that). Here is the Motor Compass Calibration Log:

But I can’t fly with the mauch sensor as I don’t have the space in the frame and my li-ion battery connector is different which is hard to integrate with the mauch setup. So I removed the mauch sensor and planned for flight.

I got the Compass Inconsistent Error so I recalibrated the compass and did a test flight in hover mode. I found my drone is drifting (about to crash) and shaking. Here are the logs:

Is it because I removed the mauch? does the Motor Compass calibration generates the multiplier to compensate the interference based on the load current? or we can set it to based on throttle? I guess based on throttle does not work because when battery reduces we need to increase the throttle little bit to compensate the power losses (I have experienced it). Just want to hear from the expert.

Really looking forward for your help & support.


Can’t imagine it was flying good. The outputs are oscillating badly.

I would suggest lowering the Rate Pitch/Roll P&I values to ~0.10 or until the oscillation is gone at hover.
Set these and make another hover flight.

Current sensing is required so until you have it on-board don’t bother with Compass motor Compensation. In fact set COMPASS_MOTCT to 0 to disable the saved coefficients as they are not doing any good w/o current measurement.

1 Like

Thank you so much Dave for the reply. I have been going through the docs available for vibration analysis and I have a few queries:

  1. Why the Vibration is not showing in the VIBE graphs?

  1. I plugged in the old battery and updated the parameters as all the old parameters but still I can see the motor output oscillations (As I told you earlier the drone was flying well but since I changed the battery, it started showing vibrations) Can you guess what could be the reason?

  2. Clipping is 0, which means the vibrations that are being detected aren’t overwhelming the IMU. Is that right?

  3. Measuring the vibration through FFT analysis:

Here the peak of vibration is showing around 100Hz, which is the motor rotation frequency and other peaks correspond to its harmonic. ACC3 is the accelerometer data after filtering, what does the after-filtering data mean? I have not set up any low pass & notch filters so what is the filtering mean here?.

  1. Please tell me what you understand with this data and I guess this data will be used to set the low pass filter but if we increase the low filter frequency then it might cause a significant phase log so we need to set up the harmonic notch filter for which I have to set up the INS_LOG_BAT_OPT = 2 to capture post filter gyro data and the motor hover thrust value (In the last flight the motor thrust value has not learned I have to fly again)

Here is the log:

Again thanks for the help! I have to catch up with you guys so I have to learn a lot and I want your guidance and help.

Looking forward to your reply.

Not vibration, output oscillation, totally different things. The fields I graphed are the RC outputs. You don’t have a vibration problem you have a tuning problem. The Rate PID’s I mentioned? It’s pointless to configure the Dynamic Notch Filter until this is gone.

Here again is the RC outputs from this latest log. It looks bad and there is something odd going on with Motor 2.:

But anyway follow the advice about reducing the Rate PID’s. And set the Accel filter to what I suggested also.

1 Like

Thanks for the information, Dave!
Yeah! It must be the problem with Rate PID’s, I will reduce the Pitch & Roll P&I values until it is stable. You are right something is wrong with the motor2.

But why these motors are oscillating on the ground also? I can understand the oscillation of motors as soon as I lift the drone but you can see the oscillation even on the ground itself. Is it normal or is this also affected by the P&I of pitch & roll?

Looking forward to your reply.


What’s the vehicle config?

Hey Dave!
As per your suggestion, I have reduced the rate PID and I have observed the oscillations have reduced significantly but not fully. I have reduced the rates to below 0.1 and How long can I reduce the rates? I have observed some control lagging issues in the drone.
Is it safe to reduce the rates more & below 0.1?
Here is the log:

In the below log, I have reduced the rates to 0.08

Really looking forward to your suggestion and help.


Deal with Motor 2.
OK, it’s improving. Now the D term is too high. I wonder where these PID’s came from? Drop both Pitch and Roll to .004 and make another hover flight in AltHold. Also re-enable these as you are not done with the Notch filter config:

Also, give this a read and set these parameters. In summary you want the minimum Arm throttle required to spin the motors cleanly (no hesitation or cogging) and the MIN value to be slightly above that.:
Setting Motor Range

And set these (based on MOT_THST_HOVER):

1 Like

Hey Dave! Thank you so much for all the help.
I got these PIDs after the auto tune which I performed long back, here is the log of that autotune:

After updating all the parameters taken from the autotuning, my drone was flying well and smoothly.
I just wanted to tell you that during autotuning I have used a different set of propellers which are more efficient than the current propellers but I have flown the same drone with the current propellers so many times after auto-tuning and did not have a single problem like this.
I know changing the propellers will change all the parameters but this oscillation issue came after I tried to change the battery from lipo to li-ion since then the drone became unstable.

I don’t have the old propellers right now with me, I broke them and they are a little expensive so I am using these little cheap propellers for the testing. I want to know your opinion and suggestion on this. I might use them in the future once my drone is a little stable and at that time I will again perform the autotuning.

I have done the changes as per your suggestion and the oscillations are almost gone but the drone is behaving very weirdly to the pilot’s input.

Here is the log:

Here is the log of taking off in AltHold mode:

My observation from the flight:

  1. Oscillations are gone but drone responding is very weak to the control as we have reduced the gains drastically.
  2. It is taking off fast and tilted to one side, not taking off smoothly.

Looking forward to your suggestions and help. Thanks again for all the things, btw I am also going through the documentation and now understand many things but am still a little confused.


Yea I can imagine. I had only suggested the drop the D-term to .004. Looks like you dropped P&I but I don’t know why you chose those values. Set those bacl to .08 and set he D-terms to .004 and try again.

1 Like

Hey Dave! Sorry for the late post. I have found the problem, you guessed it right there was some problem with the Motor 2 ESC. That ESC was slow compared to the other ESC and that is the reason Motor 2 PWM value was very high. Now I have changed it and it is flying well.

But I have something to ask and I need your guidance for that. During Compass MOT calibration I have observed that when I raise the throttle to around 65-70% the interference value is going to 100%.

I don’t want to move the External Compass Up so what can you suggest for that? I have saved the Compass Motor Calibration offsets but still, sometimes Innovation for the compass exceeds the value of 1. So what do you suggest for that? Is it because interference is too much (100%) and offset does not work well or we can still work it out without moving the compass further up?

I have not tried the Magfit offsets, will try that soon. I just want to know whether these offsets will work well even in the presence of 100% interference.

Looking forward to hearing back from you. A lot learned, still learning and there is too much to learn.


I think you will have to move the compass. But try Magfit anyway as that’s what you will want to use going forward for both compass offsets and motor compensation.

1 Like

Thanks for the reply, Dave! I will try the Magfit offsets. Actually, the interference is coming from my lithium-ion battery pack which I made and I have seen people flying with the same kind of battery pack flying the drone without putting the compass at much height, I wonder how they do it.

Do you have any Idea of shielding a compass or something like that? Can you suggest any other way instead of moving the compass? I want to try every single possible way before moving the compass up.

If anyone reading this post has faced a similar kind of problem in past then please tell me whether you have found any good way to limit the interference or not.

Looking forward to your response


Hey Dave!
I hope you are doing great. I have resolved the compass motor interference problem, but the internal compass is having so much interference that it is impossible to overcome.

I am happy to tell you that I have built a small drone for learning and doing all the testing because it is small and easy to fly.
I have completed the initial setup and almost ready for the autotune but I want your suggestion on this. I have tried to set the throttle based harmonic notch filter but as you can see in the below image that nothing much changed in the gyro amplitude post-processing data.

Here is the log file of the test:

I have selected the first peak in the above graph to set the notch filter, do I have to select the highest peak (which is the second peak)?

And I have something to ask, my 4th motor is always running faster while flying in every log as you can see below image. Why it could be like that? is it because of not proper level or something else?

And could you also please check whether everything is properly set up or not? I have followed the full documentation step by step, let me know if I missed something.

Looking forward to your reply. Thanks again for all the help.

That’s because you are looking at the pre-filter data for both Gyro’s. Set these to log both pre and post filter data.
The filter parameters look OK. Check the “magnitude” box before loading a log file for the FFT graph. The log scale graphs you show are not great for this analysis.

1 Like

Hey Dave! Thanks again, Yeah I was checking it wrong. Here is the pre and post-filter data and it looks promising.

Here is the latest log:

Can you please look at the logs and tell me what should I work on to make it more stable and which will help me fine-tune my drone? then I will perform auto-tune on a calm day and hopefully, the drone will be ready.

Thanks again for all the help.

Really looking forward to your reply.

Set these back to default:
ATC_RAT_PIT_I,0.145 (.135)
ATC_RAT_RLL_I,0.145 (.135)
And then these:

Then run Auto Tune

1 Like