1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00
Commit graph

36 commits

Author SHA1 Message Date
ctzsnooze
2bc6f92c1b move definition of dataThreshold 2018-08-20 00:33:11 +10:00
ctzsnooze
c6a2ba18ef Improve peak detection 2018-08-20 00:33:11 +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
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
Michael Keller
b979cb2ea4
Merge pull request #6485 from etracer65/dyn_filter_2k
Fix dynamic filter for gyro loop < 4K
2018-08-02 13:10:26 +12:00
Bruce Luckcuck
382ad2ad8f More changes from review & rebase
Simplified disable logic to only use the feature() check in the gyro loop.

Changed 2000hz loop time constant to a define.
2018-08-01 12:20:32 -04:00
Bruce Luckcuck
9ba89f6da0 Changes from review
Revise and simplify initialization logic and avoid unneeded code if USE_DUAL_GYRO is not defined.

Corrected double constant to float.

Split centerFreq filter apply and constrain into separate statements.
2018-08-01 12:12:44 -04:00
Bruce Luckcuck
25c6b038d9 Changes from review
Used HZ_TO_INTERVAL_US() instead of hardcoded 500us.

Moved tests into a dedicated function.
2018-07-31 10:37:01 -04: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
Andrey Mironov
02eccab75b Made gyroAnalyse reentrant 2018-07-23 17:00:43 +03:00
Andrey Mironov
79dfaadb85 Fixed dynamic notch Q scaling 2018-07-23 14:41:21 +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
d8dd6f29f8 Set FAST_RAM to go into .fastram_data by default. Added FAST_RAM_NOINIT 2018-05-23 14:40:33 +03:00
blckmn
a9f74cd6df Removed excess trailing spaces before new lines on licenses. 2018-04-25 20:58:00 +10:00
blckmn
b6422db597 All applicable files now updated. 2018-04-22 12:13:33 +10:00
Andrey Mironov
172642383d
Fixed notch Q calculation to be dimensionless as it should (#5529)
* Fixed notch Q calculation to be dimensionless as it should

* Get rid of one division and leverage multiply-accumulate instr
2018-03-24 20:27:39 +03:00
Miroslav Drbal [ApoC]
3ce8223c96 Dynamic filter performance improvement for 16k and 32k gyro loop frequency (#5450)
* * FAST_RAM-ing variables used to compute FFT
* Eradicated global static variables in favour of define
* FFT_WINDOW_SIZE / 2 replaced with FFT_BIN_COUNT
* Limit call count of filters update to necessary minimum on 32k and 16k gyro sampling rate
* Dynamic filter recalculation freq. is at least FFT_SAMPLING_RATE + update time
* Moved global variables used in local scope only to local scope

* * Based on diehertzs review I removed all 0 initializations of global variables

* * Fixed calculation of update frequency for center frequency filter, thx rav-rav for pointing the problem

* * Silenced the warning signed vs unsigned comparison

* * Replaced magick values 3*4 and 12 with preprocessor macro as requested by DieHertz

* * Replaced hardcoded axis count with proper preprocessor macro
2018-03-21 00:17:34 +13:00
Martin Budden
3125ae252b Tidied gyro filter code 2018-01-03 12:27:53 +00:00
Martin Budden
671382234a Enabled switch fallthrough checking by compiler 2017-12-23 19:46:40 +00:00
mikeller
b489d0ba9d Renamed 'parameter_group' to 'pg'. 2017-12-19 23:36:31 +13:00
Martin Budden
de5b0d53ff Enabled Instruction TCM 2017-12-17 13:41:51 +00:00
Martin Budden
12640972a9 Preparation for using instruction cache on F7 2017-12-15 10:07:19 +00:00
Michael Keller
a7deb8b899 Merge pull request #3799 from adrianmiriuta/HEADFREE_MAG
HEADFREE true 3D (second edition)...
2017-10-12 00:01:23 +13:00
Martin Budden
53f5e87c7a Add void to function declarations/definitions where required 2017-09-24 09:22:48 +01:00
Adrian Miriuta
7146c40ca8 HEADFREE true 3D (second edition)...
reduced memory footprint ...
	rebased squashed cleanup
2017-09-23 07:35:30 +02:00
Martin Budden
a86ac89448 Whitespace tidy 2017-07-05 09:34:44 +01:00
Martin Budden
23f158913e Moved time functions out of system.h into time.h 2017-05-26 14:03:28 +01:00
rav
26b1cd4237 remove dynamic filtering as a mode 2017-05-15 17:03:22 +02:00
rav
a2453d1980 code reformatting
rename biquadFilterApplyDF2 back to biquadFilterApply
add new value for dynamic notch mode
fix COLIBRI_RACE/i2c_bst.c
2017-05-13 02:22:38 +02:00
rav
cd5307188e some code reformatting 2017-05-12 17:22:59 +02:00
rav
c7f8e4d7a4 remove unused OSD data
add dynamic filters to F3 and F7 targets
fix COLIBRI_RACE and OMNIBUS
2017-05-12 17:13:51 +02:00
rav
75089ea24c fix build errors 2017-05-11 23:10:00 +02:00
rav
d9909b91d3 enable frequency analysis and automatic, dynamic changing of notch filter frequencies
change F3 from CM1 to CM4
add debug flags for FFT
add bandpass filter
add different filtering apply function
add feature DYNAMIC_FILTER
replace mode GTUNE with DYNAMIC FILTER
move gyro frequency analysis into gyro loop instead of own task
2017-05-11 16:10:29 +02:00
Martin Budden
2493c214b0 Created subdirectories in drivers directory 2017-04-12 08:06:22 +01:00
Martin Budden
ea2ec8b069 Added hooks for gyro data analysis 2017-02-23 15:52:26 +00:00