Skip to content
Brian White edited this page Mar 28, 2019 · 12 revisions

Welcome to the PIDtoolbox wiki!

Here you will find a detailed user guide for PIDtoolbox. The wiki is divided into 4 main parts based on the main functions (1) Log viewer, (2) Spectral analyzer, (3) PID error analysis tool, and (4) Step response tuning-related tool.

(1) Log viewer

(2) Spectral analyzer

(3) PID error analysis tool

(4) Step response tool

Real world examples

E.G. (i) Mid-throttle oscillation

'Glen' posted a log file (A) to the Betaflight BlackBox Log Review Facebook group: (Betaflight BlackBox Log Review Facebook group) describing a vibration issue with his copter. He then made some changes to the PIDs and filters and reposted a second log file (B). I imported each log file (.csv) using the select buttons, then clicked load+run. Below is a screenshot of the main results, with line plots of flight data on the left (gyro filtered and unfiltered lines selected), and spectrograms on the right. Test A and B are coded orange vs blue, respectively, and the orange/blue shaded regions indicate the window of the data used for subsequent analysis (these windows can be adjusted from the control panel on the right). If you click within the white region of any of the line plots, it expands to facilitate viewing and control with the zoom tools. Now based on the full spectrograms (heatmaps below), the post filtered Gyros (right panels) look relatively clean in both test flights A (upper) and B (lower).

Using the drop down menus and <100Hz check boxes in the control panel, I then selected the specrograms to compute sub-100Hz throttle x freq plots for set point and PID error, then clicked the refresh button to recompute the new spectrograms (see plot below). I know, you're thinking "why are you plotting set point?" Since set point is RC input in deg/s, the freq spectrum of set point is a good measure of the range of frequencies associated with commanded motion. Theoretically, anything above this is uncommanded motion (i.e., stuff we don't like, such as mid-throttle oscillations, propwash, etc.). PID error is the difference between set point (commanded motion, or what we ask the copter to do) versus the gyro (actual motion, or what the copter actually did). The horizontal red and yellow dashed lines on the spectrograms demarcate this region (which, incedentally corresponds with the cutoff used in UAVtech's filter calc tool. Now, when we look at the spectrogram of PID error (right panels), we see a clear band of activity around 40-50Hz in the mid-to-upper throttle range, mainly on roll and pitch for test A, and less so for test B (despite the fact that the full spectrum looked clean for both!). To corroborate this, we can see clear oscillations in the Gyro and PID error traces blown up on the left, with peaks ~22ms apart (which is 45Hz!). Remember, this was not obvious when viewing the full spectrum.

To go a little further, we can plot the mean absolute value of PID error as a function of throttle (see below). For these plots, we window the analysis to flight data where the set point remained relatively low (100deg/s; see max stick deg/s window in the control panel), to minimize the potential confound of large error induced by fast flips/rolls (fortunately, snap flips/rolls usually occur at min throttle, so it's actually not a major issue here). In agreement with the earlier spectrogram data, you can see a systematic increase in mean |PID error| starting around mid-throttle, particularly for roll in test A (orange bars). From these results, it's clear that the adjustments made in test B were an improvement over test A. So we're on the right track!

E.G. (ii) Propwash

This past summer I was asked by Mark Spatz (UAVtech) to compare propwash handling between 1k and 8k pid loop rates, on the same copter with identical settings with the exception that the 1k setup did not have the dynamic notch active. Thus, the 1k setup had a minor disadvantage in terms of potentially more motor-related noise (though a potentially steeper lpf cut @ lower loop rate (for example); see fig at the beginning of this document for pre- vs post- filtered gyro of this data), but this was offset by an advantage of having lower total phase latency (3.01ms vs 3.71ms for A vs B, respectively, abbreviated as PsD-A and PsD-B in the lower portion of the control panel; side note, phase latency is computed directly in PIDtoolbox via cross correlation between filtered and unfiltered gyro and dterm). Some time ago I posted an HD video (Propwash Video Test) of both flights on the Rotor Riot Facebook page, and then polled observers to decide which one showed less propwash in a blind test. Turns out more people chose test (1) (but not all). See if you can guess which one that corresponds to in the following results of both flights:

In this case we are plotting the spectrograms only (Test A left and Test B right) for sub-100Hz PID error and motor sigs 1 and 2. Test A shows less activity in the 20-90Hz window in both PID error and the motor 1-2 signals (the same was true for motors 3-4, not plotted here). For test B, there is a bigger 'blob' of activity above the red dashed 'commanded motion' line, indicative of more vibration/propwash. Incidentally, it turns out that flight (1) in the video corresponds to Test data A here. It's also worth noting that these spectrograms are normalized such that the amplitude spectrum is unaffected by the length of the file/flight, which makes it more of an apples-to-apples comparison. This shows the novelty and value of being able to plot spectrograms across different kinds of blackbox data (the noise was especially noticeable on the motor outputs). PIDtoolbox gives you the option to easily plot spectrograms for several other variables, change the heatmap scale, and select from a list of color maps.

I hope you find PIDtoolbox useful, and I welcome feedback from the FPV community.

Cheers! -Brian

The spectral analysis than tuning per se, since filtering out vibration seems to be the number one concern. A major part of flight control software development has been devoted to filtering noise from the gyro, particularly in the ~200-500Hz range associated with motor vibration. From my analyses of blackbox data, I've noticed a consistent pattern between copters that fly well and copters that do not, specifically in the 30-90Hz range. Commanded motion is generally below ~20Hz (even if you're a 'Mr. Steele' on the sticks!), but elevated activity in the 30-90Hz range tends to correlate with the kind of vibrations we SEE during flight and in HD video (e.g., mid-throttle oscillation, propwash, jello). Although these frequencies can't be filtered out, a goal of PIDtoolbox is to use this as an objective measure of flight performance, to help the user decide whether a manipulation of software/hardware/mechanical settings was effective. I'll show some examples that support this idea. As always, the goal of a well-performing copter still requires reducing +100Hz noise, so PIDtoolbox supports the ability to plot the throttle x freq spectrograms that we've come to love about Plasmatree PID-analyzer, and extends this functionality to many other flight variables.

Clone this wiki locally