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
18 changes: 18 additions & 0 deletions PIDReview/PIDReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function reset() {
step_plot.data[i].x = []
step_plot.data[i].y = []
}
document.getElementById("step_note").hidden = true
for (let i = 0; i < Spectrogram.data.length; i++) {
Spectrogram.data[i].x = []
Spectrogram.data[i].y = []
Expand Down Expand Up @@ -397,6 +398,7 @@ function get_FFT_data_index(set_num, plot_type) {
function setup_FFT_data() {

const PID = PID_log_messages[get_axis_index()]
document.getElementById("step_note").hidden = true

// Clear existing data
TimeInputs.layout.shapes = []
Expand Down Expand Up @@ -508,6 +510,7 @@ function clear_calculation() {
}
// Enable button to fix
document.getElementById("calculate").disabled = false
document.getElementById("step_note").hidden = true

for (let i = 0; i < PID_log_messages.length; i++) {
if ((PID_log_messages[i] == null) || (PID_log_messages[i].sets == null)) {
Expand Down Expand Up @@ -1047,7 +1050,10 @@ function redraw_step() {
const plot_index = i*2
step_plot.data[plot_index].x = []
step_plot.data[plot_index].y = []
step_plot.data[plot_index+1].x = []
step_plot.data[plot_index+1].y = []
}
document.getElementById("step_note").hidden = true
if (valid_sets == 0) {
Plotly.redraw("step_plot")
return
Expand Down Expand Up @@ -1105,6 +1111,9 @@ function redraw_step() {
// Pre-calculate inverse
sn = array_inverse(sn)

// True if there is at least one step estimate
let have_steps = false

// For each data set
for (let j = 0; j < num_sets; j++) {
if (PID.sets[j] == null) {
Expand Down Expand Up @@ -1189,6 +1198,7 @@ function redraw_step() {
// No good steps, skip this set
continue
}
have_steps = true

// Plot mean
step_plot.data[plot_index+1].x = time
Expand All @@ -1201,6 +1211,14 @@ function redraw_step() {

}

// Explain an empty plot, the threshold is in the units of the axis
let note = document.getElementById("step_note")
note.hidden = have_steps
note.textContent = "No step response: not enough of the analysis time has a target above 20 " + PID.units + "."
if (PID.units == "deg /s") {
note.textContent += " Select a section with some sharp stick inputs."
}

step_plot.layout.yaxis.range = [0, 2]
step_plot.layout.yaxis.autorange = false

Expand Down
5 changes: 4 additions & 1 deletion PIDReview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,18 @@ <h2 style="text-align:center">
Step Response
<img id="TT_PID_StepResponse" src="../images/question-circle.svg" style="width: 1em; vertical-align: bottom"
data-tippy-content="
Simulated PID response to a step input.
Closed loop step response estimated from the logged target and actual rates.
Used to evaluate rise time, overshoot, damping, and stability.
Only parts of the flight where the target goes above 20 (deg/s for rate axes) are used, so the analysis time needs some sharp stick inputs.
Grey lines are the estimate from each part, the coloured line is their mean.
" />
</h2>


</td></tr></table>

<div id="step_plot" style="width:1200px;height:450px"></div>
<p id="step_note" style="width:1200px; text-align:center" hidden></p>

<table><tr><td style="width:1200px">
<h2 style="text-align:center">
Expand Down
Loading