Data Field: AppBuilder

By user request, this app lets you define your own data field, based on a simple math formula like cadence / 2.

If you want to get fancy, there's conditional expressions (like IF in Excel), functions for data analysis (like MIN and AVG), and the data field can also display the text of your choice. The resulting data can be (optionally) written to the activity FIT file.

With AppBuilder, you can implement almost any field that involves math, such as: calculating normalized power and saving the data to the FIT activity file, showing the average pace for even-numbered laps, or recording the amount of time you sprinted.

Full documentation and examples here:
http://ciq-appbuilder.blogspot.com/

AppBuilder 5:
Now with new features! AppBuilder 5 is a completely new app, so please check it out in the store if you are interested in any of the new features.
https://apps.garmin.com/en-US/apps/fd690281-9c22-4fee-a81e-3b7f39aa67c5

- Store up to four formulas per app. Switch between formulas directly on the watch, without using a phone or PC. With four clone apps, you can store up to 16 formulas total
- User variables. Allows for powerful formulas where information can be stored at one point, like the start of a lap, and used later. e.g. Lap elevation change
- Improved timeavg() options. Allows for simpler, more flexible normalized power function
- More functions and variables

4 clones of AppBuilder are available in the store, so you can have 2 formulas in the same activity
  • Hi. I’m wondering if anyone could help with a formula to calculate Lap W/Kg?
    I find that Lap avg Power is great for climbing efforts, but would also like to have Lap w/kg as it is probably a more consistent stat than W where weight may vary.
  • Former Member
    Former Member over 5 years ago
    LAPAVG(Power/UserWeight)
  • Following site has a quite complete formula for cycling power:

    https://www.gribble.org/cycling/power_v_speed.html

    AppBuilder doesn't have trigonometric functions, but seems you can simplify the formula by removing them altogether (SIN(ATAN(x)) hardly changes the grade value and COS(ATAN(x)) will always return close to 1) and it will still give very close to similar values (at least quick values I tested in excel at different speeds / grades).

    (1-(2/100))^-1*(9.8067*(UserWeight+10)*(GETV(1)+0.005)+(0.5*0.63*0.509*1.22601*Speed_raw^2))*Speed_raw

    In the example set weight of bike at 10. Also you could tweak the other constants, I just took the default values from the site. GETV(1) is for grade so you can use SETV(1, insert grade formula here) ; Or replace it with full grade formula.

    Note that if you go downhill you will get negative power at some point. Might be a good idea to add logical operators for example if cadence is 0 then power is 0. Also if power is less than 0 then power is 0.

    Didn't get that far yet, but it's a good starting point to experiment with. Also didn't test it, so sorry if doesn't work yet. Will maybe test it tomorrow on trainer if I got time.


    Hi JYH9
    excuse me..i saw only now your message.
    Can be good solution, but i don't understand if i must use GETV(1) or put:

    .....+10)*(SETV(1, IF(Speed_raw GTE 1, TIMEAVG((Altitude_raw - PREVN(Altitude_raw, 14,1)) / (Distance_raw - PREVN(Distance_raw, 14,1)) *100, 3), 0))+0.005)....

    thanks for now
  • BortoloS He's saying that you could choose either way, depending on your preference. You also have to remove "*100" from the grade formula, as you need it in the form of a ratio from 0 to 1, and not a percentage from 0 to 100.
  • Former Member
    Former Member over 5 years ago
    In AppBuilder5+ you might also want to use SETGLOBAL so that the variable is used by all the fields as SETV can be only used by the same field. You probably even cannot fit both grade and power formula in the same field. Remember that after setting a variable you can still use the same field to display something else, by adding ; and the value you wan't to display. Or you can set several variables, only the last one will be shown.

    Here's one possible working example - first set global variable for grade:

    SETGLOBAL(1, IF(Speed_raw GTE 1, (Altitude_raw - PREVN(Altitude_raw, 14)) / (Distance_raw - PREVN(Distance_raw, 14)), 0))

    Then set a variable for power calculation, and after that set a global variable with logical operator to only display positive power values and when cadence is over 0 (if you pause pedaling for example you might still have speed left to incorrectly show power while your legs aren't moving), otherwise power will be 0:

    SETV(1,(1-(2/100))^-1*(9.8067*(UserWeight+10)*(GETGLOBAL(1)+0.005)+(0.5*0.63*0.509*1.22601*Speed_raw^2))*Speed_raw) ; SETGLOBAL(2,IF(GETV(1) GT 0 AND Cadence GT 0, GETV(1), 0))
  • Former Member
    Former Member over 5 years ago
    Now you have a global variable that you can use just like native Power. So for example to display and record power you could use:
    RECORD(GETGLOBAL(2),7)

    To display average power and lap power
    AVG(GETGLOBAL(2))
    LAPAVG(GETGLOBAL(2))

    To display NP and lap NP
    AVG(TIMEAVG(GETGLOBAL(2),30,1)^4)^0.25)
    LAPAVG(TIMEAVG(GETGLOBAL(2),30,1)^4)^0.25)

    As for power accuracy, your results may vary. I noticed that power was a bit lower than my trainer at low speeds, but at high speeds it was noticeably higher.

    There are probably other more accurate formulas and I can't really test this on a road bike currently. So it may work satisfactory or not work at all. This was just the first one I found that had all the necessary bits to translate to AppBuilder formulas without too much work.
  • I have used this formula, but i obtain negative values:

    (1-(2/100))^-1*(9.8067*(UserWeight+10) * (SETV(1, IF(Speed_raw GTE 1, TIMEAVG((Altitude_raw - PREVN(Altitude_raw, 14,1)) / (Distance_raw - PREVN(Distance_raw, 14,1)), 3), 0))+0.005)+(0.5 * 0.63 * 0.509 * 1.22601 * Speed_raw^2)) * Speed_raw

    now i try SETGLOBAL solution.
  • Former Member
    Former Member over 5 years ago
    You don't need SETV if you place grade calculation inside the same formula. You only should use SETV with GETV if you have repetitions of same formula and want to save space by sharing the formula as a variable. SETV / GETV works within one field and SETGLOBAL / GETGLOBAL with multiple fields of same instance.

    I highly recommend to learn to use variables though, as this will allow you for more flexible use within separate fields in AppBuilder5+
  • In AppBuilder5+ you might also want to use SETGLOBAL so that the variable is used by all the fields as SETV can be only used by the same field. You probably even cannot fit both grade and power formula in the same field. Remember that after setting a variable you can still use the same field to display something else, by adding ; and the value you wan't to display. Or you can set several variables, only the last one will be shown.

    Here's one possible working example - first set global variable for grade:

    SETGLOBAL(1, IF(Speed_raw GTE 1, (Altitude_raw - PREVN(Altitude_raw, 14)) / (Distance_raw - PREVN(Distance_raw, 14)), 0))

    Then set a variable for power calculation, and after that set a global variable with logical operator to only display positive power values and when cadence is over 0 (if you pause pedaling for example you might still have speed left to incorrectly show power while your legs aren't moving), otherwise power will be 0:

    SETV(1,(1-(2/100))^-1*(9.8067*(UserWeight+10)*(GETGLOBAL(1)+0.005)+(0.5*0.63*0.509*1.22601*Speed_raw^2))*Speed_raw) ; SETGLOBAL(2,IF(GETV(1) GT 0 AND Cadence GT 0, GETV(1), 0))


    I think to have understand..

    thanks JTH9!!!
  • Former Member
    Former Member over 5 years ago
    I did a quick test with trainer in ERG mode at 200 and 400 watts on 7% and 0% grades running a simulation (Road Grand Tours Beta) and the resulting speeds were surprisingly quite close to this formula (within 1-2kph).

    I also got trainer speeds to closely match up to 700W or so after I did a quick test with reduced drag and added rolling resistance, which kind of make sense when you consider the trainer is basically braking the wheel and lacks wind resistance so the calculated speed values are not that realistic in the first place (which is often the case with trainers). So at low wattage the trainer shows slower speed and and at high wattage faster speed than you would get in reality.

    All in all I'd say so far the formula seems like it might even be worth trying, but of course the final test is on road (have to wait until summer on my part). And you might still have to consider general Garmin GPS and altimeter accuracy isn't the best around. :)

    PS. One more thing I remembered - if you don't have a cadence sensor, you might want to remove the "AND Cadence GT 0" from the formula. Otherwise the power will be left at 0.