Automatic MOT_THST_EXPO estimation lua script

@dkemxr
thank you!
very interesting that it converged much faster when MOT_OPTIONS=1. You can see the impact of using the resting voltage for the compensation really clearly in the log and it throws off the expo calculation. Ends up with about the same expo, but takes much longer to converge when using resting voltage.

thanks!

Hi Dave - can you forward the logs to me too please?
I’ll use the data to check how there existing motor thrust expo calcs align with reality for the Initial Params calculator.
All I’m probably after is

  • Prop size
  • old MOT_THST_EXPO
  • new MOT_THST_EXPO

and these for reference, just in case…

MOT_PWM_MAX
MOT_PWM_MIN
MOT_SPIN_ARM
MOT_SPIN_MIN
1 Like

thanks @xfacta
I’m building a list in a spreadsheet too:

1 Like

@dkemxr just had a look at your Chimera7 log. It hit the EXPO_LIMIT_MAX of 0.9 very quickly and stayed there.

2023-05-12 10:41:48.289 Expo: starting tune with expo=0.62
2023-05-12 10:41:53.768 Expo: 0.80 accel=(-3.93,3.57) err=1.298
2023-05-12 10:42:01.351 Expo: 0.90 accel=(-3.23,3.22) err=0.774
2023-05-12 10:42:08.027 Expo: 0.90 accel=(-3.03,3.13) err=0.631
2023-05-12 10:42:14.606 Expo: 0.90 accel=(-2.87,3.39) err=0.677
2023-05-12 10:42:21.379 Expo: 0.90 accel=(-3.08,3.23) err=0.703
2023-05-12 10:42:30.689 Expo: 0.90 accel=(-2.77,2.99) err=0.424

so this would imply true expo is over 0.9, which is unexpected and is why I had that limit.
If you’re willing to try it and are ready to quickly revert (or change mode) if it becomes unstable it would be interesting to try with a higher EXPO_LIMIT_MAX (maybe 0.98) and see how it does. Don’t go above 0.99.
If you run again can you please set LOG_BITMASK=65535? It looks like you have some yaw oscillation while doing the expo pulses and I think that may be impacting the result as it will lower the achieved acceleration.
Are the motors canted at all?
Could you try lowering ATC_ACCEL_Y_MAX and the ATC_ANG_YAW_P to try to get rid of the yaw oscillation and see if that helps?
I suspect if we get rid of the yaw oscillation then the expo tune will work a lot better.

OK, will make the changes and re-test tomorrow.

Tentatively tried a test today but conditions were poor (windy/gusty), and my recently crashed and revived copter (11" tri-blade props, 2.9kg AUW) has developed some ugly y-axis vibes for reasons I’ve yet to find.

The firmware and script ran fine, but I have to solve the copter’s issues before proceeding. Results did not converge, almost certainly because of the poor test conditions and vibrations. I have the log if you want it.

I have a smaller Cinewhoop along with a Hexsoon EDU-450 I can try on a calmer day.

@tridge I’ll contribute. Could you make me a build (we are using Cube orange with PMW)

yes please, I’d like to get a better understanding of how windy it can be for the expo script to be useful

sure, you didn’t say if plane or copter so I made both:
http://uav.tridgell.net/ExpoTest/
thanks for testing!

No problem, Tridge! Wind was out of the south at about 8-12 knots and pretty gusty. Before a minor crash, I felt the copter was reasonably well tuned, but it’s a bit unhappy now.
Log file (gusty wind)

EDIT:
As the sun went down, the wind died considerably, so I tested the EDU-450, which is mostly stock but has a nicer 4-in-1 ESC than the provided ones from Hexsoon. This was a much better flight with a better behaved copter!
EDU-450 log file here.

I forgot that the KakuteH7Mini-Nand doesn’t have scripting capabilities, so I won’t be able to test my little 3.5" Cinewhoop. Shame. It’s super overpowered, and I was looking forward to that!

Thank you so much, I will inform you if I need anything more and the results when I get them.

Curiously, with no changes other than favorable wind, my bigger copter performed like its old self again this evening with vibe levels back to acceptable ranges, and I got a successful test.
Log file (calm wind)

Slightly off topic - not sure if you (or anyone) saw my work on scripting a momentum drag estimator, but if my approach is sound, it might be a nice companion to this thrust expo tuner.

1 Like

Thanks @Yuri_Rage !
I notice your 11x3 copter also has the incorrect BW for dynamic harmonic and starts oscillating in roll at low throttle due to the filter causing phase lag. I suspect this is a common problem and we need to update the wiki.
I think you should set:

  • INS_HNTCH_BW=7
  • INS_HNTC2_ENABLE=0

The windy log really shows the problem with tuning expo in gusty conditions. The calm log is much better.
For the Edu450, @rmackay9 also tested that frame. Randy got an expo of 0.62 whereas you got 0.56. I think the difference is you have different MOT_SPIN_MIN and MOT_SPIN_ARM values to @rmackay9 which I know impacts the result significantly.
Can you give me some info on the 11x3 motor and ESC for this spreadsheet?

also, the .bin logs are preferred to .log files. They contain a bit more information and load faster.
Cheers, Tridge

Thanks much for the tuning advice - I was really fiddling with filtering for a while on the 11x3 copter, and it looks like maybe I left the second one enabled after messing with a static notch or something. Good catch! Interesting about the bandwidth param - I thought I had that set well and am very interested in what info you’d suggest for the wiki.

The EDU-450 actually uses an XRotor 40A ESC, which may also have a slight impact(?). If you pass the MOT_SPIN* values that Randy used, I’m happy to test again and compare results.

The 11x3 copter is a ZD550 frame with an iFlight BLITZ 80A ESC, iFlight XING 4214 660kV motors, and Master Airscrew 3x11x10 MR series props.

If I’m posting logs to a public location, I always anonymize them, which results in a .log file. I can share future logs directly with you if the need arises.

Hey @tridge here are two logs, first with MOT_OPTIONS=0 and second with MOT_OPTIONS=1. This is the Y6 I had in canberra, and both flights are off the same battery, which happen to have a fair bit of voltage sag… if that sag complicates the log data, let me know and I’ll go out with a newer battery and re-run the tests.

I’ve pushed some significant changes to the expo lua script today.
The key one is it now samples the acceleration at the zero vertical velocity point.


this means we sample the acceleration when there is no drag from vertical air flow. In the above graph you can see after the down pulse starts the copter is initially travelling upwards and there is a down force from the drag. That gives an artifically inflated acceleration reading. By waiting till the velocity crosses zero we get a more accurate sample.
I did several flights with @MichelleRos today on her 7" quad. The results were interesting as this is a very powerful quad (hover throttle is 0.12). We were surprised to find the expo came out at 0.86, much higher than the previous setting of 0.65. The data does look very clear, but I’m looking forward to discussing with @Leonardthall

1 Like

Assume you want more logs using the revised script?

i will, but hold off for a bit while I work on some other changes. I think the existing logs can be reprocessed to give me the data I need.

2 Likes

No worries. Found the source of inconsistent vibration on the ZD550 (11x3) copter and will need time to replace the ESC anyway. One of the corners of the board took enough of a bump in the aforementioned crash to delaminate it where one of the motor wires connects, causing what’s almost certainly a current spike on one phase. Was very hard to see but pretty easy to literally “sniff out” as the problem worsened.

1 Like

@tridge Hi again tridge. We were wondering, once we have the lua script already on the mission planner, how do we make sure that the script executes itself? or is it automatic once it is already on mission planner?