False trigger on "==" object


#1

Have a problem with some objects I am connecting up.
I have 8 switches connected to analogue input with resisters to divide up the voltage so I get a different reading for each. This works fine. Then as the value arrives in, I divide it by 8, round off to the nearest whole number then output the value. In the image you will see a "3" circled confirming switch 3 selected.
The value is then converted into an integer, passed to a math "==" object where is it compared to a constant being "1". If the switch and constant match, the boolean output is supposed to rise and trigger the toggle object either true or false as its final output. But as you can see by the image, 3 and 1 don't match yet the toggle is still triggered true, in fact it triggers true with the other switches too. The only object I have modified the code in is the analog input, and there do not appear to be any issues there. So I cannot work out why the toggle is triggered when the numbers do not match. Thanks for any help you can offer.

Patch as follows..
analog switch5.axp (6.3 KB)


#2

Start by adding disp/i and disp/bool objects after all objects. May be easier to find out what's going wrong. Another thing your can try is moving objects to a different place, as execution order can also influence values.


#3

I think the signal from pressing button "3" quickly rises through value "1" causing the trigger. The solution is to prevent triggering the toggle when a value only occurs for one cycle.


#4

Thanks @Johannes,
That makes a lot of sense, I'll apply a delay with Timeri object, once it passes a certain krate value, the values will pass through.

Thanks @janvantomme,
I have read in other post this method fixing issues, about time I give it more consideration.


#5

Solution worked. Moded a Timeri object, once the trigger rises, it counts 200 krate cycles before taking a reading. It only takes the reading once and holds onto it until the the inlet returns to 0.