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

407 commits

Author SHA1 Message Date
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
Thorsten Laux
ba2c1e9264 IDLE updates 2019-08-02 13:51:44 +02:00
Thorsten Laux
d474df3149 idle 2019-08-02 13:51:44 +02:00
jflyper
542146c702 Motor code refactor (Phase 1) 2019-07-17 01:33:39 +09:00
Dominic Clifton
1f2ef98042 Fix compilation when USE_DSHOT and USE_PWM_OUTPUT are not defined.
Fix compilation when USE_DMA and USE_DMA_SPEC are not defined.

Cleanup calling code of `isMotorProtocolDshot`.

Fix 'unused' warning when USE_PWM_OUTPUT is not defined.

Undo isMotoroProtocolDshot change.

Disable USE_SERIAL_4WAY_BLHELI_INTERFACE when USE_PWM_OUTPUT is not
enabled.

Style cleanup.
2019-07-03 08:36:12 +12:00
jflyper
0e63596abd Move motorConfig_s, motorDevConfig_s and associated PG handling into pg/motor.[ch] 2019-06-29 20:03:54 +09:00
jflyper
cf219cd8a6 Add and handle USE_TIMER 2019-05-05 19:42:52 +09:00
jflyper
45b7fa8095 Add and handle USE_PWM_OUTPUT 2019-05-05 18:05:13 +09:00
Thorsten Laux
5a759c56ef avoid dshot telemetry collisions
actually use calculated deadtime

fix whitespace and return value

fix ws

Address review feedback

fix ws
2019-03-26 21:51:25 +13:00
Bruce Luckcuck
81c226e769 Periodically try to activate DSHOT telemetry if enabled but not working
If DSHOT telemetry is enabled but one or more ESC's are not supplying valid telemetry packets, then send the DSHOT command to enable telemetry once a second while disarmed until all ESC's are supplying telemetry.

Addresses the issue of the flight controller booting without the ESC's powered. In this case the initial command at boot to enable bidirectional telemetry will be missed by the ESC since they're not powered. If the battery is subsequently plugged in the ESC's will default to bidirectional telemetry disabled.

This change will detect that ESC's are not supplying telemetry and attempt to preiodically enable them.
2019-03-17 17:45:08 -04:00
mikeller
acf759b82e Fixed detection of brushless / brushed motors. 2019-03-03 13:01:04 +13:00
Thorsten Laux
e16ef1db4f First attempt low throttle airmode oscillation fix
raise dc offset immediately

Add airmode noise fix

no filter when inactive and slightly more throttle

hpf throttle to avoid large moves increasing throttle persistently

fix ws

fix ununsed variable and default to off

include airmode throttle offset in loggingThrottle
2019-02-18 23:48:36 +13:00
mikeller
73d18ede66 Halved motor_output_limit for 3D modes. 2019-01-30 00:05:41 +13:00
mikeller
a3cf7e0cf7 Added motor output limiting per profile. 2019-01-28 00:37:00 +13:00
Michael Keller
06f89603bc
Merge pull request #7463 from etracer65/mixer_throttle_fix
Fix mixer throttle calculation
2019-01-27 11:38:15 +13:00