Arduino to Max - contact mic knock sensor - Too much data.

Noisey Parker's icon

Hello,

I am using a pre-made patch called Arduino2Max, and using a contact mic to create a crude drum pad. I have a few problems.

1- it only creates a data when I remove my finger from the pad, not the actual contact hit.

2- It creates lots of pressure data rather than just a single hit.

3- It is aways fluctuating at a low level so constantly producing data.

is there away to filter the data, so it only begins reading at a certain level? And to switch so it is the initial contact that creates the data. and maybe to filter or compact the data, so it takes the highest number of any given burst of data?

I have included the patch, many thanks for any help on this

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

brendan mccloskey's icon

Hi
are you confident enough to hack the Arduino2Max code? Becuase I don't think you can solve this in Max alone - so we would need to see both the circuit and the part of the Arduino code that is doing the reading and sending. If you're using a piezo, remember they are polarized (ie, there's a right way and a wrong way to connect them):

1- can't solve this in Max (or Arduino) as neither program can see into the future; use Serial.println(yourSensorValueVariableHere); in the Arduino sketch to see exactly what is coming off the sensor

2 and 3- use either the map and constrain expressions in Arduino to scale and limit that data or use [>] and [togedge] in Max.

Brendan

ps, there is renowned programmer/composer on this site who has done fantastic stuff with, amongst other things, a piezo and he's great at sharing ideas......his name's on the tip of my tongue......anyone else help?

Brendan

brendan mccloskey's icon
Noisey Parker's icon

thanks, you were right about the polarity, that has solved the on / off the sensor trigger problem. I still have a problem with the amount of data produced.

I got rig of the fluctuating low level data with a gate based on > 20 so that the very low data is screened out.

I am going to try and create a gate of about 5/10ms that only lets through one hit every 10ms interval. ie the first hit, I don't think this is perfect thought. Maybe only let one hit though before it has to return to a certain level before it is active again?

Thanks for you help, it really got me thinking. If you have any ideas of how to screen out subsequent data after the initial hit I would much appreciate it.

Simon's icon

Sounds like you might not have an appropriate resistor in your circuit.
Like this :-

balam's icon

I agree with Simon
a 10K resistor to ground and analog filters nice,
In my exp. a 50k resistors works even better,