DataField: Advanced Grade (6 clones)

Advanced Grade is an app that eliminates grade (slope) jumps in Garmin Edge devices. It has many settings for flexible custom setup of the filtering of the grade. In addition it can display the max/min elevation and max/min pressure. All of the selected variables can be displayed with one decimal place. The default settings are chosen to ensure a balance between accuracy and fast response.

View on Connect IQ Store

In stage 1 the raw grade is calculated from the "Grade source" and the elapsed "Distance", then it's rejected if it's higher than the maximum allowable value. The remaining raw grade is filtered and if it deviates from its filtered value by more than the parameter "Max deviation", it's rejected. In stage 2, the remaining raw grade from stage 1 is filtered. So, for the lag, first you have to ride "Distance" metres for the raw grade calculation, then you need "Settling time" seconds for the filtering in stage 2. Additional "Settling time" seconds for the filtering in stage 1 is needed only at first start, or when the change in the grade is more than the max deviation for long time. For example: you ride +12 degrees uphill and after the grade is stabilized around this value, then immediately -12 degrees downhill for more than the sum of the settling times from both stages.

Configuration screens on Garmin Express:

Features:

Label
- the title of the datafield, maximum 20 characters.
Decimal point
- when switched on, the selected variables are displayed with one decimal place.
Separator
- the separator between the selected variables.
Reset on Lap
- what to reset, when "Lap" button is pressed.
- default value is "Max/min grade".
Max/min set time (s) [1 - 20]
- max/min values settling time.
- default value is 3s.
Grade (%)
- display the output grade from stage 2.
Maximum grade (%)
- display the maximum of the output grade from stage 2.
Minimum grade (%)
- display the minimum of the output grade from stage 2.
Elevation (m)
- display the altitude above mean sea level.
Max elevation (m)
- display the maximum altitude.
Min elevation (m)
- display the minimum altitude.
Pressure (hPa)
- display the ambient (local) barometric pressure, it's smoothed by a two-stage filter.
Max pressure (hPa)
- display the maximum pressure.
Min pressure (hPa)
- display the minimum pressure.

Stage 1 - Calculating the grade and rejecting its false values
Grade source
- grade calculation source, it can be "Pressure", "Altitude" or either of the two whose output is smaller in absolute value "Min (Press, Alti)".
- default value is "Pressure".
Distance (m) [1 - 100]
- traveled distance, based on which the grade is calculated.
- default value is 20m, my advise is to not set it below 10m.
Max limit (%) [1 - 100]
- if the grade is higher than this value, it's rejected
- default value is 30%, you can change it depending on the maximum grade you will be climbing.
Max deviation (%) [1.0 - 20.0]
- if the grade deviates from its filtered value by more than this parameter, it's rejected.
- default value is 4.0%, my advise is to not set it below 2.0%.
Filtering mode
- this filter is used in combination with "Max deviation" to reject the false values of the grade.
- moving average and 2-nd order Bessel filters are applied to the signal, the one whose output is smaller in absolute value is chosen.
- default value is "Min (MA, Bessel)".
Settling time (s) [1 - 20]
- the settling time of the filters.
- default value is 4s, my advise is to not set it below 4s.

Stage 2 - Filtering the remaining grade values from stage 1
Filtering mode
- moving average and 2-nd order Bessel filters are applied to the signal, the one whose output is smaller in absolute value is chosen.
- default value is "Min (MA, Bessel)".
Settling time (s) [1 - 20]
- the settling time of the filters.
- default value is 8s, my advise is to not set it below 4s.

Debug - Write to FIT
- the selected grade values will be written to the FIT file: S1 input (%), S1 output (%), S2 output (%) are represented as s1_inp s*, s1_out d*t*, s2_out t* respectively, where s* is the grade source, d* is the max deviation and both t* are the settling times of the filters in stage 1 and 2 respectively.
S1 input (%)
- write the input grade of stage 1.
S1 output (%)
- write the output grade from stage 1.
S2 output (%)
- write the output grade from stage 2.

Changelog:

Version 1.7
In stage 1 is added option for grade calculation source.
In the debug section, the grade values can be written to the FIT file.
---
Version 1.6
Fixed issue with elevation not showing in some cases.
---
Version 1.5
Added settling time for max/min values.
Added new filter, which is combination of moving average and 2-nd order Bessel.
In the debug section is added option to save grade values in the FIT file.
Raw pressure is removed from the debug section.
---
Version 1.4
The three stages are combined into two.
The filtering algorithm is changed to exponential moving average.
The default settling time of the filter in stage 1 is decreased to 4s.
Some parameter names and ranges are changed.
- - -
Version 1.3
The history buffer for calculation of the raw grade is increased.
- - -
Version 1.2
Now max/min elevation is calculated only during activity.
- - -
Version 1.1 is the first official release.

  • Looks interesting. I have a few questions. What happens if a grade is rejected? Does the next grade estimation somehow account for this? How far can you reduce the lag without running into excessive noise? On a 530, the standard noise-free grade has a lag of about 8 seconds, so I am curious if you can go substantially lower. Would you be interested in making your estimation technique a Monkey barrel that (for some form of compensation) can be introduced into other apps?

  • The raw grade is calculated from the change of the raw pressure over the elapsed distance "Distance (m) [0 - 200]". In stage 1, you reject the calculated raw grade when it's above "Limit (%) [0.0 - 100.0]". In stage 2 you calculate the moving average of the output grade from stage 1. This average value shows the tendency of the raw grade, when the raw grade is too far from the tendency, it's rejected. Too far means if the difference between the tendency and the raw grade is more than the "Deviation (%) [0.0 - 50.0]". In stage 3 you average the valid raw grade from stage 2, to stabilize the signal. So, for the lag, first you have to ride 20 metres for the raw grade calculation, then you need 8 seconds for the grade averaging in stage 3. Another 8 seconds for the tendency in stage 2 is needed only at first start or when the change in the grade is more than the Deviation for very long time, for example: you ride +15 degrees uphill and after the grade is stabilized around this value, then -15 degrees downhill for more than 16 seconds, when the grade will be stabilized around the new value. Of course you have full freedom to change what you want, but i made a lot of tests and the default settings seems to me the best choice. I tried some low pass filters, but the results are worse. By the way, if you go to the debug options and check to display the "Raw grade (%)", you can see what mess is there, specially if some wind blows over the computer or if you shake (push) it a little harder with your hand ;) On my 1040 when it's on the mount and i shake (push) it, in some cases the raw grade can go between +150% and -150%! I can try to do the barrel, it's a good idea. I will wait some time to see which is the best algorithm and how are the reactions. I think to try Butterworth filter soon, i will implement it if it has good results.

  • Version 1.2
    Now max/min elevation is calculated only during activity

  • Version 1.3
    The history buffer for calculation of the raw grade has been increased

  • Version 1.4
    The three stages are combined into two.
    The filtering algorithm is changed to exponential moving average.
    The default settling time of the filter in stage 1 is decreased to 4s.
    Some parameter names and ranges are changed.

  • Using exponential moving average for grade smoothing seems to work much better than other low-pass filters. Response feels both stable and quick enough for steep climbs and descents.

  • Version 1.5
    Added settling time for max/min values.
    Added new filter, which is combination of moving average and 2-nd order Bessel.
    In the debug section is added option to save grade values in the FIT file.
    Raw pressure is removed from the debug section.

  • Version 1.6
    Fixed issue with elevation not showing in some cases.

  • Version 1.7
    In stage 1 is added option for grade calculation source.
    In the debug section, the selected grade values will be written to the FIT file.