Grade Calc: Code Details

After a lot of testing on my EDGE 1050, I think I'm finished optimizing the Grade Calculation. This is the field that implements the algorithm. I'll provide the full source code soon, with detailed comments on the logic.

For now, if you'd like to try it, it includes some diagnostic values and writes some data to the FIT file for post-activity assessment.

There is a lot more involved in the metric, but at the high-level I've found that generating three grade candidate values (average, median and least squares) over a FIFO depth of 11 elements (that is user settable), and then taking the central value of those three, I get a value that is often better than the built-in native grade value. I handle various other conditions. For example, quick deceleration often throws off the value (even the built in grade), so I detect and handle that.

The data field shows the three grades calculated from the FIFOs (A/M/L). And the Raw (instantaneous) grade. I also keep track of how many times each of the candidate values was central. I show if your FIFO is filled (it is reset when stopped and has to refill).

The counts are stored as a FIT String. I found it interesting that each of the three methods were used a significant number of times.

The GRADE graph shown here was my last ride. I've since implemented a smoothing function that makes the Grade Graph look better. I've zoomed into a 0.4 mile climb called Sugarloaf in Clermont, Florida. The actual grade does increase to about 12% then levels off at about 8-9%, then drops back to flat at the top. The smoothed data in the latest version looks great. This graph jumps around a bit as the best candidate jumps between Avg, Median and LS. You can overlay my Elevation Data and my Grade data and then zoom into particular sectors to see how it works. My Elevation graph in the Garmin Connect activity is much better than the default Elevation graph since Garmin doesn't auto-zoom the vertical axis to show the undulations with enough resolution.

Here is the field: https://apps.garmin.com/apps/f0ddadf0-4eb1-41fc-ae62-3b94575109ab

If you try it and have feedback, please let me know. I'll test it a few more times, make final revisions (based on my tests and your feedback), and release the code. You can e-mail me at: [email protected]