1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00
Commit graph

738 commits

Author SHA1 Message Date
mikeller
2feae20c32 Replaced instances of '#include <platform.h>' with '#include "platform.h"'. 2018-05-24 23:46:19 +12:00
Michael Keller
71a1a9789a
Merge pull request #5945 from supiiik/master
New calculation method for Dterm setpoint weight
2018-05-24 21:16:55 +12:00
Andrey Mironov
d8dd6f29f8 Set FAST_RAM to go into .fastram_data by default. Added FAST_RAM_NOINIT 2018-05-23 14:40:33 +03: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
supiiik
6c15904a77
Update pid.c 2018-05-22 20:01:25 +02:00
supiiik
e4846f2ecc
New calculation for DTERM setpoint weight
I'm flying race with betaflight and on all my race quads I have setpoint on maximum value 2.54. But I feel, that it's not enough. This calculation of setpoint is almost same as old method up to number 2.0 (previously 2.54) but numbers above 2.0 have more aggresive impact on Dterm RC stick commands. With this calculation i found, that value 2.3 is fine for me. 2.3 is equivalent to 6,35 with old calculation method (which was not possible of course, because there is 8bit limit). With higher values have quad much sharper responses and feel more "locked in". 
I think, that most freestyle pilots have setpoint at values around 1, so there is almost no change and race pilots using higher values and for those, who are limited by the value 2.54 (like me and my friends) should be solution new setpoint calculation method.
This is my first pull request to betaflight, so I hope, that I did everything well according your rules
2018-05-22 19:59:47 +02:00
s0up
ac6b8088c9 add gps rescue mode 2018-05-20 16:28:17 -07:00
s0up
de5fa47c4c navigation feature / reference removal 2018-05-09 10:28:36 -07:00
Mark Hale
b2e43abf2d Display anti-gravity activity in OSD.
Signed-off-by: Mark Hale <mark.hale@physics.org>
2018-05-05 19:56:56 +01:00
blckmn
a9f74cd6df Removed excess trailing spaces before new lines on licenses. 2018-04-25 20:58:00 +10:00
Bruce Luckcuck
0a0add8c56 Yaw spin recovery optimize (#3)
* PID controller unittest

* Clean code for yaw spin recovery

* Yaw spin recovery optimizations

* Flash size optimizations, use 50% throttle when airmode is off, and override pidsum_limit_yaw

Also rebasing from betaflight/master
2018-04-24 14:02:36 +12:00
ctzsnooze
41fb37a264 Clean code for yaw spin recovery 2018-04-24 13:51:06 +12:00
borisbstyle
8fab0fee11 PID controller unittest 2018-04-22 16:10:17 +02:00
blckmn
46fe22b4bd Direct license replacement 2018-04-22 09:22:46 +10:00
Andrey Mironov
f18448e8dc
Added FAST_RAM_INITIALIZED (#5733)
* Added FAST_RAM_INITIALIZED for those who really want it

* Added the white crow of KISSFCV2F7

* Made initialized data LMAs robust

* Fixed indirection when initializing fast memory
2018-04-21 16:04:07 +03:00
Michael Keller
8e152f3259 Added explanation as to why fixed dT is used in PID calculation. (#5737) 2018-04-21 11:21:35 +03:00
Miroslav Drbal [ApoC]
4968352446 Fixing the #5705 (D-Term spikes) (#5728)
* * Fixing the #5705 (D-Term spikes)
  - For D-Term calculation I reverted back to use dT instead of jittery deltaT
  - Moved calculation of deltaT to handleItermRotation because it is the only place now where it is used

* * Changed the constant expression per DieHertz request

* * Changed the type of argument to match the type from caller

* * Redone also the handleItermRotation to dT per @ledvinap request
2018-04-21 12:09:13 +12:00
Andrey Mironov
f24941feb7
Constrained D-term transition upper-bound (#5701) 2018-04-16 16:45:25 +03:00
Miroslav Drbal [ApoC]
045557561d Optimized the PID loop a little bit (#5661)
* * Put PID variables into the structure
* Precalculate DTerm gyro filter outside the axis loop
* Removed unused variables PIDweight[3], airmodeWasActivated
* If zero throttle or gyro overflow, we can just set values and exit, this saves checks and jumps in axis loop
* Compute PIDSUM after the axis loop, this saves branching inside the loop because of Yaw has no D term

* * Incorporated review changes from DieHertz and fujin

* * Incorporated another review requests from DieHertz
  - PidSum renamed to Sum
  - pidData[3] redone to pidData[XYZ_AXIS_COUNT]
2018-04-11 08:22:51 +12:00
borisbstyle
3663230803 Cleanup PID controller function (#5631) 2018-04-06 20:23:57 +12:00
Bruce Luckcuck
7bc600d651 Throttle limit feature (#5608)
Adds new throttle_limit_type and throttle_limit_percent parameters that allow the pilot to limit the maximum commanded throttle seen by the flight controller by either scaling or clipping the maximum throttle.  The default is 100 representing no limiting.  So as an example, if a pilot was to set throttle_limit_type = SCALE and throttle_limit_percent = 80 the throttle input would scale from 0 to 80% based on full stick deflection from the radio.

This capability replaces the method of limiting throttle in the radio which some pilots are using to manage throttle on tight courses or reduce overall battery consumption when the extra power isn't needed.

There is no effect on the maximum throttle seen by the motors so the mixer still has full authority.
2018-04-05 16:01:28 +12:00
joelucid
ee8daac41d ITerm rotation (#5469)
* ITerm rotation

* address requested changes

* now counting up

* scale errors according to Ki while rotating

* iterm_rotation profile setting

* revert to non scaled version, style related fixes

* Triggering a CI build.
2018-03-26 10:50:21 +13:00
joelucid
efda704ee5 Throttle boost (#5508)
* throttle boost which temporarily boosts throttle in both directions to improve response

* fix comment and use pt1FilterGain

* incorporate review suggestions

* incorporate review suggestions

* use float constant to avoid double promotion

* formatting changes

* formatting change

* hopefully last style changes
2018-03-25 11:33:22 +13:00
joelucid
98a77dcd96 Discontinuity fix (#5509)
* use continuous feed-forward

* use continuous feed-forward

* formatting
2018-03-23 14:13:32 +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
Petr Ledvina
141d6ec30a Higher-order gyro filter (#5257)
* Implement nth order Butterworth

Uses biquad sections

* Purge RC+FIR2

* Add butterworth LPS as gyro filter

Replaces RC+FIR

* Make FKF code conditional

* Add USE_FIR_FILTER_DENOISE

Denoise is almost useless anyway ...
2018-03-15 01:45:20 +13:00
Bruce Luckcuck
449f5f2f5c Runaway Takeoff remove unneeded parameters and enhance deactivate logic
Removed parameters runaway_takeoff_threshold (hardcode to 60) and runaway_takeoff_activate_delay (hardcode to 75).  The previous default values worked well and required no tuning.

Enhance the deactivate logic to remove the R/P/Y stick activity condition once throttle reaches 2X runaway_takeoff_deactivate_throttle_percent.  Additionally reduce the runaway_takeoff_deactivate_delay by 50% when throttle exceeds 75%.
2018-02-27 19:22:33 -05:00
Michael Keller
a2ba0af426
Merge pull request #5066 from jirif/pid_optimize
Optimize pid loop
2018-02-02 00:49:38 +13:00
Bruce Luckcuck
a32b05c284 Initial implementation of Runaway Takeoff Prevention (anti-taz)
Detects runaway pidSum values on takeoff and auto-disarms to prevent the "Tasmanian Devil" caused by incorrect props, wrong motor order/direction, incorrect flight controller orientation, etc.  After a successful takeoff and normal flight is detected the feature is disabled for the remainder of the battery.
2018-01-31 07:36:16 -05:00
Bruce Luckcuck
fba0b2cea3 Optimze pidSum calculation by storing the value rather than recalculating in multiple places.
Saves 72 bytes. Will save at least that additionally when incorporated into Runaway Takeoff Prevention (which also calculates the pidSum in two places).

Additionally adds a slight performance improvement by not repeating the floating point additions to calculate the pidSum in multiple places.  Effectively replaces 2 calculations with 1 (4 with 1 with Runaway Takeoff Prevention).
2018-01-30 09:58:41 -05:00
jirif
b612df0c53 Optimize pid loop 2018-01-30 11:23:03 +01:00
Martin Budden
3747d6742b Whitespace tidy 2018-01-10 16:56:54 +00:00
Steffen Windoffer
c549b91b5e remove const from reset_conf( since it allready is defined in the marko 2017-12-21 20:09:38 +01:00
mikeller
b489d0ba9d Renamed 'parameter_group' to 'pg'. 2017-12-19 23:36:31 +13:00
Michael Keller
b94533ead1
Merge pull request #4767 from martinbudden/bfa_enable_instruction_tcm
Enabled Instruction TCM
2017-12-19 01:36:32 +13:00
Martin Budden
b26ff88fd9 Added gyro overflow checking and handling. Helps avoid YSTTM 2017-12-18 05:21:02 +00:00
Martin Budden
de5b0d53ff Enabled Instruction TCM 2017-12-17 13:41:51 +00:00
Martin Budden
a33a82725e Add fast RAM support, CCM or TCM depending on processor 2017-12-16 17:42:35 +00:00
Martin Budden
12640972a9 Preparation for using instruction cache on F7 2017-12-15 10:07:19 +00:00
Martin Budden
9060ecb302 Reset ITerm on motor reversal 2017-12-01 07:06:20 +00:00
Martin Budden
e7d2e84348
Merge pull request #4616 from martinbudden/bfa_pid_deltat_us
Scaled PID deltaT calculations from us to seconds
2017-11-19 04:58:59 +00:00
Martin Budden
34b48badb9 Scaled PID deltaT calculations from us to seconds 2017-11-19 04:24:40 +00:00
Martin Budden
cfc87d1891 Better separation between GPS and NAV 2017-11-18 08:00:31 +00:00
Martin Budden
9c9f02f550 Use constant dT for ITerm calcualtion to avoid windup caused by jitter 2017-11-17 06:11:53 +00:00
Martin Budden
56ed140e33 Updated to use currentTimeUs, which is time of gyro sampling 2017-11-12 12:49:12 +00:00
Martin Budden
0491eae52e Update PID calculations to use actual deltaT 2017-11-12 09:40:50 +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
mikeller
46624d28ca Added switching off of beeper in all cases when crash recovery is disabled. 2017-10-21 09:12:46 +13:00