Preventing Simultaneous Double Triggers

startec's icon

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?

Peter McCulloch's icon

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.

Wetterberg's icon

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.

startec's icon

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

Wetterberg's icon

>@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

startec's icon

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.

Wetterberg's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

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

brendan mccloskey's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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.

Brendan

Wetterberg's icon

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

brendan mccloskey's icon

Ah, well-spotted Andreas

brendan mccloskey's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Sorted:

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

startec's icon

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.

Francois Weber's icon

hi,

Max Patch
Copy patch and select New From Clipboard in Max.

like that :

brendan mccloskey's icon

The hearts indicate how many threads one has "favourited"