diff --git a/FilterReview/FilterReview.js b/FilterReview/FilterReview.js index 9f0bdea5..8d546e0f 100644 --- a/FilterReview/FilterReview.js +++ b/FilterReview/FilterReview.js @@ -181,7 +181,7 @@ function HarmonicNotchFilter(params) { } } - if (this.tracking == null) { + if ((this.tracking == null) && (this.params.enable > 0)) { alert("Unsupported notch mode " + this.params.mode) } @@ -443,7 +443,7 @@ function reset() { } // Reset FFT plot notch selection - for (let i = 0; i < 2; i++) { + for (let i = 0; i < num_notches; i++) { let check = document.getElementById("Notch" + (i+1) + "Show") check.disabled = true check.checked = false @@ -492,6 +492,8 @@ var fft_plot = {} var Bode = {} var flight_data = {} const max_num_harmonics = 16 +const num_notches = 4 +const notch_dash = ["solid", "dot", "dash", "dashdot"] function setup_plots() { const time_scale_label = "Time (s)" @@ -610,9 +612,9 @@ function setup_plots() { } // Add tracking lines - // Two harmonic notch filters each with upto 8 harmonics - for (let i=0;i<2;i++) { - let dash = (i == 0) ? "solid" : "dot" + // Harmonic notch filters each with upto 16 harmonics + for (let i=0;i" + name, - legendgroup: i+2, + legendgroup: i+num_notches, legendgrouptitle: { text: "" } }) } @@ -1581,7 +1583,7 @@ function redraw_Spectrogram() { for (let i=0;i= 4 + // The third and fourth notches are side by side, only show their enable params unless either is enabled + const show_extra = HNotch_params.slice(2).some((names) => parameter_get_value(names.enable) > 0) + for (let i = 0; i < HNotch_params.length; i++) { - // Show/hide ESCMSK based on filter version - const esc_mask_elem = document.getElementById(HNotch_params[i].esc_mask) - if (esc_mask_elem != null) { - esc_mask_elem.parentElement.style.display = show_esc_mask ? "" : "none" - if (!show_esc_mask) { - parameter_set_value(HNotch_params[i].esc_mask, 0) + const show_all = (i < 2) || show_extra + for (const [key, name] of Object.entries(HNotch_params[i])) { + const elem = document.getElementById(name) + if ((key == "enable") || (elem == null)) { + continue } + // Show/hide ESCMSK based on filter version + const show = show_all && ((key != "esc_mask") || show_esc_mask) + elem.parentElement.style.display = show ? "" : "none" + } + if (!show_esc_mask) { + parameter_set_value(HNotch_params[i].esc_mask, 0) } // Set harmonic bitmask size based on firmware capability @@ -1931,6 +1941,9 @@ function time_range_changed() { // build url and query string for current params and open filter tool in new window function open_in_filter_tool() { + // Filter Tool only has two harmonic notches + const extra_notches = [3, 4].filter((num) => parseFloat(document.getElementById("INS_HNTC" + num + "_ENABLE").value) > 0) + // Assume same base let url = new URL(window.location.href) url.pathname = url.pathname.replace('FilterReview','FilterTool') @@ -1993,6 +2006,11 @@ function open_in_filter_tool() { window.open(url.toString()) + // Warn after opening, a popup blocker can stop the window opening if the alert is left open + if (extra_notches.length > 0) { + alert("Filter Tool supports two harmonic notches, notch " + extra_notches.join(" and ") + " will not be included") + } + } function save_parameters() { @@ -2469,8 +2487,10 @@ async function load(log_file) { new RPMTarget(log, 2, 5)] // Load logged notch fequencies for comparison - logged_tracking = [ new LoggedNotch(log, 0), - new LoggedNotch(log, 1) ] + logged_tracking = [] + for (let i = 0; i < num_notches; i++) { + logged_tracking.push(new LoggedNotch(log, i)) + } // If log data is present allow user to show it let show_logged_notch = false @@ -2574,8 +2594,9 @@ async function load(log_file) { // Enable top level filter params parameter_set_disable("INS_GYRO_FILTER", false) parameter_set_disable("SCHED_LOOP_RATE", false) - parameter_set_disable("INS_HNTCH_ENABLE", false) - parameter_set_disable("INS_HNTC2_ENABLE", false) + for (const names of get_HNotch_param_names()) { + parameter_set_disable(names.enable, false) + } // Load filters from params filter_param_read() diff --git a/FilterReview/index.html b/FilterReview/index.html index caec117a..bb6ac5cc 100644 --- a/FilterReview/index.html +++ b/FilterReview/index.html @@ -380,7 +380,7 @@

IMU Spectrum -
+
Notch tracking IMU Spectrum + + + + + +
@@ -536,6 +542,81 @@

Filter Configuration + + + + + + +
+
+ Third Notch Filter +

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+
+
+
+ Fourth Notch Filter +

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+

+ +

+
+

IMU Spectrogram @@ -599,7 +680,7 @@

IMU Spectrogram

-
+
Notch tracking