Profile image

A rather new approach to holding a value

1,139 zwen  2.8 years ago

Hey guys, I’ve been looking around the forum to search for all kinds of FT functions. And I saw a lot of people asking for ways to hold a value, such as bank angle or altitude. There’s been a commonly way using smooth(X, large number), but I think the approach can be easier. If this is not the first post about this method, I’m sorry but I did not notice any.

I found that sum() and rate() are not usually used in designs. However, based on the knowledge of calculus, sum(rate(X)) = dX. To make this useful, I tried to put in conditions such as:

sum(rate(Altitude * 1.9685 - Trim * 36) * clamp01(Activate1)) to achieve designated VS

Or sum(RollRate * clamp01(Activate1 & (Roll = 0))) to hold the bank angle

IMHO this system is reliable and easier to use than PID controls. Here is the plane I used to try out the controls: https://www.simpleplanes.com/a/3JXJml/Blue-Cow-w-AP
I haven’t actually tuned the numbers but they are already working smoothly. I’m also exploring things such as IAS hold with pitch and with throttle.

  • Log in to leave a comment
  • Profile image
    66.8k SnoWFLakE0s

    Smooth is a much better method for storing data--there's a good reason most of us are using it for a memory function. It is very flexible in terms of storing data, as it can change values instantly to a very specific desired value or reset to a default value instantly as well.

    2.8 years ago
  • Profile image
    16.4k edensk

    @zwen smooth(RESET ? RESET_VALUE : sign(INPUT) * 999999, RESET ? 9999999 : abs(INPUT))
    RESET is the condition in which it resets, in this case Activate1. RESET_VALUE would be 0, and INPUT would be what you put inside sum()

    2.8 years ago
  • Profile image
    1,139 zwen

    @edensk I do agree with you for the last part, but I do not quite understand how to use smooth to cancel out the last value. However, I just want to point out that the sum function can record a value based on the activation of another group, which means continuing a previous procedure even when disturbed by a sudden input.

    2.8 years ago
  • Profile image
    16.4k edensk

    You just made a PID without the P and D. Using the pid function and setting those two parameters to 0 would do the same thing. Also, You should use a smooth function that can be reset to zero instead of sum, as the sum function will keep its last value until it's reactivated

    2.8 years ago
  • Profile image
    28.6k ALTMTR

    Great, I will use it. Thanks.

    2.8 years ago