1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00
Commit graph

421 commits

Author SHA1 Message Date
tdogb
1fcb206c46 initial commit 2023-02-10 00:08:12 -05:00
Jan Post
931c982a3b
Refactor RPM Filter (#11765)
* Refactor RPM Filter

* Refactor RPM Filter parameter group
2022-11-12 20:39:21 +11:00
blckmn
8714bd13f4 Fixes for SITL - adding to the standard list of targets 2022-10-21 08:51:21 +11:00
Mathias Rasmussen
34ee2f67c9 Use lrintf to round floats to integers 2022-10-14 02:28:30 +02:00
Mathias Rasmussen
61ded491cd Use std abs() instead of ABS() macro
Changes uses of ABS() macro to <stdlib.h> abs() and <math.h> fabsf()
2022-10-12 19:49:03 +02:00
Mathias Rasmussen
9957ceb275 Fix function brace style 2022-10-12 16:31:55 +02:00
Kevin Plaizier
a2a5f596fb
use constrainf instead of nexted else statement
Co-authored-by: Jan Post <Rm2k-Freak@web.de>
2022-10-06 18:15:42 -06:00
Kevin Plaizier
7ba88137e7 Ensure that airmode off to on always has a smooth transition
Ensure that non legacy mixer types also function as expected.

Also lay the groundwork for an airmode strength setting.

Add const before some values

all mixer types working as expected
2022-10-06 10:46:45 -06:00
Kevin Plaizier
c533990d6a Fix the normal airmode mixer
https://github.com/betaflight/betaflight/issues/11854 Should fix this. Didn't realize that it was actually possible for it to somewhat act wrong.
2022-09-27 01:21:23 -06:00
ctzsnooze
2262dfc60e use Throttle Setpoint, not rcDATA(throttle), for TPA 2022-01-25 18:37:01 +11:00
Mathias Rasmussen
87c259a26e Fix use of floating point math functions 2021-12-21 04:18:59 +01:00
ctzsnooze
7b0b8ee35d Retain dynamic idle settings, reduce dependencies 2021-11-25 15:58:36 +11:00
phobos-
c3f90e567f disabled voltage sag compensation in crash flip mode 2021-01-02 12:55:43 +01:00
borisbstyle
4a916af6a9 Added DYNAMIC mixer 2020-12-08 12:04:18 +01:00
borisbstyle
75da17a00e New linear mixer (credits to @tylercorleone) 2020-12-08 12:04:07 +01:00
ctzsnooze
8050ecd1e7 Mixer update: dynamic idle and throttle logging improvements
- all CLI parameters related to dynamic idle alone re-named with the `dyn_idle_` prefix
- when linear throttle scaling is active, the user's set idle value is now correct whether dynamic idle is on or off. Previously, the idle value fell when dynamic idle was activated at the same time as linear throttle scaling.
- enabling dynamic idle no longer causes a deadband at full throttle
- the setpoint throttle value sent to Blackbox does not include the dynamic idle offset
- the throttle value sent to the antigravity and dynamic lowpass code includes throttle scaling, but no other modifiers, to avoid false elevation of the apparent throttle position from dynamic idle and unnecessary transient changes in their filter cutoffs
- Dynamic Idle now uses a modified PI controller during active rpm control phase
- the D factor provides early detection of rapid falls in rpm, e.g. in hard chops. It is filtered heavily. Inadequate `dyn_idle_d_gain` may lead to a transient drop in rpm immediately after cutting throttle. Default is 50.
- the P factor provides fast control over rpm during the active control phase. Too much `dyn_idle_p_gain` may cause oscillation in that phase. Note enough and a slow drop in rpm will be inadequately corrected. Default is 50. Needs to be higher with heavier larger props.
- An integral element does most of the work.  It prevents enduring offsets from the set rpm. The I gain is high when increasing responding to low rpm, and slow to release.  The slow release makes a huge difference and avoids I oscillation. Not enough `dyn_idle_i_gain` and there may be wobble in rpm during the control phase, or the idle value may rise too slowly; too much may cause wobble. Default is 50. Needs to be higher with heavier larger props.
- The DYN_IDLE debug shows idle P, I and D in debugs 0, 1 and 2. minRps stays in debug 3.
- Interactions between throttle and thrust linear, dynamic idle, throttle scaling and throttle boost have been checked and work as they should.
2020-11-09 09:09:17 +11:00
Michael Keller
6c1cb60784 Added the dynamic idle throttle offset to the blackbox header to fix the motor output display. 2020-10-27 02:01:26 +01:00
mikeller
9e6b65680e Split mixer code into initialisation and runtime to reduce flash space usage. 2020-10-11 23:54:26 +13:00
mikeller
7836bc220c Fixed motorOutputLimitLow in blackbox and OSD. 2020-08-31 22:00:23 +12:00
Sam Lane
4c99ad743d Rename FAST_RAM to FAST_DATA 2020-08-23 08:49:26 +01:00
mikeller
a5a1c8dd59 Cleaned up handling of 'oldMinRps' in dynamic idle code. 2020-08-17 22:15:06 +12:00
Bruce Luckcuck
2317b5fe8d Disable GPS RESCUE if mixer is fixed-wing type
GPS Rescue flight control logic only knows how to fly multirotors and engaging GPS Rescue on a fixed-wing craft would result in an immediate loss of control and crash. For example, when GPS Rescue is engaged it attempts to yaw to the home direction heading and this won't work on fixed wing (particularly the flying wing mixer with no rudder). Next it tries to attain the target altitude exclusively with throttle control - not how altitude is controlled with a fix-wing aircraft.

Also the GPS Rescue no-fix arming prevention logic shouldn't be applied.
2020-07-27 18:49:34 -04:00
Michael Keller
41fa8754bc
Merge pull request #9633 from mikeller/remove_vbat_pid_compensation
Remove vbat pid compensation
2020-07-06 13:41:27 +12:00
mikeller
5b58c300b6 Removed unused 'io/motors.h' header file. 2020-06-29 18:49:06 +12:00
mikeller
b6689edc26 Removed VBat PID compensation. 2020-06-22 01:12:47 +12:00
Bruce Luckcuck
5b3fd2d08f Disable dynmaic idle if RPM filter is not enabled
The addition of previous checks of bidirectional DSHOT being enabled were not sufficient. Additionally RPM filter must also be active (harmonics > 0) for dynamic idle to determine the minimum motor RPM and function correctly.
2020-04-22 20:36:54 -04:00
Bruce Luckcuck
52d0764d17 Fix dynamic idle safety issues
Fixes a problem with dynamic idle not checking for bidirectional DSHOT being enabled. So the code would run but have no RPM data available leading to elevated motor idle.

Fixes a problem with dynamic idle not resetting accumulated static variables that continue to be used when dynamic idle is switched off via a PID profile change. Depending on the state of the variables this could cause excessive motor idle speed. In some cases enough to cause the quad to spontaneously take off on arming or be unable to descend in flight.

Fixes a problem with dynamic idle inappropriately modifying the static `motorOutputLow` that is set based on the chosen motor protocol. Downstream code that relies on this value to determine the acutal motor output range was adversely affected.
2020-04-19 09:12:45 -04:00
Michael Keller
2101326a1d
Merge pull request #9619 from mikeller/add_motor_protocol_disabled
Added 'disabled' motor protocol and made it the default.
2020-04-11 12:41:18 +12:00
mikeller
d1ac12eccd Added 'disabled' motor protocol and made it the default. 2020-04-01 20:33:29 +13:00
Michael Keller
5f8fc1e6f9
Merge pull request #9647 from etracer65/mixer_crashflip_div0
Fix division by zero in mixer crashflip
2020-03-28 14:02:13 +13:00
Bruce Luckcuck
3c1e8cb1c3 Fix division by zero in mixer crashflip 2020-03-26 19:45:07 -04:00
Bruce Luckcuck
ae76defa56 Fix div by 0 risk in mixer vbat sag compensation
Fix division by zero if `batteryConfig()->vbatwarningcellvoltage` was set to 420 (4.2v).
2020-03-26 17:30:55 -04:00
mikeller
afe704bbd9 Fixes from review. 2020-03-26 01:54:42 +13:00
ctzsnooze
d63ba914c6 motor output scale
First draft

Change method to percentage compensation

fast sag filter with fast battery updates

Renaming, moving factors to init where possible

Names changed, display update frequency reverted to 50hz as it was

50Hz ESC Voltage sampling, battery sag lowpass for PID compensation.

increment PG_PID_PROFILE, element added to end of batteryConfig_t

all HZ_TO_INTERVALs set back to 200 to match battery task frequency of 200hz.

Add a flag to control vbat comp

Flag vbat_sag_comp_enabled allows battery compensation to be enabled or
disabled from the CLI. When disabled the battery voltage task is run at
50Hz and the battery compensation code is not run. When enabled the
voltage task is run at 200Hz and the compensation code runs. Constants
for the fast and slow rates are added to tasks.h. The default value for
vbat_sag_compensation is changed to 100 as we no longer need to use it
to disable the feature.

Fixed variable task frequency setting.

Added config validation to disable sag compensation unless ADC is used as the voltage data source.

Added conditionals, fixed naming.

Fixed build.
2020-03-22 17:15:08 +13:00
Bruce Luckcuck
37069ba267 Fix initialization of mixer related pidProfile settings
Previously the variables were only initialized at boot and were not updated when the pidProfile changed.
2020-03-18 10:38:31 -04:00
jflyper
ff16686893 White space tidy 2020-02-17 23:54:57 +13:00
Tdogb
91333f3781 updated default crashflip expo to 35 2020-01-12 17:01:13 -05:00
Tdogb
3243aafdb9 crashflip expo 2019-12-17 12:57:47 -05:00
Tdogb
73a280cc85 initial commit of crashflip motor power percentage control 2019-12-16 17:24:55 -05:00
mikeller
e0a6f1ab14 Improved fixed wing detection. 2019-11-17 14:05:07 +13:00
Bruce Luckcuck
be79913726 Change virtual current meter to use setpoint rather than rcCommand throttle
Use the final calculated throttle value that may be affected by throttle limiting, throttle boost, etc. instead of the rcCommand input when calculating the virtual current meter.
2019-11-08 16:16:16 -05:00
mikeller
4a7904695e Moved 'config.[ch]' into the 'config/' directory. 2019-10-28 11:17:25 +13:00
Thorsten Laux
d6535d9b38 fix idleMinMotorRps scale 2019-08-04 19:01:34 +02:00
Thorsten Laux
5767102889 scale idleThrottleOffset correctly 2019-08-04 14:34:34 +02:00
Thorsten Laux
e66ab2d8fe ifdef static var 2019-08-02 17:30:22 +02:00
Thorsten Laux
d033a8dc76 address code review 2019-08-02 14:20:37 +02:00
Thorsten Laux
293dc42710 address feedback 2019-08-02 13:51:44 +02:00
Thorsten Laux
bca9f8a587 better idle defaults and don't set idle_throttle if not enabled 2019-08-02 13:51:44 +02:00
Thorsten Laux
e39d5e7000 Make dyn_idle a conditional compile 2019-08-02 13:51:44 +02:00
Thorsten Laux
b4c4757470 Conditional idle compile 2019-08-02 13:51:44 +02:00