Trough just puts out zero


    May 27 2017 | 3:45 pm
    Im trying to get the range of an accelerometers values for scaling - this can change with diffent devices/accelerometrs so I am feeding a scale/zmap object with values from peak and trough for the high and low input values. Peak works fine but trough just seems to put out zero even though the values dont drop below 200 . Ive tried using ZL to filter out zeroes and even put accelerometer data through a switch that doesnt turn on till data is already streaming - but Im only getting zeroes from trough. Any ideas ?

    • May 27 2017 | 5:10 pm
      Check out in Max the Extras Menu -> Examples Overview -> Max -> Interface -> sensor-tamer.
      (Also if you want someone to look at your code, maybe paste some compressed code.)
    • May 28 2017 | 9:02 am
      minimum/maximum are perfect replacements for peak
    • Jul 26 2019 | 7:47 pm
      I have exactly this problem, I have spent hours trying to get it to work but trough just refuses to output any data. Minimum also doesn't work, it just outputs zero. Is there any other way for getting the range of data?
      Thanks!
      Michiel
    • Jul 27 2019 | 11:25 am
      If You don't understand how trough object works, then You can spend not only hours, but days trying to get it "work". So what are You trying to do ? If You ask such questions, like "I can't get this object to work" without giving details, no one can figure out what mistake You are doing.
    • Jul 27 2019 | 12:07 pm
      @source audio The problem I experience is the same as explained it in the first post (which is why I said "I have exactly this problem") namely I am trying to get a range of incoming data for scaling. For this I use trough and peak. The peak is working just fine, but the trough object doesn't. I now kind of fixed it by using "if $f1 <.... " and feeding that into itself.
      For a more detailed explanation: I have 10 digit numbers coming in that vary in the last 4 digits. I want to scale this to an audio range. I'm quite new to this so I'm not sure if I'm making sense.
      All the best
    • Jul 27 2019 | 12:38 pm
      Trough object is tricky beause it works a bit different than "usual" max objects, it does not check if value received in left inlet is lower than last received value, but last received value has to be set as argument or received in second inlet. So if You want to pass a value only if it is smaller than last value, You have to send output to right input with a bit of delay, preferably using pipe object. But is that what You need ?
      I still don't understand exactly why should one need to use peak or trough or anything else to scale 4 digits ? If You say "scale range of incoming data" does that mean that You want to scale data only if within range, but pass the rest as is ? split object could do that
    • Jul 27 2019 | 1:47 pm
      Hi Michael, I got round this in the end. I cant remember exactly what it was but if I remember rightly I was getting some weird floating values issues from the sensor ("nan" etc) because I was getting a float - if your getting float values it sometimes helps to convert them into integers wiping away the potential for infinite floating point values - so I just multiplied the incoming data by 100 ( (or in your case 100000 whatever) ) and put it into an integer number box Yoiu can scale as needed after that.