Merge pull request #313 from mikeller/add_gyro_notch_2_filter

Added gyro notch 2 filter.
10.3.x-maintenance
borisbstyle 2016-10-12 10:21:23 +02:00 committed by GitHub
commit fd3dc4bd7a
5 changed files with 71 additions and 22 deletions

View File

@ -1649,16 +1649,22 @@
"pidTuningGyroLowpassFrequencyHelp": {
"message": "Gyro Soft Lowpass Frequency (Hz)"
},
"pidTuningGyroNotchFrequency": {
"message": "Gyro Notch Filter Frequency (Hz)"
"pidTuningGyroNotch1Frequency": {
"message": "Gyro Notch Filter 1 Frequency (Hz)"
},
"pidTuningGyroNotch2Frequency": {
"message": "Gyro Notch Filter 2 Frequency (Hz)"
},
"pidTuningGyroNotchFrequencyHelp": {
"message": "Gyro Notch Filter Frequency in Hz (0 means disabled)"
},
"pidTuningGyroNotchCutoff": {
"message": "Gyro Notch Filter Cutoff Frequency (Hz)"
},
"pidTuningGyroNotchCutoffHelp": {
"pidTuningGyroNotch1Cutoff": {
"message": "Gyro Notch Filter Cutoff 1 Frequency (Hz)"
},
"pidTuningGyroNotch2Cutoff": {
"message": "Gyro Notch Filter Cutoff 2 Frequency (Hz)"
},
"pidTuningGyroNotchCutoffHelp": {
"message": "Gyro Notch Filter Cutoff Frequency in Hz (This is where notch filter starts. For example with notch filter 160 and notch hz of 260 it means the range is 160-360hz with most attenuation around center)"
},
"pidTuningFilterSettings": {

View File

@ -261,10 +261,12 @@ var FC = {
gyro_soft_lpf_hz: 0,
dterm_lpf_hz: 0,
yaw_lpf_hz: 0,
gyro_soft_notch_hz: 0,
gyro_soft_notch_cutoff: 0,
gyro_soft_notch_hz_1: 0,
gyro_soft_notch_cutoff_1: 0,
dterm_notch_hz: 0,
dterm_notch_cutoff: 0
dterm_notch_cutoff: 0,
gyro_soft_notch_hz_2: 0,
gyro_soft_notch_cutoff_2: 0
};
ADVANCED_TUNING = {

View File

@ -591,13 +591,16 @@ MspHelper.prototype.process_data = function(dataHandler) {
FILTER_CONFIG.dterm_lpf_hz = data.readU16();
FILTER_CONFIG.yaw_lpf_hz = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
FILTER_CONFIG.gyro_soft_notch_hz = data.readU16();
FILTER_CONFIG.gyro_soft_notch_cutoff = data.readU16();
FILTER_CONFIG.gyro_soft_notch_hz_1 = data.readU16();
FILTER_CONFIG.gyro_soft_notch_cutoff_1 = data.readU16();
FILTER_CONFIG.dterm_notch_hz = data.readU16();
FILTER_CONFIG.dterm_notch_cutoff = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
FILTER_CONFIG.gyro_soft_notch_hz_2 = data.readU16();
FILTER_CONFIG.gyro_soft_notch_cutoff_2 = data.readU16();
}
}
break;
case MSPCodes.MSP_SET_PID_ADVANCED:
console.log("Advanced PID settings saved");
break;
@ -1124,10 +1127,14 @@ MspHelper.prototype.crunch = function(code) {
.push16(FILTER_CONFIG.dterm_lpf_hz)
.push16(FILTER_CONFIG.yaw_lpf_hz);
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
buffer.push16(FILTER_CONFIG.gyro_soft_notch_hz)
.push16(FILTER_CONFIG.gyro_soft_notch_cutoff)
buffer.push16(FILTER_CONFIG.gyro_soft_notch_hz_1)
.push16(FILTER_CONFIG.gyro_soft_notch_cutoff_1)
.push16(FILTER_CONFIG.dterm_notch_hz)
.push16(FILTER_CONFIG.dterm_notch_cutoff);
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
buffer.push16(FILTER_CONFIG.gyro_soft_notch_hz_2)
.push16(FILTER_CONFIG.gyro_soft_notch_cutoff_2)
}
}
break;
case MSPCodes.MSP_SET_PID_ADVANCED:

View File

@ -444,12 +444,12 @@
</tr>
<tr class="newFilter">
<td>
<input type="number" class="nonProfile" name="gyroNotchFrequency" step="1" min="0" max="500"/>
<input type="number" class="nonProfile" name="gyroNotch1Frequency" step="1" min="0" max="500"/>
</td>
<td>
<div>
<label>
<span i18n="pidTuningGyroNotchFrequency"></span>
<span i18n="pidTuningGyroNotch1Frequency"></span>
</label>
<div class="helpicon cf_tip" i18n_title="pidTuningGyroNotchFrequencyHelp"></div>
</div>
@ -457,12 +457,38 @@
</tr>
<tr class="newFilter">
<td>
<input type="number" class="nonProfile" name="gyroNotchCutoff" step="1" min="0" max="500"/>
<input type="number" class="nonProfile" name="gyroNotch1Cutoff" step="1" min="0" max="500"/>
</td>
<td>
<div>
<label>
<span i18n="pidTuningGyroNotchCutoff"></span>
<span i18n="pidTuningGyroNotch1Cutoff"></span>
</label>
<div class="helpicon cf_tip" i18n_title="pidTuningGyroNotchCutoffHelp"></div>
</div>
</td>
</tr>
<tr class="newFilter">
<td>
<input type="number" class="nonProfile" name="gyroNotch2Frequency" step="1" min="0" max="500"/>
</td>
<td>
<div>
<label>
<span i18n="pidTuningGyroNotch2Frequency"></span>
</label>
<div class="helpicon cf_tip" i18n_title="pidTuningGyroNotchFrequencyHelp"></div>
</div>
</td>
</tr>
<tr class="newFilter">
<td>
<input type="number" class="nonProfile" name="gyroNotch2Cutoff" step="1" min="0" max="500"/>
</td>
<td>
<div>
<label>
<span i18n="pidTuningGyroNotch2Cutoff"></span>
</label>
<div class="helpicon cf_tip" i18n_title="pidTuningGyroNotchCutoffHelp"></div>
</div>

View File

@ -247,8 +247,8 @@ TABS.pid_tuning.initialize = function (callback) {
}
if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) {
$('.pid_filter input[name="gyroNotchFrequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz);
$('.pid_filter input[name="gyroNotchCutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff);
$('.pid_filter input[name="gyroNotch1Frequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz_1);
$('.pid_filter input[name="gyroNotch1Cutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff_1);
$('.pid_filter input[name="dTermNotchFrequency"]').val(FILTER_CONFIG.dterm_notch_hz);
$('.pid_filter input[name="dTermNotchCutoff"]').val(FILTER_CONFIG.dterm_notch_cutoff);
@ -257,6 +257,10 @@ TABS.pid_tuning.initialize = function (callback) {
$('input[name="dtermSetpoint-number"]').val(ADVANCED_TUNING.dtermSetpointWeight / 100);
$('input[name="dtermSetpoint-range"]').val(ADVANCED_TUNING.dtermSetpointWeight / 100);
if (semver.gte(CONFIG.flightControllerVersion, '3.0.1')) {
$('.pid_filter input[name="gyroNotch2Frequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz_2);
$('.pid_filter input[name="gyroNotch2Cutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff_2);
}
} else {
$('.pid_filter .newFilter').hide();
}
@ -356,10 +360,14 @@ TABS.pid_tuning.initialize = function (callback) {
ADVANCED_TUNING.ptermSetpointWeight = parseInt($('input[name="ptermSetpoint-number"]').val() * 100);
ADVANCED_TUNING.dtermSetpointWeight = parseInt($('input[name="dtermSetpoint-number"]').val() * 100);
FILTER_CONFIG.gyro_soft_notch_hz = parseInt($('.pid_filter input[name="gyroNotchFrequency"]').val());
FILTER_CONFIG.gyro_soft_notch_cutoff = parseInt($('.pid_filter input[name="gyroNotchCutoff"]').val());
FILTER_CONFIG.gyro_soft_notch_hz_1 = parseInt($('.pid_filter input[name="gyroNotch1Frequency"]').val());
FILTER_CONFIG.gyro_soft_notch_cutoff_1 = parseInt($('.pid_filter input[name="gyroNotch1Cutoff"]').val());
FILTER_CONFIG.dterm_notch_hz = parseInt($('.pid_filter input[name="dTermNotchFrequency"]').val());
FILTER_CONFIG.dterm_notch_cutoff = parseInt($('.pid_filter input[name="dTermNotchCutoff"]').val());
if (semver.gte(CONFIG.flightControllerVersion, '3.0.1')) {
FILTER_CONFIG.gyro_soft_notch_hz_2 = parseInt($('.pid_filter input[name="gyroNotch2Frequency"]').val());
FILTER_CONFIG.gyro_soft_notch_cutoff_2 = parseInt($('.pid_filter input[name="gyroNotch2Cutoff"]').val());
}
}
}