Add dynamic lpf and dterm filters
parent
4859878e2f
commit
9f2e608530
|
@ -2950,6 +2950,15 @@
|
|||
"pidTuningGyroLowpassType": {
|
||||
"message": "Gyro Lowpass 1 Filter Type"
|
||||
},
|
||||
"pidTuningGyroLowpassDynMinFrequency": {
|
||||
"message": "Gyro Lowpass 1 Dynamic Min Cutoff Frequency [Hz]"
|
||||
},
|
||||
"pidTuningGyroLowpassDynMaxFrequency": {
|
||||
"message": "Gyro Lowpass 1 Dynamic Max Cutoff Frequency [Hz]"
|
||||
},
|
||||
"pidTuningGyroLowpassDynType": {
|
||||
"message": "Gyro Lowpass 1 Dynamic Filter Type"
|
||||
},
|
||||
"pidTuningGyroLowpass2Frequency": {
|
||||
"message": "Gyro Lowpass 2 Cutoff Frequency [Hz]"
|
||||
},
|
||||
|
@ -2974,6 +2983,9 @@
|
|||
"pidTuningNotchFilterHelp": {
|
||||
"message": "The Notch Filter has a Center and a Cutoff. The filter is symmetrical. The Center Frequency is the center of the filter and the Cutoff Frequency is where Notch filter starts. For example with Notch Cutoff of 160 and Notch Center of 260 it means the range is 160-360Hz with most attenuation around center"
|
||||
},
|
||||
"pidTuningLowpassFilterHelp": {
|
||||
"message": "The Lowpass Filters can have two variants: static and dynamic. For a determined lowpass filter number only one (static or dynamic) can be enabled at the same time. The static only has a Cutoff that is a value that defines in some way where the filter starts. The dynamic defines a min and max values, that is the range where the Cutoff is placed. This Cutoff moves from min to max at the same time than you move the throttle stick."
|
||||
},
|
||||
"pidTuningFilterSettings": {
|
||||
"message": "Profile dependent Filter Settings"
|
||||
},
|
||||
|
@ -2989,6 +3001,18 @@
|
|||
"pidTuningDTermLowpass2Frequency": {
|
||||
"message": "D Term Lowpass 2 Cutoff Frequency [Hz]"
|
||||
},
|
||||
"pidTuningDTermLowpass2Type": {
|
||||
"message": "D Term Lowpass 2 Filter Type"
|
||||
},
|
||||
"pidTuningDTermLowpassDynMinFrequency": {
|
||||
"message": "D Term Lowpass 1 Dynamic Min Cutoff Frequency [Hz]"
|
||||
},
|
||||
"pidTuningDTermLowpassDynMaxFrequency": {
|
||||
"message": "D Term Lowpass 1 Dynamic Max Cutoff Frequency [Hz]"
|
||||
},
|
||||
"pidTuningDTermLowpassDynType": {
|
||||
"message": "D Term Lowpass 1 Dynamic Filter Type"
|
||||
},
|
||||
"pidTuningDTermNotchFiltersGroup": {
|
||||
"message": "D Term Notch Filters"
|
||||
},
|
||||
|
|
10
src/js/fc.js
10
src/js/fc.js
|
@ -352,6 +352,8 @@ var FC = {
|
|||
gyro_hardware_lpf: 0,
|
||||
gyro_32khz_hardware_lpf: 0,
|
||||
gyro_lowpass_hz: 0,
|
||||
gyro_lowpass_dyn_min_hz: 0,
|
||||
gyro_lowpass_dyn_max_hz: 0,
|
||||
gyro_lowpass_type: 0,
|
||||
gyro_lowpass2_hz: 0,
|
||||
gyro_lowpass2_type: 0,
|
||||
|
@ -360,8 +362,11 @@ var FC = {
|
|||
gyro_notch2_hz: 0,
|
||||
gyro_notch2_cutoff: 0,
|
||||
dterm_lowpass_hz: 0,
|
||||
dterm_lowpass_dyn_min_hz: 0,
|
||||
dterm_lowpass_dyn_max_hz: 0,
|
||||
dterm_lowpass_type: 0,
|
||||
dterm_lowpass2_hz: 0,
|
||||
dterm_lowpass2_type: 0,
|
||||
dterm_notch_hz: 0,
|
||||
dterm_notch_cutoff: 0,
|
||||
yaw_lowpass_hz: 0,
|
||||
|
@ -452,6 +457,8 @@ var FC = {
|
|||
|
||||
DEFAULT = {
|
||||
gyro_lowpass_hz: 100,
|
||||
gyro_lowpass_dyn_min_hz: 150,
|
||||
gyro_lowpass_dyn_max_hz: 450,
|
||||
gyro_lowpass_type: 0,
|
||||
gyro_lowpass2_hz: 300,
|
||||
gyro_lowpass2_type: 0,
|
||||
|
@ -460,8 +467,11 @@ var FC = {
|
|||
gyro_notch2_cutoff: 100,
|
||||
gyro_notch2_hz: 200,
|
||||
dterm_lowpass_hz: 100,
|
||||
dterm_lowpass_dyn_min_hz: 100,
|
||||
dterm_lowpass_dyn_max_hz: 250,
|
||||
dterm_lowpass_type: 0,
|
||||
dterm_lowpass2_hz: 200,
|
||||
dterm_lowpass2_type: 0,
|
||||
dterm_notch_cutoff: 160,
|
||||
dterm_notch_hz: 260,
|
||||
yaw_lowpass_hz: 100,
|
||||
|
|
|
@ -969,6 +969,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
FILTER_CONFIG.gyro_32khz_hardware_lpf = gyro_32khz_hardware_lpf;
|
||||
} else {
|
||||
FILTER_CONFIG.gyro_32khz_hardware_lpf = 0;
|
||||
|
||||
FILTER_CONFIG.dterm_lowpass2_type = data.readU8();
|
||||
FILTER_CONFIG.gyro_lowpass_dyn_min_hz = data.readU16();
|
||||
FILTER_CONFIG.gyro_lowpass_dyn_max_hz = data.readU16();
|
||||
FILTER_CONFIG.dterm_lowpass_dyn_min_hz = data.readU16();
|
||||
FILTER_CONFIG.dterm_lowpass_dyn_max_hz = data.readU16();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1690,6 +1696,13 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push8(FILTER_CONFIG.gyro_lowpass2_type)
|
||||
.push16(FILTER_CONFIG.dterm_lowpass2_hz);
|
||||
}
|
||||
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
|
||||
buffer.push8(FILTER_CONFIG.dterm_lowpass2_type)
|
||||
.push16(FILTER_CONFIG.gyro_lowpass_dyn_min_hz)
|
||||
.push16(FILTER_CONFIG.gyro_lowpass_dyn_max_hz)
|
||||
.push16(FILTER_CONFIG.dterm_lowpass_dyn_min_hz)
|
||||
.push16(FILTER_CONFIG.dterm_lowpass_dyn_max_hz);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_SET_PID_ADVANCED:
|
||||
|
|
|
@ -315,8 +315,21 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
|
||||
$('select[id="throttleLimitType"]').val(RC_tuning.throttleLimitType);
|
||||
$('.throttle_limit input[name="throttleLimitPercent"]').val(RC_tuning.throttleLimitPercent);
|
||||
|
||||
$('.pid_filter select[name="dtermLowpass2Type"]').val(FILTER_CONFIG.dterm_lowpass2_type);
|
||||
$('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val(FILTER_CONFIG.gyro_lowpass_dyn_min_hz);
|
||||
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val(FILTER_CONFIG.gyro_lowpass_dyn_max_hz);
|
||||
$('.pid_filter select[name="gyroLowpassDynType"]').val(FILTER_CONFIG.gyro_lowpass_type);
|
||||
$('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val(FILTER_CONFIG.dterm_lowpass_dyn_min_hz);
|
||||
$('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val(FILTER_CONFIG.dterm_lowpass_dyn_max_hz);
|
||||
$('.pid_filter select[name="dtermLowpassDynType"]').val(FILTER_CONFIG.dterm_lowpass_type);
|
||||
|
||||
} else {
|
||||
$('.throttle_limit').hide();
|
||||
|
||||
$('.gyroLowpassDyn').hide();
|
||||
$('.dtermLowpassDyn').hide();
|
||||
$('.dtermLowpass2TypeGroup').hide();
|
||||
}
|
||||
|
||||
$('input[id="gyroNotch1Enabled"]').change(function() {
|
||||
|
@ -356,6 +369,30 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
|
||||
$('.pid_filter input[name="gyroLowpassFrequency"]').val(checked ? cutoff : 0).attr('disabled', !checked);
|
||||
$('.pid_filter select[name="gyroLowpassType"]').val(checked ? type : 0).attr('disabled', !checked);
|
||||
|
||||
if (checked) {
|
||||
$('input[id="gyroLowpassDynEnabled"]').prop('checked', false).change();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('input[id="gyroLowpassDynEnabled"]').change(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
var cutoff_min = DEFAULT.gyro_lowpass_dyn_min_hz;
|
||||
var cutoff_max = DEFAULT.gyro_lowpass_dyn_max_hz;
|
||||
if (FILTER_CONFIG.gyro_lowpass_dyn_min_hz > 0 && FILTER_CONFIG.gyro_lowpass_dyn_min_hz < FILTER_CONFIG.gyro_lowpass_dyn_max_hz) {
|
||||
cutoff_min = FILTER_CONFIG.gyro_lowpass_dyn_min_hz;
|
||||
cutoff_max = FILTER_CONFIG.gyro_lowpass_dyn_max_hz;
|
||||
}
|
||||
var type = FILTER_CONFIG.gyro_lowpass_type > 0 ? FILTER_CONFIG.gyro_lowpass_type : DEFAULT.gyro_lowpass_type;
|
||||
|
||||
$('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val(checked ? cutoff_min : 0).attr('disabled', !checked);
|
||||
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val(checked ? cutoff_max : 0).attr('disabled', !checked);
|
||||
$('.pid_filter select[name="gyroLowpassDynType"]').val(checked ? type : 0).attr('disabled', !checked);
|
||||
|
||||
if (checked) {
|
||||
$('input[id="gyroLowpassEnabled"]').prop('checked', false).change();
|
||||
}
|
||||
});
|
||||
|
||||
$('input[id="gyroLowpass2Enabled"]').change(function() {
|
||||
|
@ -374,13 +411,38 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
|
||||
$('.pid_filter input[name="dtermLowpassFrequency"]').val(checked ? cutoff : 0).attr('disabled', !checked);
|
||||
$('.pid_filter select[name="dtermLowpassType"]').val(checked ? type : 0).attr('disabled', !checked);
|
||||
|
||||
if (checked) {
|
||||
$('input[id="dtermLowpassDynEnabled"]').prop('checked', false).change();
|
||||
}
|
||||
});
|
||||
|
||||
$('input[id="dtermLowpassDynEnabled"]').change(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
var cutoff_min = DEFAULT.dterm_lowpass_dyn_min_hz;
|
||||
var cutoff_max = DEFAULT.dterm_lowpass_dyn_max_hz;
|
||||
if (FILTER_CONFIG.dterm_lowpass_dyn_min_hz > 0 && FILTER_CONFIG.dterm_lowpass_dyn_min_hz < FILTER_CONFIG.dterm_lowpass_dyn_max_hz) {
|
||||
cutoff_min = FILTER_CONFIG.dterm_lowpass_dyn_min_hz;
|
||||
cutoff_max = FILTER_CONFIG.dterm_lowpass_dyn_max_hz;
|
||||
}
|
||||
var type = FILTER_CONFIG.dterm_lowpass_type > 0 ? FILTER_CONFIG.dterm_lowpass_type : DEFAULT.dterm_lowpass_type;
|
||||
|
||||
$('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val(checked ? cutoff_min : 0).attr('disabled', !checked);
|
||||
$('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val(checked ? cutoff_max : 0).attr('disabled', !checked);
|
||||
$('.pid_filter select[name="dtermLowpassDynType"]').val(checked ? type : 0).attr('disabled', !checked);
|
||||
|
||||
if (checked) {
|
||||
$('input[id="dtermLowpassEnabled"]').prop('checked', false).change();
|
||||
}
|
||||
});
|
||||
|
||||
$('input[id="dtermLowpass2Enabled"]').change(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
var cutoff = FILTER_CONFIG.dterm_lowpass2_hz > 0 ? FILTER_CONFIG.dterm_lowpass2_hz : DEFAULT.dterm_lowpass2_hz;
|
||||
var type = FILTER_CONFIG.dterm_lowpass2_type > 0 ? FILTER_CONFIG.dterm_lowpass2_type : DEFAULT.dterm_lowpass2_type;
|
||||
|
||||
$('.pid_filter input[name="dtermLowpass2Frequency"]').val(checked ? cutoff : 0).attr('disabled', !checked);
|
||||
$('.pid_filter select[name="dtermLowpass2Type"]').val(checked ? type : 0).attr('disabled', !checked);
|
||||
});
|
||||
|
||||
$('input[id="yawLowpassEnabled"]').change(function() {
|
||||
|
@ -420,8 +482,10 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('input[id="gyroNotch2Enabled"]').prop('checked', FILTER_CONFIG.gyro_notch2_hz != 0).change();
|
||||
$('input[id="dtermNotchEnabled"]').prop('checked', FILTER_CONFIG.dterm_notch_hz != 0).change();
|
||||
$('input[id="gyroLowpassEnabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass_hz != 0).change();
|
||||
$('input[id="gyroLowpassDynEnabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass_dyn_min_hz != 0 && FILTER_CONFIG.gyro_lowpass_dyn_min_hz < FILTER_CONFIG.gyro_lowpass_dyn_max_hz).change();
|
||||
$('input[id="gyroLowpass2Enabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass2_hz != 0).change();
|
||||
$('input[id="dtermLowpassEnabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass_hz != 0).change();
|
||||
$('input[id="dtermLowpassDynEnabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass_dyn_min_hz != 0 && FILTER_CONFIG.dterm_lowpass_dyn_min_hz < FILTER_CONFIG.dterm_lowpass_dyn_max_hz).change();
|
||||
$('input[id="dtermLowpass2Enabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass2_hz != 0).change();
|
||||
$('input[id="yawLowpassEnabled"]').prop('checked', FILTER_CONFIG.yaw_lowpass_hz != 0).change();
|
||||
}
|
||||
|
@ -535,6 +599,19 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
|
||||
RC_tuning.throttleLimitType = $('select[id="throttleLimitType"]').val();
|
||||
RC_tuning.throttleLimitPercent = parseInt($('.throttle_limit input[name="throttleLimitPercent"]').val());
|
||||
|
||||
FILTER_CONFIG.dterm_lowpass2_type = $('.pid_filter select[name="dtermLowpass2Type"]').val();
|
||||
FILTER_CONFIG.gyro_lowpass_dyn_min_hz = parseInt($('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val());
|
||||
FILTER_CONFIG.gyro_lowpass_dyn_max_hz = parseInt($('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val());
|
||||
FILTER_CONFIG.dterm_lowpass_dyn_min_hz = parseInt($('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val());
|
||||
FILTER_CONFIG.dterm_lowpass_dyn_max_hz = parseInt($('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val());
|
||||
|
||||
if (FILTER_CONFIG.gyro_lowpass_dyn_min_hz > 0 && FILTER_CONFIG.gyro_lowpass_dyn_min_hz < FILTER_CONFIG.gyro_lowpass_dyn_max_hz ) {
|
||||
FILTER_CONFIG.gyro_lowpass_type = $('.pid_filter select[name="gyroLowpassDynType"]').val();
|
||||
}
|
||||
if (FILTER_CONFIG.dterm_lowpass_dyn_min_hz > 0 && FILTER_CONFIG.dterm_lowpass_dyn_min_hz < FILTER_CONFIG.dterm_lowpass_dyn_max_hz ) {
|
||||
FILTER_CONFIG.dterm_lowpass_type = $('.pid_filter select[name="dtermLowpassDynType"]').val();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -919,8 +996,11 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
}
|
||||
|
||||
populateFilterTypeSelector('gyroLowpassType', loadFilterTypeValues());
|
||||
populateFilterTypeSelector('gyroLowpassDynType', loadFilterTypeValues());
|
||||
populateFilterTypeSelector('gyroLowpass2Type', loadFilterTypeValues());
|
||||
populateFilterTypeSelector('dtermLowpassType', loadFilterTypeValues());
|
||||
populateFilterTypeSelector('dtermLowpass2Type', loadFilterTypeValues());
|
||||
populateFilterTypeSelector('dtermLowpassDynType', loadFilterTypeValues());
|
||||
|
||||
pid_and_rc_to_form();
|
||||
|
||||
|
|
|
@ -639,10 +639,57 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<div class="pid_mode" i18n="pidTuningGyroLowpassFiltersGroup"/>
|
||||
<div class="pid_mode">
|
||||
<div i18n="pidTuningGyroLowpassFiltersGroup" />
|
||||
<div class="helpicon cf_tip" i18n_title="pidTuningLowpassFilterHelp" />
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr class="gyroLowpassDyn">
|
||||
<td>
|
||||
<span class="groupSwitchValue">
|
||||
<span class="inputSwitch"><input type="checkbox" id="gyroLowpassDynEnabled" class="toggle" /></span>
|
||||
<span class="inputValue"><input type="number" name="gyroLowpassDynMinFrequency" step="1" min="1" max="16000"/></span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningGyroLowpassDynMinFrequency"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="gyroLowpassDyn">
|
||||
<td>
|
||||
<span class="inputValue"><input type="number" name="gyroLowpassDynMaxFrequency" step="1" min="1" max="16000"/></span>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningGyroLowpassDynMaxFrequency"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="gyroLowpassDyn">
|
||||
<td>
|
||||
<select name="gyroLowpassDynType">
|
||||
<!-- Populated on execution -->
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningGyroLowpassDynType"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="groupSwitchValue">
|
||||
|
@ -674,6 +721,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="gyroLowpass2">
|
||||
<td>
|
||||
<span class="groupSwitchValue">
|
||||
|
@ -786,10 +834,57 @@
|
|||
<th colspan="2">
|
||||
<div class="pid_mode">
|
||||
<div i18n="pidTuningDTermLowpassFiltersGroup" />
|
||||
<div class="helpicon cf_tip" i18n_title="pidTuningLowpassFilterHelp" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr class="dtermLowpassDyn">
|
||||
<td>
|
||||
<span class="groupSwitchValue">
|
||||
<span class="inputSwitch"><input type="checkbox" id="dtermLowpassDynEnabled" class="toggle" /></span>
|
||||
<span class="inputValue"><input type="number" name="dtermLowpassDynMinFrequency" step="1" min="1" max="16000"/></span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningDTermLowpassDynMinFrequency"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="dtermLowpassDyn">
|
||||
<td>
|
||||
<span class="inputValue"><input type="number" name="dtermLowpassDynMaxFrequency" step="1" min="1" max="16000"/></span>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningDTermLowpassDynMaxFrequency"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="dtermLowpassDyn">
|
||||
<td>
|
||||
<select name="dtermLowpassDynType">
|
||||
<!-- Populated on execution -->
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningDTermLowpassDynType"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="groupSwitchValue">
|
||||
|
@ -837,6 +932,21 @@
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="dtermLowpass2 dtermLowpass2TypeGroup">
|
||||
<td>
|
||||
<select name="dtermLowpass2Type">
|
||||
<!-- Populated on execution -->
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<label>
|
||||
<span i18n="pidTuningDTermLowpass2Type"></span>
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<div class="pid_mode">
|
||||
|
|
Loading…
Reference in New Issue