Profile image

Code that displays time since certain condition has been met?

133 MrCacahuate  1.8 years ago

HI !

Im fiddling with manual prop engines, I want to create a gauge that alerts you that you've reached a critical RPM.

I noticed that the engine breaks based on: time maxRpm has been achieved rather than: Current RPM is X times greater than maxRPM.

So, after doing some experiments I've determined that the engine breaks 11 seconds after the limited is exceeded:

RPM has been > maxRPM for 11 seconds? Yes: engine breaks. In other words.

First I tried:
(RPM1 > maxRPM) ? Time : 0

This does not work since Time is measured since the level has started.

I Figured the following:
(RPM1 > maxRPM) ? sum(rate(round(Time))) : 0

This basically does: okey so since time always increases at the same rate it always outputs 1 and sum counts how many 1 I have.

Esentially it counts time from 0 to x regardless of the time the level has been active. My problem is that if say you've returned to a safe RPM after 8 seconds, the next count will start at 8 breaking the engine esentially when 19 seconds are reached rather than 11.

Help pls c:

  • Log in to leave a comment
  • Profile image

    so... How are you trying to achieve this "warning"?
    Through texts, mayhaps? or lights?

    nvm, I understand now, kinda

    lemme get this straight
    you want to make a warning about the rpm overspeed by stating how much time it has spent in it's overspeeding state, and you want it to count from 0 again when it reaches safe rpm before it spent 11 seconds in it's overspeed state?
    in that case

    smooth(RPM1>maxRPM, (RPM1>maxRPM ? 1/11 : 1)) should work

    need explanation?
    so, RPM1>maxRPM should've been a boolean, right? But a boolean is also a value. True is essentially just 1, and False is 0.
    smooth(x, l) is essentially forcing the value to go through a rate, instead of instantaneously turning into the value it's supposed to be, whether it activates or deactivates.
    to combat this, use the "if" format on the l part of smooth(x, l). If it reaches the maxRPM, it'll smoothen out the code. If it returns to a safe RPM after it oversped, it'll instantly return to 0 because you're not limiting it's rate of change, aka matching the same max rate as it's max value.
    if you don't want the final value to show up as 1, then add *11 at the end of the code.

    Pinned 1.8 years ago
  • Profile image

    @ZeroWithSlashedO LMAO never mind my previous comment, it works like a charm Thanks so Much!

    1.8 years ago
  • Profile image

    @ZeroWithSlashedO With a 0 to 9 gauge where the indicator multiplier is equal to 36 because I want it to point at 0 when 10 seconds have passed.

    I've developed a new code but I cant get the last part to work, it goes as follow:

    RPM >= maxRPM ?
    If no, then: 0
    If yes, then: Okay, are you returning to a safe RPM number in maximum 10 seconds at the current amount of RPM at the current RPM rate?
    If no, then: assign the value 10 but start at 0 and increase 1 for every second passed
    If yes, then: Solve for seconds in the previous if statement

    My code looks something like this:

    RPM1>=3000 ? ((RPM1 + 10*rate(RPM1))<=3000 ? (3000 - RPM1)/rate(RPM1) : smooth(10,1)) : 0

    1.8 years ago