bird-sanctuary / bluejay

:bird: Digital ESC firmware for controlling brushless motors in multirotors
GNU General Public License v3.0
314 stars 36 forks source link

Dynamic pwm #67

Closed damosvil closed 1 year ago

damosvil commented 1 year ago

This pr uses a 4th pwm setting value DYNAMIC besides, 24, 48, and 96 to implement dynamic pwm frequency. Thresholds are configurable, but the default ones are:

stylesuxx commented 1 year ago

This is pretty awesome! I think we should rename this to "dynamic" instead of variable - what do you think?

We have variable PWM that can be set to either a fixed value (24, 48, 96) or dynamic.

What I am also wondering is: How did you arrive at those thresholds? You think it would make sense to allow the user to set those themselves? I am particularly thinking about people here who use throttle limits in their FC firmware. This would mean, that they might never go above 60% throttle and thus not benefit from the dynamics at all...

damosvil commented 1 year ago

@stylesuxx I have thinking on these thresholds based on my experience, but I would also like the idea of allow the user to decide. Should I add then 2 more settings, at the end of the existing ones?

stylesuxx commented 1 year ago

I think it would make sense to give the users a way to tinker with it a bit - maybe we decide later on, that there is a perfect value, but for starting out, let's add two more settings.

We should also consider the side effects though - can we properly safeguard it? I don't want to run issues that might be dangerous because the user set some "stupid" value...

damosvil commented 1 year ago

I think that we could allow them to choose between [20-60] for the 96/48 low throttle threshold (Thres1) and [30-90] for the 48/24 high throttle threshold (Thres2), always constraining them to Thres1 + 10% <= Thres2, or something like that, allowing them to choose in steps of 5 or 10%. What do you think?

howels commented 1 year ago

With AM32 the concept of linking PWM to RPM instead of throttle was introduced, and seems to be preferred as a means of dynamic PWM. Should this be considered here?

stylesuxx commented 1 year ago

AM32 has more means to set eRPM into perspective (and actually get RPM) - kv, pole count and such - Bluejay does not have this - at least not yet - I am not entirely sure if it would make sense to couple this to eRPM. But it is definitive something worth investigating.

Right now this is purely a POC with unclear outcome. We have also discussed more discrete scaling, not just in steps. But the steps and throttle values would be a first step to play around with things and see if it's worth the effort.

DISCLAIMER: should you attempt to test this, please only do so with a current limited (200mA) power supply for now.

damosvil commented 1 year ago

https://www.youtube.com/shorts/EarcES4U93U

damosvil commented 1 year ago

I made more flights abusing pretty hard my Meteor 65 and extracted several logs. There were no problems and no smoke. Please, use this blackbox viewer branch if you want to inspect the logs (there you can find a compiled version): https://github.com/betaflight/blackbox-log-viewer/pull/625

DYNAMIC_PWM_BTFL_BLACKBOX_LOG_Meteor65_20230216_190311.zip

damosvil commented 1 year ago

More testing on a 5 inch kwad. Betaflightf4 target with 4 individual LANRC 32A 3-6S ESCs: BTFL_BLACKBOX_LOG_Galaga_20230220_00.zip

github-actions[bot] commented 1 year ago

Build artifacts:

damosvil commented 1 year ago

Tests flawed because of flashing with old esc-configurator tool so no dynamic pwm has been tested. This pr has been superseeded by https://github.com/bird-sanctuary/bluejay/pull/73. Cancelled