Forums > MaxMSP

Preventing Simultaneous Double Triggers


Sep 15 2013 | 3:14 am

Hello All,
I use an arduino board, which I have made into a custom trigger-er, using Maxuino. One issue I am having is "double" or even more events (toggles or bangs) happening when I push a button on the arduino. My board has a button and when I press it, sometime it will go from 0-1 multiple times. I was going to use a onebang with a delay to make sure only one event was triggered per button push, but, that does not seem to work. I made a timer that showed the time in between the double triggers and they happen at exactly the same time (to the ms). Any ideas on how to filter out the extra "presses" if they happen at exactly the same time?

Sep 15 2013 | 10:46 am

They can’t be happening at the exact same time if they’re coming in in serial. You could use the timer object and a threshold (>) to determine whether or not to pass an event. (Using gate)

Do something like:
Input
t i b b
(Both b’s connected to timer). Output of timer into > 100, that goes into left inlet of gate.
i goes into right inlet of gate.

Alternatively, check out qlim and speedlim.

Sep 15 2013 | 11:02 am

Just to clarify, are you getting like:

0
1
0
1
0
1

Or:

0
1
1
1
1
?

Because if it’s the latter, change or zl.change will be helpful.

Sep 15 2013 | 4:28 pm

Unfortunately it is definitely the former. @Peter, they are indeed coming in serial, as this is input from an arduino board from the serial object (how did you know that?)

Sep 15 2013 | 5:15 pm

>@Peter, they are indeed coming in serial, as this is input from an arduino board from the serial object (how did you know that?)

All comms with an arduino board is serial, as far as I know. And serial information means that things don’t happen at the same time, even though you’re having trouble measuring the timing.

This is good, though; this means that you can gate your way out of a lot of issues. Buuuut have you started here?
http://arduino.cc/en/Tutorial/Debounce

Sep 15 2013 | 5:47 pm

Yes, I have already looked at debouncing. The issue with that is that Maxuino uses the Firmata sketch, and I am not yet good enough to edit Firmata to add the debouncing feature.

Sep 16 2013 | 5:46 am

ah, shoot. Well then let’s do patched debouncing, right?

Just hacked this together, I’m so sorry if there are better ways of doing this, hehe.

<code>
-- Pasted Max Patch, click to expand. --

</code>

Sep 16 2013 | 7:52 am

Here’s an alternative; but I think Wetterberg is right: debouncing the source is better, even though you don’t describe what type of button/switch you are using. If you are using only one or a few of these, Maxuino is kind of overkill.

<code>
-- Pasted Max Patch, click to expand. --

</code>

Brendan

Sep 16 2013 | 8:08 am

Note that Brendans code assumes that you can tell "actual zeros" from "bounce zeros".

Sep 16 2013 | 8:53 am

Ah, well-spotted Andreas

Sep 16 2013 | 9:01 am

Sorted:

<code>
-- Pasted Max Patch, click to expand. --

</code>

But if you press your button DURING the mechanical noise then this algorithm will fall over also.

Sep 16 2013 | 8:38 pm

Thank you both very much. I am sure both solutions would have worked but I went with Wetterberg’s because I understood it a bit better. It has almost solved the problem. I say almost because there are sometimes still a few double triggers. (I am using the switches to trigger things in Ableton Live and elsewhere).

I am using a few different switches. Conductive carbon ones like you see on a remote control and, to prototype, I am just inserting a jumper cable and pulling it out.

I realize that neither are good buttons, but I have no choice for the conductive carbon and I want to make sure that my patch is as bulletproof as possible.

If I can figure out what those hearts are under your names, I would heart you both.

Sep 17 2013 | 12:02 am

hi,

like that :

<code>
-- Pasted Max Patch, click to expand. --

</code>

Sep 17 2013 | 2:45 am

The hearts indicate how many threads one has "favourited"

Viewing 14 posts - 1 through 14 (of 14 total)

Forums > MaxMSP