Trough just puts out zero

Augustine Bannatyne - Leudar's icon

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 ?

Jean-Francois Charles's icon

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.)

Roman Thilenius's icon

minimum/maximum are perfect replacements for peak

Michiel Deprez's icon

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

Source Audio's icon

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.

Michiel Deprez's icon

@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

Source Audio's icon

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

Augustine Bannatyne - Leudar's icon

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.