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

242 commits

Author SHA1 Message Date
AJ Christensen
4fdee6ec1c Gyro Sensors: Remove 32kHz gyro sampling mode(s) and associated code 2019-02-13 22:41:21 +13:00
mikeller
21edada68b Removed leftover references to 'gyro_align', 'acc_align'. 2019-02-01 01:50:40 +13:00
jflyper
5b40bb4b24 Set acc alignment to that of active gyro 2019-01-29 11:33:01 +09:00
AJ Christensen
5bcf35c7af Extend gyro filter implementation debugging for pitch and yaw axis.
* Introduce CLI parameter gyro_filter_debug_axis which defaults to 'ROLL',
  the previous behavior. When set to either PITCH, or YAW, the debug logging
  implementation in the gyro filtering will use that axis instead.
2019-01-21 22:22:37 +13:00
Kenneth Mitchell
f6e456cd06
Allow dyn lpf to initialize if static lpf config is 0.
Change min > max per review.

Fix missing ifdef.
2019-01-15 16:48:21 -05:00
Thorsten Laux
9ef95bb84d address code review comments 2019-01-08 09:50:26 +01:00
Thorsten Laux
8d4ed72e13 rpm telemetry based notch filter 2019-01-07 13:36:01 +01:00
mikeller
fdd5869054 Update L3GD20 gyro to modern gyro API. 2018-12-19 01:25:39 +13:00
jflyper
a27a374f41 Do call gyroPreInitsensor for gyro 2 even if it is not activated. 2018-12-17 02:07:50 +09:00
jflyper
9ea1428d11 Introduce per device pin pre-init 2018-12-13 11:15:26 +09:00
Kenneth Mitchell
233ac7fb3f
Allow width=0 to select single notch. Restore dyn lpf mins. 2018-12-02 10:01:51 -05:00
Kenneth Mitchell
011eae93c6
Cascaded notch filters. 2018-12-02 09:52:02 -05:00
Bruce Luckcuck
afc1591956 Dual gyro debugging optimize
Bypass the numerous dual-gyro DEBUG_SET statements unless a related debug_mode is set. The dual-gyro debugging is rarely used so in most cases all of the statements can be bypassed. Saves 1-2% CPU load on SPRACINGF7DUAL running in `gyro_to_use = BOTH` and at 32K.
2018-11-08 14:54:16 -05:00
Kenneth Mitchell
ff8d1a842a
Fixes from reviews. 2018-10-25 20:34:55 -04:00
Kenneth Mitchell
ca460e842b
Implement throttle based dynamic gyro and dterm filters. 2018-10-25 19:23:14 -04:00
Bruce Luckcuck
8e0128a2b2 Fix ordering of gyro filtering and overflow/yaw-spin logic
Since the gyro overflow and yaw-spin logic uses filtered gyro data they need to be after the filter application.

Currently the logic is before causing it to operate on one sample old data. This won't prevent the logic from working and it's not a critical fix, but it's better to have the checks after the filtering.
2018-10-01 10:27:48 -04:00
Bruce Luckcuck
6656780205 Dual gyro fixes - fix non-reentrant code in gyro sensor update and fix hardcoded gyroSensor1 logic
Fixes instances of hardcoded gyroSensor1 in the status functions for overflow detection, yaw spin detection, and the sensor temperature reading.

Also fixes non-reentrant code in gyroUpdateSensor() that would not behave properly when gyro_to_use = BOTH
2018-09-28 12:57:30 -04:00
jflyper
fc6c24c38e Configurable acc/gyro 2018-09-10 17:55:52 +09:00
jflyper
58647e678f Remove reset facility 2018-09-06 20:07:09 +09:00
jflyper
9caeceb2dd Resolve upward inclusion 2018-09-06 18:43:58 +09:00
Michael Keller
c12981f732
Merge pull request #6617 from etracer65/gyro_lpf_updates
Disable DLPF EXPERIMENTAL mode for MPU60x0; remove experimental support from F3
2018-08-23 22:25:48 +12:00
Bruce Luckcuck
ec038c7db4 Changes from review - add default clause and update PG version 2018-08-22 17:26:23 -04:00
mikeller
6de1c32d9d Added shadow copies for CLI and MSP. 2018-08-21 00:36:47 +12:00
mikeller
c99629bbf1 Removed calls to (latching) 'feature()'. 2018-08-21 00:35:55 +12:00
mikeller
47e4d3d68d Fixed warning. 2018-08-20 14:32:21 +12:00
ctzsnooze
759007214b remove PT1
warning:
In file included from ./src/main/sensors/gyro.c:1022:0:
./src/main/sensors/gyro_filter_impl.h: In function 'filterGyro':
./src/main/sensors/gyro_filter_impl.h:18:15: warning: variable 'gyroDataForAnalysis' set but not used
2018-08-20 12:15:05 +10:00
ctzsnooze
14c90bf10b user configurable sample rate, true peak detection
1. User can set sampling rate to suit expected range of frequencies:
- HIGH suits 4" or smaller and 6S 5"
- MEDIUM suits classic 5" 4S
- LOW is for 6" or greater
Limits automatically scaled:
HIGH : 133/166 to 1000Hz, MEDIUM : 89/111 to 666Hz, LOW : 67/83 to 500Hz
2. Bandpass entirely eliminated, not needed.
3. True peak detection method, favouring first peak to exceed 80% of maximum bin height; ignore or threshold values not required.
2018-08-20 00:33:11 +10:00
Andrey Mironov
3f001295f7 Simplified FFT location 2018-08-20 00:33:11 +10:00
ctzsnooze
1e960c95eb Dynamic Filter Update
Improves on earlier 3.5RC1 dynamic filter with:
- better FFT tracking performance overall, even with a narrower default notch width
- can reach 850Hz for high kV 2.5-3" and 6S quads
- works better with 32k gyros
- can be applied pre- (location 1) and post- (location 2) static filters. Pre-static filter location works best, but post-static may work well in 32k modes or with PT1 option
- option to use a PT1 filter rather than the classical notch filter, perhaps useful for quads with a lot of noise above their peak.
- ability to totally bypass the pre-FFT bandpass filter, by setting Q=0, maximising the range of responsiveness
- "ignore" value, absolute FFT bin amplitude below which the bin will be excluded from consideration. May be tweaked to optimise peak detection; primarily for advanced tuners. If too high, only the very peaks will be included, if too low, noise may clutter peak detection.
- "threshold" value for peak detection, which, when divided by 10, is the multiple by which one bin must exceed the previous one for peak detection to commence. If too low, FFT detection becomes more random, if too high, no peaks are detected.
2018-08-20 00:33:10 +10:00
Bruce Luckcuck
f252b09fdb Fix dynamic filter for gyro loop < 4K
For gyro loops from 2K to < 4K scale the FFT_SAMPLING_RATE_HZ to ensure we get 3 samples.

Also constrain the `centerFreq` result from the lowpass to ensure it doesn't overshoot beyond the min/max notch center cutoff.
2018-07-31 08:59:27 -04:00
Bruce Luckcuck
0fcfb95120 Change default gyro loop to 2.67KHz for I2C gyro targets
Improves dynamic filter operation by providing a wider sampling window due to the higher gyro loop rate.

Makes the dynamic more useful by default on targets like SPRACINGF3.
2018-07-29 10:45:42 -04:00
Andrey Mironov
19f5d3cd98 Removed a redundant memset 2018-07-23 17:00:43 +03:00
Andrey Mironov
02eccab75b Made gyroAnalyse reentrant 2018-07-23 17:00:43 +03:00
mikeller
46d3f0dd83 Added parameters for dynamic notch filter. 2018-07-23 00:43:30 +12:00
ctzsnooze
ad9197ca6a Dynamic Notch Filter Update
Improves performance of the dynamic notch filter, increasing peak accuracy over a wider band of frequencies, and generally using a narrower, higher notch.
Details:
- FFT now operates on gyro data *after* gyro notches and lowpasses
- FFT bandpass Q changed from 0.707 to 0.05, to 'open up' the FFT to a greater range of incoming frequencies
- FFT centre output now ranges from about 130 to 666Hz.
- ignore the lowest couple of FFT bins going into centre frequency calculation
- analyse FFT bins from low to high, keep ignoring bins until a bin is found that exceeds its previous bin by a factor of 2; then start examining bins from the bin before that (stops the FFT from being biased low, or going to the lowest value if there is no notch at all).
- if no bin exceeds previous by more than 2 times, ie no obvious peak, smoothly go to maximum allowed notch frequency to avoid delay (might be better to bypass filter altogether?)
- dominant bin emphasised by cubing bin height before calculating mean
- maximum cutoff frequency is half the highest allowable centre frequency
- default notch width is +/-25% of centre, narrower than before most of the time
- code tidied up
- thanks to rav, Flint, UAV Tech, icr4sh, diehertz and everyone else who helped with this.
2018-07-21 22:55:41 +10:00
Andrey Mironov
77d3484b6d Unified gyro filter debug and non-debug by pseudo-templates 2018-07-16 11:03:16 +03:00
ctzsnooze
705d3939eb Initial default suggestions for 3.4
Set default RC smoothing channels to RPYT

first attempt at enabling features by default

update filter notes
2018-06-09 22:26:00 +12:00
AJ Christensen
b1069027c3 gyro sensors: use axis_e enum for consistency 2018-06-09 14:25:52 +12:00
AJ Christensen
03b480a8ef gyro sensors/debug: record standard deviation for roll *only*
* visibile in the DEBUG_GYRO_RAW[3]
2018-06-09 14:18:47 +12:00
AJ Christensen
f2cc9acc1f gyro sensors/debug: standardize gyro debugging enum elements
* will require coordination with BFC of course.
* rationale: previously `DEBUG_GYRO_NOTCH` debugging was used to grab the
  scaled, unfiltered gyro readings, prior to the FFT running. This has been
  updated to `DEBUG_GYRO_SCALED`.

  similarly, `DEBUG_GYRO` debugging was used to record the filtered gyro. This
  is updated to `GYRO_FILTERED`.

  interestingly, `DEBUG_GYRO` was also used for movement threshold calibration.
  This has been updated to be `DEBUG_GYRO_CALIBRATION` and also now stores
  per-axis standard deviation.

  Application of filter position moved slightly for logical grouping, has no
  effect due to LTI.
2018-06-07 17:17:26 +12:00
mikeller
f32731638d Removed default changes from this pull request. 2018-06-03 22:44:42 +12:00
mikeller
75693fbd5b Added defaults and MSP support to filter settings. 2018-06-03 22:44:42 +12:00
AJ Christensen
a63c8b0079 gyro & d-term filters: remove filtering options except biquad/pt1
* through extensive testing prior to the beginning of the RC cycle, we have
  discovered that the simplest combination of filters appears to be up to four
  PT1 filters: two for gyro, and two for d-term.
* non-cascaded biquad filter plumbing is retained for noisy setups and the
  dynamic notch bandpass, although gyro and d-term variants of the filtering may
  eventually be removed in favor of pt1
* update all related unit tests
2018-05-29 10:54:46 +12:00
Michael Keller
e605b497e8
Merge pull request #5932 from etracer65/gyro_cal_settings
Make gyro calibration period user configurable and rename moron_threshold
2018-05-24 21:13:47 +12:00
Andrey Mironov
3733640c08 Changed NOINLINE to be applied conditionally on ITCM presence 2018-05-23 16:34:01 +03: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
Bruce Luckcuck
8f6f4bf4c4 Make gyro calibration period user configurable and rename moron_threshold
Gryo calibration period can be configured in 1/100 second intervals using `gyro_calib_duration` (default is 125 or 1.25 seconds).

Renamed the `moron_threshold` parameter to `gyro_calib_noise_limit`. Functionally it is unchanged.
2018-05-23 07:14:52 -04:00
Michael Keller
b5521b927d
Merge pull request #5909 from etracer65/gyro_calib_cleanup
Gyro calibration cleanup and use floating point calculations for zero offset
2018-05-17 23:19:43 +12:00
Michael Keller
82500afb1b
Merge pull request #5902 from mikeller/optimise_gyro_sanity_checks_f7
Optimised gyro sanity checks for F7.
2018-05-17 23:16:38 +12:00
Michael Keller
edfa6cfcb0
Merge pull request #5900 from jflyper/bfdev-drop-stale-gyro-support
Gradually retire stale/unused acc/gyro support
2018-05-17 23:16:21 +12:00