1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00
Commit graph

127 commits

Author SHA1 Message Date
Kenneth Mitchell
82d1736890
Call initEscEndPoints after auto changing profiles.
Reset escEndPoints with OSD.

Fix include order.
2019-04-27 18:32:25 -04:00
Dominic Clifton
78f38daa4f Drastically reduce the CMS RAM usage.
Previously the runtime page state was mixed with the page configuration.

This resolves this by:
a) making the configuration entries constant so they do not need to be
in RAM.
b) Maintaining page state independently.
2019-02-17 00:18:24 +01:00
Bruce Luckcuck
a64bd06f5a D_MIN cleanup - use array for parameters; move CMS menu entries
Change to using an array of `uint8_t` for the `d_min_` axis parameters. Simplifies the code.

The CMS menu entries were incorrectly placed under the `FILTER PP` submenu. Moved to the `MISC PP` submenu.
2019-02-09 15:40:27 -05:00
ctzsnooze
b70d34f9db Update D_CUT to D_MIN, add setpoint
Directly and easily set the minimum value for D on pitch and roll.
- Boost back to the primary D setting is generated from gyro or setpoint inputs.
- Setpoint input is stick derived, faster by 10ms approx, and does not respond to propwash.
- Gyro input is motor derived and slower, but responds to propwash
- timing value sets balance between gyro (100) and setpoint (0) boost factors
- gain value sets overall sensitivity
- default D mins are 20 roll 22 pitch
- default D is 35, 38; if undefined then normal 30, 32 values
TUNING
- D value to flip overshoot control
- D_min to noise, lower values mean cooler motors but perhaps more propwash.
- Advance, higher values bring the boost in earlier, and stronger overall, useful for very high flip rates, but dampen stick responsiveness slightly.
- Gain value adjust against logs, checking maximal boost with flips and some rise with propwash, should be edging to get up from the min value in normal flight.
2019-02-10 01:44:55 +11:00
mikeller
299d96fdc7 Added battery cell count based automatic PID profile switching. 2019-02-04 13:15:43 +13:00
Bruce Luckcuck
9d7af42e9f Add CMS entry for motor_output_limit
Will assist tuning while at the field. Added under PROFILE -> MISC PP.
2019-02-04 10:55:24 +13:00
ctzsnooze
7e3e5649e1 DTERM_CUT
This code cuts D by a specified percentage durning normal flight.

It lets D smoothly rise up to normal during rapid gyro moves like flips and rolls, and increase during prop wash events.

D should now be tuned to values the 'normal' 30-45 range.

If D is 40, a dterm_cut_percentage of 65 will cut D to 14 in normal flight, but the quad will still get full 40 of D to control bounce-back after flips and about 25 of D during strong prop wash.

The dterm_cut_percentage can be adjusted via the OSD, from the D filtering page.
Adding d_cut results in cooler motors, lower amounts of noise in motor traces and faster reactions to quick stick inputs.

Too high a dterm_cut_percentage may bring out P oscillation from lack of D.  Values of 70% are generally OK.

Input is gyro differential (delta).  Frequencies above 40hz (above propwash) are attenuated with a configurable (dterm_cut_range_hz) biquad filter.  Lower values for range can be used if the quad is very noisy or gets low frequency D resonant oscillation.  Up to 50 or 60hz may suit clean quads where prop wash control is the main priority.  Too high a range value results in D being boosted from noise in normal flight.

The boost signal is 'integrated, smoothed and delayed' with a 7hz PT1 'dterm_cut_lowpass_hz' filter.  The default of 7Hz gives about the right amount of smoothing and delay.  Higher numbers cause the boost to come on faster, with less delay. Lower values delay the boost effect and cause it to last longer.

The dterm_cut_gain amount controls the strength of the boost effect by amplifying the input to the boosting effect.  If the quad is flow gently, a higher gain value may be needed to gain full boost.

Logging with set debug_mode = D_CUT allows recording of realtime D values on roll and pitch into debug 2 and 3.  The reatime D value should reach its set maximum during rapid turns, ideally at about the time D itself peaks.  If it fails to reach the maximum, gain should be increased.

The D_Cut feature is not enabled on LUXV2RACE, OMNIBUS, SPRACINGF3NEO because there isn't enough flash space.
2019-01-12 21:09:03 -07:00
Kenneth Mitchell
257a09d693
Add dyn filter options to OSD.
Fix FLIP32F3OSD target.

Fix trailing whitespace.
2019-01-02 18:33:26 -05:00
Bruce Luckcuck
ab0e1260be Launch Control: increase throttle trigger percent max to 90
Per user request. Apparently the previous max of 50% wasn't providing agressive enough launches for some users.
2018-12-08 11:25:28 -05:00
Bruce Luckcuck
9830681158 Add throttle limit settings to CMS
There have been a number of requests for this as it seems to be common for racers to tune these values and adjust the settings as they become more comfortable with a track. Previously the settings could only be adjusted in the CLI and required a computer. Adding them to the CMS makes it easy to adjust in the field.
2018-11-23 09:25:00 -05:00
mikeller
570a0f7882 Changed RC rate minimum to be 0.01. 2018-11-05 23:27:42 +13:00
Bruce Luckcuck
b723d2976d Changes from review and add unit tests
Stylistic updates and add tests to the PID unit tests to verify launch control behavior
2018-10-30 18:14:49 -04:00
Bruce Luckcuck
e4dc93b128 Launch Control
Adds a race start assistance system that allows the pilot to pitch forward and then release the sticks with the quad holding position for the race start.
2018-10-27 11:50:37 -04:00
Miguel Angel Mulero Martinez
db133032a6 Fix CMS Throtle Boost 2018-08-01 16:00:32 +02:00
Miguel Angel Mulero Martinez
e0d17a5e2f Hide LPF2 and Throttle Boost from CMS if not available 2018-07-31 10:15:25 +02:00
Miguel Angel Mulero Martinez
df4b893d61 Add Throttle Boost to CMS 2018-07-31 09:18:06 +02:00
Miguel Angel Mulero Martinez
9d77c05d1f Add DTerm LPF2 to the CMS menu 2018-07-24 15:51:01 +02:00
Bruce Luckcuck
17e76e48f6 PID controller feedforward
Restructures the PID controller to decouple feedforward from D.

Cleaned up the structure of the PID controller; moved some feature-based enhancements out of the main structure.

Feedforward becomes a separate component of the PID controller and there is now:
f_pitch
f_roll
f_yaw

The default values of 60 for pitch and roll matches the default setpoint weight used in BF3.4.  Yaw previously had no setpoint weight capability so the default here needs to be discussed.  Currently it's also set to 60 and flight testing seems positive.  Feedforward on yaw adds a lot of value so I don't think we want to default to 0.  Instead we need decide on the default.

All occurences of setpoint weight have been replaced by feedforward. "setpoint_relax_ratio" has been renamed to "feedforward_transition".

The pidSum now consists of P + I + D + F.

D has been added back for yaw (disabled by default with d_yaw = 0). We've found little need for D for normal quads but it may have value for other configurations - particularly tricopters.

Updated CMS menus to support adjusting the feedforward for each axis.

Changed the default for "rc_interp_ch" to be "RPYT".  Need yaw to be smoothed to support feedforward.

Open issues:

Needs BFC support
- Need to add support for the axis "F" gains.
- Remove "setpoint weight" slider.
- Rename "D Setpoint transition" to "Feedforward transition"

Needs BBE support
- Header "setpoint_relaxation_ratio" has been renamed "feedforward_transition"
- Header "dterm_setpoint_weight" has been replaced with an array named "feed_forward_weight".
  example: H feed_forward_weight:65,60,60    (R,P,Y)
- PID component "AXISF" has been added for all axes. Should be handled like P, I and D values.
- PidSum calculation needs to include F.

Needs LUA script support
- Support the renamed "setpoint_relax_ratio".
- Support for feedforward weight on all 3 axes.

Open code issues:
- rc_adjustments.c - support for adjusting feedforward weight for all axes. Currently only supporting roll - needs coordination with BFC.
2018-07-21 10:26:23 -04:00
jflyper
1126159243 Change CMS menu page title for PROFILE from IMU to PROFILE 2018-07-04 11:04:44 +09:00
supiiik
cc12dddedb Indentations repaired 2018-05-23 15:55:07 +02:00
supiiik
8a1c5e5e74 small fixes, MIN for 8bit MSP 2018-05-23 14:36:23 +02:00
supiiik
4312513a77 MSP changed
Changed MSP, all new data are at the end
2018-05-23 13:33:43 +02:00
supiiik
76e3e7aded dterm_setpoint_weight to uint16_t
dterm_setpoint_weight changet to uint16 with limit 0-2000
2018-05-23 08:39:45 +02:00
blckmn
a9f74cd6df Removed excess trailing spaces before new lines on licenses. 2018-04-25 20:58:00 +10:00
blckmn
46fe22b4bd Direct license replacement 2018-04-22 09:22:46 +10:00
Míguel Ángel Mulero Martínez
efef50ced1 Increment AG GAIN step in CMS (#5568) 2018-03-30 16:54:55 +13:00
joelucid
98a77dcd96 Discontinuity fix (#5509)
* use continuous feed-forward

* use continuous feed-forward

* formatting
2018-03-23 14:13:32 +13:00
Dan Nixon
bc283cf5b9 Refine extended CMS menu toggles (#3601) 2018-03-22 00:07:53 +13:00
AJ Christensen
46291a8374 Dual-stage Gyro Filtering: PT1, Biquad, Butterworth, Denoise (FIR), FKF (fixed K), and Biquad RC+FIR2 (#5391)
* Dual-stage Gyro Filtering: PT1, FKF, and Biquad RC+FIR2

* Builds on the previous work of apocolipse.
* Fixes 'stage2'/'stage1' mis-naming to reflect where it is applied in the loop.
  That is, the older Biquad, PT1, Denoise (FIR) filters are 'stage2' - applied
  after dynamic and static notches (if enabled), and the controversial PT1,
  'fast Kalman' filter, and Biquad RC+FIR2 filters, are 'stage1'. e.g. before
  dynamic notch.
* FKF bruteforce Kalman gain removed. Calculate from half of PT1 RC constant,
  automatically taking loop-time into account.
* New union type definition for stage1 filtering.
* New gyro sensor members for stage1 filter application function and states for
  all three supported filter types
* New enum types for stage1 v. stage2. dterm lowpass type references 'stage2'.
* updates to CMS/MSP/FC to allow compilation (untested, probably breaks
  MSP, Lua, and ~comms with BFC~).
* Refactors FKF initialization, update and associated structures to be faster by
  not continuously calculating 'k'. Filter gain is calculated once during
  initialization from RC constant as per PT1 and Biquad RC+FIR2. It was
  discovered this converges to static value within 100 samples at 32kHz, so can
  be removed. Remove related interface (CLI) settings.
* update dterm_lowpass_type to use new 'TABLE_LOWPASS2_TYPE' (biquad/pt1/FIR)
* Stage 1 defaults to PT1, 763Hz (equivalent to Q400 / R88 from quasi-kalman
  filter) - suitable for 32kHz sampling modes. Can be switched to Biquad
  RC+FIR2, and FKF.
* Update `#if defined(USE_GYRO_SLEW_LIMITER) to `#ifdef`.
* Includes optional Lagged Moving Average 'smoothing' pipeline step, applied (in
  code) after the output of stage1.
* (diehertz): Removed redundant pointers from gyro filtering

* blackbox: fix indentation

* cms IMU menu: fix indentation

* filters: remove USE_GYRO_FIR_FILTER_DENOISE in filter type enum

* gyro sensors: go back to `if defined()` form. for slew limiter

* gyro sensors: increment parameter group version

* due to non-appending changes, the version must be bumped.
2018-03-21 15:52:59 +13:00
ctzsnooze
ab231b7c84 Second dterm pt1 (#5458)
* Second PT1 on DTerm

This PR replaces the default biquad filter with a second PT1 set to
200Hz.

Basically allows the user to enable a second, set point configurable,
PT1 type first order low-pass filter on DTerm.

This is useful because most noise in most logs arises from D, not P.

The default is set to on, at twice the normal Dterm setpoint.  This
provides greater Dterm cut than a single PT1, and twice the steepness
of cut above the second setpoint.  Modelling shows significant
reductions in higher frequency Dterm noise with only minor additional
delay.

The improvement in noise performance will be less than for biquad, but
the delay is considerably less.

If with the default settings the overall noise improves a lot, it may
be possible bring D both filtering set points to higher numbers (e.g.
140/280), or alternatively remove other filters such as the notch
filters, while maintaining an adequate level of control over noise.

* Update names, old defaults, fix whitespace

Defaults restored to biquad with second PT1 off.  ‘lpf’ retained as
abbreviation for values, otherwise generally remove ‘Filter’ where
redundant, replace ‘FilterLpf’ with ‘Lowpass’, etc, thanks Fujin and
DieHertz

* Remove underscore in lowpass_2, add hz to setpoint for lowpass

Thanks DieHertz

* completed replacing lpf with lowpass, added _hz to all lowpass set points in profile

Thanks DieHertz

* fix whitespace

fixed whitespace in settings.c

* whitespace attempt #57

* change lpf to lowpass where appropriate elsewhere

Note did not change OSD abbreviations, they are still LPF, and did not
change gyro_lpf anywhere.

* second attempt at a simple PT1 implementation

Basically copied from the DtermNotch implementation

* Second PT1 on DTerm

This PR replaces the default biquad filter with a second PT1 set to
200Hz.

Basically allows the user to enable a second, set point configurable,
PT1 type first order low-pass filter on DTerm.

This is useful because most noise in most logs arises from D, not P.

The default is set to on, at twice the normal Dterm setpoint.  This
provides greater Dterm cut than a single PT1, and twice the steepness
of cut above the second setpoint.  Modelling shows significant
reductions in higher frequency Dterm noise with only minor additional
delay.

The improvement in noise performance will be less than for biquad, but
the delay is considerably less.

If with the default settings the overall noise improves a lot, it may
be possible bring D both filtering set points to higher numbers (e.g.
140/280), or alternatively remove other filters such as the notch
filters, while maintaining an adequate level of control over noise.

* Rebase

* Remove underscore in lowpass_2, add hz to setpoint for lowpass

Thanks DieHertz

* completed replacing lpf with lowpass, added _hz to all lowpass set points in profile

Thanks DieHertz

* fix whitespace

fixed whitespace in settings.c

* whitespace attempt #57

* change lpf to lowpass where appropriate elsewhere

Note did not change OSD abbreviations, they are still LPF, and did not
change gyro_lpf anywhere.

* second attempt at a simple PT1 implementation

Basically copied from the DtermNotch implementation

* Whitespace fix - thanks, Ledvinap

* Fix PG issue

by moving added dterm_lowpass2_hz to bottom of struct

* Got rid of redundant indirection

* Fixed indentantion shifts
2018-03-21 01:40:23 +13:00
mikeller
ee65eba88d Added selectable RaceFlight rates. 2018-01-19 00:38:14 +13:00
mikeller
018c24fec2 Fixed range for setpoint_relax_ratio to avoid division by zero. 2018-01-14 12:12:54 +13:00
Martin Budden
3747d6742b Whitespace tidy 2018-01-10 16:56:54 +00:00
mikeller
b489d0ba9d Renamed 'parameter_group' to 'pg'. 2017-12-19 23:36:31 +13:00
Michael Keller
364afcbf25
Merge pull request #4521 from martinbudden/bf_cms_onglobalexit
Remove almost entirely unused CMS ononGlobalExit function
2017-11-10 10:35:13 +13:00
Martin Budden
243e8390a2 Removed CMS menu guards when not debugging 2017-11-09 19:09:17 +00:00
Martin Budden
9a9884e4af Remove almost entirely unused CMS ononGlobalExit function 2017-11-09 19:06:25 +00:00
mikeller
a8d34dabb0 Changed defines for GYRO/ACC/MAG/BARO/GPS/SONAR/OSD/BLACKBOX/CMS to conform to the USE_ convention. 2017-11-05 10:15:24 +13:00
Martin Budden
74c8fefd63 Merge pull request #4252 from McGiverGim/bf-add_antigravity_cms
Add antigravity config to the CMS
2017-10-09 13:04:55 +01:00
Dan Nixon
f087730035 Add throttle mid and expo to CMS 2017-10-06 18:15:13 +01:00
Miguel Angel Mulero Martinez
05fb653a8e Add antigravity config to the CMS
Added the antigravity gain and threshold to the CMS menu.
2017-09-28 17:44:56 +02:00
Martin Budden
c1a99817f4 Minor tidy of PID code 2017-09-09 07:03:15 +01:00
Bas Delfos
ec4ce2bbd6 Changed condition to USE_COPY_PROFILE_CMS_MENU 2017-08-30 21:28:49 +02:00
Bas Delfos
04d08cb033 Made CMS code conditional 2017-07-29 22:26:53 +02:00
Bas Delfos
d32abc69f8 Copy profile to another profile (CLI, MSP and CMS) 2017-07-29 22:10:14 +02:00
Dan Nixon
334dbc3039 Ensure PID/rate profile is updated before editing values 2017-07-14 14:44:16 +01:00
Martin Budden
23f158913e Moved time functions out of system.h into time.h 2017-05-26 14:03:28 +01:00
Martin Budden
71546410de Rearrange PID array to be array of PIDs 2017-05-06 11:06:47 +01:00
Hydra
2b1dac4c6d CF/BF - First cut of allow building of the OSD SLAVE board without all
the flight controller code.

Likely the dependencies can be further improved.  This is a
minimal-impact solution while there are a lot of other Betaflight PR's
still pending.
2017-04-12 00:39:27 +01:00
Martin Budden
1964362dce Removal of USE_PARAMETER_GROUPS 1 2017-03-09 22:03:59 +00:00