1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

How to compare by a percentage range?

Discussion in 'REAKTOR' started by Michael O'Hagan, Feb 9, 2021.

  1. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    I've got a situation where I need to compare the current value against the last value, and if the difference is more than %10 of the overall value range then I need to activate a smoother.

    I can't quite seem to find a method for comparing based upon percentage of difference.

    Does anyone know a way to do this?
     
  2. ANDREW221231

    ANDREW221231 NI Product Owner

    Messages:
    875
    uhhh.... multiply the value range by .1?
     
    • Funny Funny x 1
  3. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    Thank you dude, I'm so deep into this project that I can't see the forrest through the trees, my brain is halfway shut down and I'm having trouble with some of the simplest things.
     
  4. Catman Dude

    Catman Dude NI Product Owner

    Messages:
    761
    In situations like this I decide it's time to take a walk, leave the project alone for a day, let my thoughts wander too -- a lot of these things will solve themselves while putting my mind on something, anything, else -- snow falling for example on the local landscape... ;)
     
    • Like Like x 2
  5. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163

    Here is a pic...

    Router Setup.png

    So the to router is set to compare against the previous sample and anything more than a %5 increase equals a true value out of the compare module.

    The lower router is doing the same but with anything below a %5 drop in value.

    Both of these are working fine, but I need both to be active at the same time.

    If I try to merge them then one is always sending out a 1 and the other is always sending out a 0.

    If I try to route them in series then the second one becomes the deciding factor as to whether we get a zero or a 1 and the first one has no impact.

    How to I arrange some routers so that when a new value comes in it is checked against the last sample value and compared to a +/- %5 range.

    anything within that +/- %5 should output a 1 and anything outside that +/- %5 window should output a zero.

    I've tried multiple router configurations and none of them have worked.

    Thanks
     
  6. colB

    colB NI Product Owner

    Messages:
    3,969
    5% of what? What is the range?
     
  7. Catman Dude

    Catman Dude NI Product Owner

    Messages:
    761
    It's early but I'll take a shot at it.
    I think you do them in series, but don't have to execute both of them each sample.
    The logic is like this: if you exceed your range on the first compare, you output a '0' and don't need to make the second test. If didn't exceed your range on the first you don't send out a '1' but rather now need to test the second, and it becomes the 'decider'.
     
  8. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163

    The range is 0-1 and I need to be able to compare against a variable range, like the last value was .6, is the new value greater than .7 or less than .5.
     
  9. colB

    colB NI Product Owner

    Messages:
    3,969
    So the range is 0..1...

    If the previous value is 0.3, then if the new value is between 0.25 and 0.35 you want an output of 1 otherwise 0?

    within range.PNG
     
    • Like Like x 1
  10. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163

    This is why I appreciate this forum so much, I totally forgot to rectify the value, I was trying multiple stages of compares, like is it less than first, and then sending it to a second stage for greater than and so on, and it just wasn't working.

    Such a simple and perfect solution, thank you.
     
    • Like Like x 2