Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 50 additions & 19 deletions FilterReview/FilterReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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<num_notches;i++) {
let dash = notch_dash[i]
for (let j=0;j<max_num_harmonics;j++) {
// Mean line
fft_plot.layout.shapes.push({
Expand Down Expand Up @@ -692,10 +694,10 @@ function setup_plots() {
}]

// Add tracking lines
// Two harmonic notch filters each with upto 16 harmonics
for (let i=0;i<2;i++) {
// Harmonic notch filters each with upto 16 harmonics
for (let i=0;i<num_notches;i++) {
let Group_name = "Notch " + (i+1)
let dash = (i == 0) ? "solid" : "dot"
let dash = notch_dash[i]
for (let j=0;j<max_num_harmonics;j++) {
let name = (j == 0) ? "Fundamental" : "Harmonic " + (j+1)
Spectrogram.data.push({
Expand All @@ -712,9 +714,9 @@ function setup_plots() {
}

// Logged notch tacking
for (let i=0;i<2;i++) {
for (let i=0;i<num_notches;i++) {
let Group_name = "Logged Notch " + (i+1)
let dash = (i == 0) ? "solid" : "dot"
let dash = notch_dash[i]
for (let j=0;j<max_num_harmonics;j++) {
let name = (j == 0) ? "Fundamental" : "Harmonic " + (j+1)
Spectrogram.data.push({
Expand All @@ -724,7 +726,7 @@ function setup_plots() {
visible: false,
name: name,
meta: Group_name + "<br>" + name,
legendgroup: i+2,
legendgroup: i+num_notches,
legendgrouptitle: { text: "" }
})
}
Expand Down Expand Up @@ -1581,7 +1583,7 @@ function redraw_Spectrogram() {
for (let i=0;i<filters.notch.length;i++) {
// Plus one for the spectrogram plot
const plot_offset = i * max_num_harmonics + 1
const logged_offset = max_num_harmonics * 2
const logged_offset = max_num_harmonics * num_notches

// Hide all
for (let j=0;j<max_num_harmonics;j++) {
Expand Down Expand Up @@ -1653,7 +1655,7 @@ function redraw_Spectrogram() {
plot_data = build_plot_array(fundamental)

const show_logged = document.getElementById("SpecNotchShowLogged").checked
const logged_offset = max_num_harmonics * 2
const logged_offset = max_num_harmonics * num_notches
for (let j=0;j<max_num_harmonics;j++) {
if ((logged_tracking[i].harmonics & (1<<j)) == 0) {
continue
Expand All @@ -1680,7 +1682,7 @@ function update_hidden_spec(source) {

// Offset by the total number of lines over
const show_logged = document.getElementById("SpecNotchShowLogged").checked
const logged_offset = max_num_harmonics * 2
const logged_offset = max_num_harmonics * num_notches

const plot_offset = notch_num * max_num_harmonics + 1

Expand Down Expand Up @@ -1711,7 +1713,7 @@ function update_logged_notch_hidden_spec(source) {

// Offset by the total number of lines over
const show_logged = source.checked
const logged_offset = max_num_harmonics * 2
const logged_offset = max_num_harmonics * num_notches

for (let i=0;i<filters.notch.length;i++) {
const plot_offset = i * max_num_harmonics + 1
Expand Down Expand Up @@ -1836,7 +1838,7 @@ function update_hidden(source) {
}

function get_HNotch_param_names() {
let prefix = ["INS_HNTCH_", "INS_HNTC2_"]
let prefix = ["INS_HNTCH_", "INS_HNTC2_", "INS_HNTC3_", "INS_HNTC4_"]
let ret = []
for (let i = 0; i < prefix.length; i++) {
ret[i] = {enable: prefix[i] + "ENABLE",
Expand All @@ -1853,6 +1855,19 @@ function get_HNotch_param_names() {
return ret
}

// Show or hide a notch, the third and fourth notches are only available on some firmware
function show_notch(index, show) {
const num = index + 1
const display = show ? "" : "none"
document.getElementById("Notch" + num + "Params").style.display = display
document.getElementById("Notch" + num + "ShowGroup").style.display = display
document.getElementById("SpecNotch" + num + "ShowGroup").style.display = display

// Hide the table holding the extra notches if none are shown
const any_shown = ["Notch3Params", "Notch4Params"].some((id) => document.getElementById(id).style.display != "none")
document.getElementById("ExtraNotches").style.display = any_shown ? "" : "none"
}

function load_filters() {

filters = []
Expand Down Expand Up @@ -2031,6 +2046,14 @@ async function load_parameters(file) {
}
}

// Show the third and fourth notches if they are in the file
const HNotch_params = get_HNotch_param_names()
for (let i = 2; i < HNotch_params.length; i++) {
if (text.includes(HNotch_params[i].enable)) {
show_notch(i, true)
}
}

filter_param_read()
re_calc()
}
Expand Down Expand Up @@ -2469,8 +2492,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
Expand All @@ -2495,6 +2520,11 @@ async function load(log_file) {
}
}

// Only show the third and fourth notches if the firmware has them
for (let i = 2; i < HNotch_params.length; i++) {
show_notch(i, get_param(HNotch_params[i].enable) != null)
}

const other_params = ["INS_GYRO_FILTER", "SCHED_LOOP_RATE"]
for (const param of other_params) {
const value = get_param(param)
Expand Down Expand Up @@ -2574,8 +2604,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()
Expand Down
99 changes: 97 additions & 2 deletions FilterReview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ <h2 style="text-align:center">IMU Spectrum
</fieldset>
</td>
<td>
<fieldset style="width:240px;height:40px">
<fieldset style="width:240px;min-height:40px">
<legend>Notch tracking
<img id="TT" src="../images/question-circle.svg" style="width: 1em; vertical-align: bottom"
data-tippy-content='Show/hide the center frequency and movement range of enabled notch filters. These should line up with noise peaks.',
Expand All @@ -391,6 +391,16 @@ <h2 style="text-align:center">IMU Spectrum

<input type="checkbox" id="Notch2Show" name="Notch2Show" onchange="update_hidden(this)">
<label for="Notch2Show">Show notch 2</label>

<span id="Notch3ShowGroup" style="display:none">
<input type="checkbox" id="Notch3Show" name="Notch3Show" onchange="update_hidden(this)">
<label for="Notch3Show">Show notch 3</label>
</span>

<span id="Notch4ShowGroup" style="display:none">
<input type="checkbox" id="Notch4Show" name="Notch4Show" onchange="update_hidden(this)">
<label for="Notch4Show">Show notch 4</label>
</span>
</fieldset>
</td>
<td>
Expand Down Expand Up @@ -536,6 +546,81 @@ <h2 style="text-align:center">Filter Configuration
</td>
</tr>
</table>
<table id="ExtraNotches" style="display:none">
<tr>
<td style="width: 30px;"></td>
<td style="vertical-align: top">
<fieldset id="Notch3Params" style="width:532px;display:none">
<legend>Third Notch Filter</legend>
<p>
<input id="INS_HNTC3_ENABLE" name="INS_HNTC3_ENABLE" type="number" step="1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_MODE" name="INS_HNTC3_MODE" type="number" step="1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_FREQ" name="INS_HNTC3_FREQ" type="number" step="0.1" value="0"style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_BW" name="INS_HNTC3_BW" type="number" step="0.1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_ATT" name="INS_HNTC3_ATT" type="number" step="0.1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_REF" name="INS_HNTC3_REF" type="number" step="0.01" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_FM_RAT" name="INS_HNTC3_FM_RAT" type="number" step="0.01" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_HMNCS" name="INS_HNTC3_HMNCS" type="number" step="1" value="0" style="width: 100px" data-bitmask-columns="4" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC3_OPTS" name="INS_HNTC3_OPTS" type="number" step="1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p style="display:none">
<input id="INS_HNTC3_ESCMSK" name="INS_HNTC3_ESCMSK" type="number" step="1" value="0" style="width: 100px" data-bitmask-columns="6" onchange="filter_param_read()"/>
</p>
</fieldset>
</td>
<td style="vertical-align: top">
<fieldset id="Notch4Params" style="width:532px;display:none">
<legend>Fourth Notch Filter</legend>
<p>
<input id="INS_HNTC4_ENABLE" name="INS_HNTC4_ENABLE" type="number" step="1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_MODE" name="INS_HNTC4_MODE" type="number" step="1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_FREQ" name="INS_HNTC4_FREQ" type="number" step="0.1" value="0"style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_BW" name="INS_HNTC4_BW" type="number" step="0.1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_ATT" name="INS_HNTC4_ATT" type="number" step="0.1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_REF" name="INS_HNTC4_REF" type="number" step="0.01" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_FM_RAT" name="INS_HNTC4_FM_RAT" type="number" step="0.01" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_HMNCS" name="INS_HNTC4_HMNCS" type="number" step="1" value="0" style="width: 100px" data-bitmask-columns="4" onchange="filter_param_read()"/>
</p>
<p>
<input id="INS_HNTC4_OPTS" name="INS_HNTC4_OPTS" type="number" step="1" value="0" style="width: 100px" onchange="filter_param_read()"/>
</p>
<p style="display:none">
<input id="INS_HNTC4_ESCMSK" name="INS_HNTC4_ESCMSK" type="number" step="1" value="0" style="width: 100px" data-bitmask-columns="6" onchange="filter_param_read()"/>
</p>
</fieldset>
</td>
</tr>
</table>

<table><tr><td style="width:1200px">
<h2 style="text-align:center">IMU Spectrogram
Expand Down Expand Up @@ -599,7 +684,7 @@ <h2 style="text-align:center">IMU Spectrogram
</fieldset>
</td>
<td>
<fieldset style="width:240px;height:40px">
<fieldset style="width:240px;min-height:40px">
<legend>Notch tracking
<img id="TT" src="../images/question-circle.svg" style="width: 1em; vertical-align: bottom"
data-tippy-content='Show/hide the center frequency and movement range of enabled notch filters. These should line up with noise peaks.
Expand All @@ -612,6 +697,16 @@ <h2 style="text-align:center">IMU Spectrogram
<input type="checkbox" id="SpecNotch2Show" name="SpecNotch2Show" onchange="update_hidden_spec(this)">
<label for="SpecNotch2Show">Notch 2</label>

<span id="SpecNotch3ShowGroup" style="display:none">
<input type="checkbox" id="SpecNotch3Show" name="SpecNotch3Show" onchange="update_hidden_spec(this)">
<label for="SpecNotch3Show">Notch 3</label>
</span>

<span id="SpecNotch4ShowGroup" style="display:none">
<input type="checkbox" id="SpecNotch4Show" name="SpecNotch4Show" onchange="update_hidden_spec(this)">
<label for="SpecNotch4Show">Notch 4</label>
</span>

<input type="checkbox" id="SpecNotchShowLogged" name="SpecNotchShowLogged" onchange="update_logged_notch_hidden_spec(this)">
<label for="SpecNotchShowLogged">Logged</label>
</fieldset>
Expand Down
Loading