Sound detector to detect hammer strikes

Gramps

Senior Member
The dulcimer project is coming along very nicely but we are still trying to find and utilize a good input sensor.
At this point copper pads on the Hammers are moving the input pins High when they connect with the metal strings on the instrument. The wires on the Hammers are really a nuisance.
So we're going to head in the direction of sound detection.
This little gem came in the mail yesterday:
SparkFun Sound detector s e n - 12642
20190110_143128.jpg

I couldn't find any reference on the Forum using search.

By the way, we found the problem with the accelerometers. A loose connection on the power supply!
Any comments or suggestions to get me up and running with my new toy would be greatly appreciated.
Thanks, Gramps
 
Last edited:

Gramps

Senior Member
Thanks, RNovember,
I'm at one foot above sea level coding in picaxe and rising out the plain i see a mountain with a sign pointing up saying "This way to C"
 

RNovember

Well-known member
Are you trying to sense if the right note is being played, or if any note is being played?

If you want to sense if the right one is being played, you could hook the raw sound out to a frequency counter, and have that send the frequency of the note to the picaxe.

You could hook the binary indicator to a pin of a picaxe so it knows when to look for an input from the frequency counter.

I don't know if this would be practical, but it would be fun.
 

lbenson

Senior Member
Any comments or suggestions to get me up and running with my new toy would be greatly appreciated.
Basically the same as with the accelerometer--perform READADC in a tight loop outputting the result and see what difference you can detect between strike and no-strike with various notes. That would be on the audio and envelop outputs. As you have it wired to the gate output you should be able to use digital sensing if the module is calibrated to the right range--a tight loop like this:
do : if pinC.5 = 1 then : sertxd("1 ") : else : sertxd("0 ") : endif : pause 1 : loop
Adjust the pause time to suit.
Or perhaps: do while pinC.5 = 0 loop ' after pinC.5 becomes 1, you have a note being sounded

The modules like this that I am familiar with have a potentiometer so you can adjust for what gives you the digital 1.

(Of interest--what does your accelerometer output look like now?)

Basically--what does it look like with background noise, and what does it look like with hammer dulcimer sounds.
 
Last edited:

inglewoodpete

Senior Member
My thought was for a piezo sensor mounted on the instrument. Located the right way in the right spot, they can give a significant output. It should be possible to separate the "shock" of the instrument being struck versus notes ringing or other background noises. This would probably take a some experimenting, though.
 

Gramps

Senior Member
This is a little off thread, but I have to tell you guys the wonderful Discovery I made in Editor 6 this evening.
That is, that you can CHANGE the default font size from 9 to 14!😁
 

lbenson

Senior Member
My thought was for a piezo sensor mounted on the instrument.
I don't know why you aren't looking at electric guitar pickups for string strike detectors.
I think this came up a couple hundred posts ago in the original thread. I don't think we got a report of its having been tried.

Something like this firmly adhered to the sounding board.
piezo2.jpg
I got 20 of those at a few cents apiece from China. If you like, I'd be happy to drop a couple in an envelop and send them to Fort Myers (from Crystal River) if you PM me your postal address.
 
Last edited:

Gramps

Senior Member
We did consider using electric guitar pickups in the other thread, but the area that needs to be covered is very large on a hammered dulcimer. There are 35 strings if we we're able to cover 6 strings per pick up, that would work out to 9 pickups. I suppose we could go that way if we found some really cheap ones but how would you wire them so you only needed two pins to detect the sound?
 

Gramps

Senior Member
LBenson, thank you sir, but I already have four of them just have not got around to experimenting with them yet and was wondering how to attach them to the instrument without damaging the Finish perhaps double back sticky tape?
 

Gramps

Senior Member
Mentioning guitar pickups again brought to mind that there might be such a thing as a Hammered Dulcimer pickup lo and behold they exist!
this one
https://schatten-pickups.myshopify.com/collections/hammered-dulcimer-pickup-system
is not cheap but we're noticing that it only has two sensors. So perhaps 2 pizzo's will work!
This one
https://schatten-pickups.myshopify.com/collections/micro-pre-series-miniature-preamps

Is much more reasonably priced looks like a general purpose pick up that will go in any hollow-body stringed instrument
 

lbenson

Senior Member
While guitar sound hole pickups have one (or more) sensors per string, you can also get piezo sensor arrangements--just a single piezo which is taped to the back of the guitar top with sticky-back tape. A single one should work for you.

I was thinking of something like this: https://www.amazon.com/ROSENICE-Pickup-Guitars-Acoustic-Instruments/dp/B077XJPRBP

I'm not sure that the potentiometer would do anything for you.

An individual piezo with READADC should give you something to work with.
 
Last edited:

hippy

Technical Support
Staff member
An individual piezo with READADC should give you something to work with.
I never had much joy when trying to use a piezo with an ADC input but that could have been a poor circuit design and I never put much effort into making it work.

Building a simple pre-amp, effectively a microphone amplifier for a piezo sensor, would be what I would imagine would be most effective.

There are plenty of differing circuits out there for piezo signal detection so it's probably a case of experimenting, seeing what works and what doesn't.

Having an oscilloscope would probably help with that but it could possible be done without.
 

Buzby

Senior Member
I never had much joy when trying to use a piezo with an ADC input ...
Same here, the signal is too weak.

If you whack the piezo directly then the amplitude is sufficient, but the duration is too short.
Putting the piezo on the sounding board will give low amplitude, so a preamp will be needed.

Now with my half-baked-idea hat on ;)

Put an electret mic, an smd picaxe, and a wireless TX ( Bluetooth ? or IR ? ) in the hammer, and detect the strikes without having to glue bits to the soundboard.

Cheers,

Buzby
 

Gramps

Senior Member
Buzby very cool idea! We have kind of kicked around the idea of using accelerometers the same way
 
Last edited:

AllyCat

Senior Member
Hi,

IMHO the first thing you need to decide is if you are going to detect a "dc" or "ac" signal. The accelerometer was basically "dc" whilst audio is fundamentally "ac". The accelerometer may have been bipolar (bidirectional), i.e. accelerating and then decelerating but over a relatively long time period and you could potentially detect either "high" or "low".

However, sound waves always oscillate very quickly between high and low (pressure) : so any single PICaxe ADC reading might "see" a high (peak) or low (trough) or more probably "somewhere in between", which could be the "bias" voltage (i.e. "nothing"). A "real" (or raw) microcontroller (e.g. a PIC) could make many ADC measurements and analyse the signal (e.g. like a sampling 'scope does), but the PICaxe is probably not fast enough.

Thus the PICaxe needs some "hardware assistance" to convert the audio ac to a dc signal. Typically this is a three-stage process: 1) Amplify the audio signal from the microphone, 2) Convert the amplified signal to dc (e.g. by using a diode, or similar, and a capacitor) often in the form of a "peak detector", and 3) Detect when the dc level exceeds a required threshold voltage. The well-established PICaxe sound detector circuit uses three transistors to perform these three functions.

I've not looked at the data for the module you showed in #1, but I see that it has a pin called "Envelope". That might be exactly what you need to use here. The "Threshold Detection" would then be done in the PICaxe program, e.g. IF adcEnvelopeInput > threshold THEN ......

Cheers, Alan.
 

Gramps

Senior Member
If we can make the accelerometers wireless that would by far be the best solution
No issues with other noises in the room or Echoes from the instrument
I wouldn't even mind wearing the IR or Bluetooth transmitter on the back of my hand
 

inglewoodpete

Senior Member
The piezo sensor outputs quite a high voltage but has a very high impedance. Basically it needs an amplifier with a high input impedance, moderate gain to not be too sensitive to lower frequencies (say <1000Hz, possibly higher). You are looking for the high energy impact of the hammer, not he sound of the strings.

Rather than using ADC, look at the latching hardware interrupts of the X2 series of PICAXEs. Alternatively, use the comparator that some PICAXEs have built-in. I think you should have the PICAXE responding to the high impact transients of the dulcimer's hammer strikes rather than just "loud sounds".
 

inglewoodpete

Senior Member
If we can make the accelerometers wireless that would by far be the best solution
No issues with other noises in the room or Echoes from the instrument
I wouldn't even mind wearing the IR or Bluetooth transmitter on the back of my hand
Using an accelerometer (analogue device) and wireless is likely to be slow. There has to be an analogue to digital conversion before the data is passed to the wireless. Would the wireless have error checking? If a PICAXE is doing these tasks, it may miss the transient output from the accelerometer. Then, when the message has been received from the wireless link, some 10s of milliseconds may have passed. How soon after the event do you need to know about it occurring?
 

Gramps

Senior Member
We agree with lBenson that 300 beats per minute would certainly be adequate. Not sure how that works out in ms.
The accelerometers do have a digital output and we could detect the Sudden Change in Direction
 

lbenson

Senior Member
Have you tried your sound module, looking for "1"s and "0"s on the GATE pin? That might give you what you are looking for.
 

Buzby

Senior Member
Using an accelerometer (analogue device) and wireless is likely to be slow.
Not so sure about that.

The PICAXE has nothing else to do, so a tight loop would probably catch a spike.

Personally, I would not use an accelerometer. The signal will depend strongly on the orientation of the stick, and you will need to correct for this with lots of sin & cos maths.

I'd definatley go for trying the piezo or electret first. Tight loop looking for spike. If the spike is too short a diode and cap will stretch it.
Then a quick burst of IR or tone over 433MHz. ( I've gone off Bluetooth, could be too much latency. )
 

Gramps

Senior Member
Have you tried your sound module"
The only thing we did with the new sound module is hook up a battery to it and watch the LED light when a sound is heard.
I would think that this LED signal is really all that we need if we can eliminate all the other noise entering the mic
 

oracacle

Senior Member
that's actually a great little circuit and makes sound detection very easy.
The gate output will go strait to 5v when sound is detected (bare in mind sensitivity can be adjusted) and can be connected strait to a digital pin of the picaxe. envelope gives an analogue curve in accordance with the volume of the sound. If you are using a chip is ADC interrupt you can alter the detection in software.

what I would suggest is, connect the gate pin to a digital input, the envelope to an analogue input and run something like:
Code:
do
if gate = 1 then
     readadc0, b0
     sertxd (#b0,13,10)
end if
loop
or just run the ADC in a loop sertxd the data back to see what going on.
I suspect that this is that same as the PDF posted earlier. I also recommend that you read the code example, its reasonably well written and the comments at the beginning do explain what is going on.
https://learn.sparkfun.com/tutorials/sound-detector-hookup-guide

also take a look at this PDF
http://www.picaxe.com/docs/picaxe_sound.pdf
 

lbenson

Senior Member
The only thing we did with the new sound module is hook up a battery to it and watch the LED light when a sound is heard.
I would think that this LED signal is really all that we need if we can eliminate all the other noise entering the mic
I think the signal on the GATE pin replicates the LED. Did you get false positives when you looked at it? Or detect absence of true positives?
 

techElder

Well-known member
So, have y’all considered that hammer strikes won’t exactly be the only sound in the neighborhood?
 

Gramps

Senior Member
. Did you get false positives when you looked at it? Or detect absence of true positives?
Yes it did seem to be operating somewhat erratic but there was a fan droning away on the corner of the desk so we were probably getting vibration as well as sound interference
 

lbenson

Senior Member
So, have y’all considered that hammer strikes won’t exactly be the only sound in the neighborhood?
From inside the hammer dulcimer sound box, I would expect that the box would muffle outside sounds, and the strikes would overwhelm anything else. Adjustment might be needed. I'm surprised that the sparkfun module doesn't have a pot on it as most similar sound modules do--according to the pdf, you have to add a resistor (through-holes provided) or remove an existing one.
 

RNovember

Well-known member
Hello, does the dulcimer have metal strings?
A hammered dulcimer has 35 notes (70 strings- two per note).
If I understand this correctly, if you strike a note, you strike both strings.

If so, (and I don't know if you have already discussed this) then you could hook one of the strings for each note to ground, and the others hook all together and hook it to a pin of the picaxe chip.

Then if your hammer was metal, or if you could make the end conduct, then when a string is played, the picaxe pin goes high, and signals the picaxe to move on to the next note.
 

Gramps

Senior Member
RNovember, that is a very cool idea and I'll try that when I get home.
Still hoping we can use acoustics for the feedback so we don't have to have a piece of copper foil on the Hammers it does change the tone of the instrument
 
Last edited:

RNovember

Well-known member
it does change the tone of the instrument
Yea, I just realized that.

Also, I realized that you would have to have something for debouching the input in the program, because the hammer probably won't just connect them only once. Maybe a short pause, or the button command.
 

lbenson

Senior Member
I tried both a piezo clamped to the top of a Martin Backpacker guitar and, tucked in the sound hole, a sound module similar to the one Gramps has, except with only digital and analog outputs, not the "envelop" output of the Sparkfun module.

The results were quite disappointing. It took very hard plucks for the piezo to register any change in ADC reading--and yet, in conjunction with a preamp and speakers, a piezo can replicate a guitar's sound pretty successfully.

Likewise with the sound sensor module. It took hard plucks for a readADC command to give a changing reading, though not quite as hard as for the piezo. The module I tested had a multi-turn pot. Dialing it up or down changed what you might call the "register" of the ADC reading (that is, dialed one way, the resting reading might be 200, and dialed the other way, it might be 80, but in either case it took quite a hard pluck of the string to get a change of, say, 3-5 in the ADC reading, and a light or normal pluck would get no change at all). I didn't try READADC10--I guess I should, but it looks like it will take amplification for either piezo or sound module to work.

For the ADC reading, I made 10 readings as fast as I could at 4mHz (with an 08M2), sorted them, threw away the two smallest numbers and the two largest, and averaged the 6 remaining. I printed out any difference greater than plus 2 or minus 2.
 
Last edited:

techElder

Well-known member
The piezo sensor outputs quite a high voltage but has a very high impedance. Basically it needs , moderate gain to not be too sensitive to lower frequencies (say <1000Hz, possibly higher). You are looking for the high energy impact of the hammer, not he sound of the strings.
This is the key to using a high-impedance sensor of any type ... "an amplifier with a high input impedance" and high-pass filtering.

Look at hammer strikes on a scope, and see if there are fast changing edges. You will want to filter out anything else (as much as possible). It will take some experimenting, because I think you are finding the trial-and-error engineering method is not so productive. :D

I might look for an ultrasonic sensor/transducer with a matching amplifier.
 

RNovember

Well-known member
it does work!
Great.

Hey, what material is your hammer made of?

If it was something that would add more capacitance between the wires, you could use the touch command, and you wouldn't have to use copper foil, or something else that would decrease the quality of the sound.
 
Top