Shop OBEX P1 Docs P2 Docs Learn Events
microphone,pitch calculations — Parallax Forums

microphone,pitch calculations

stamptrolstamptrol Posts: 1,731
edited 2015-02-27 12:24 in General Discussion
Hi folks,

A client has a machine to analyze the materials used in making his product. It basically hits the material sample with a small hammer and listens for the resulting "ring". The sound is analyzed by a PC and the fundamental frequency is used to sort the material.

I suspect the PC is needed to do an analysis in software.

Any thoughts on how this analysis can be tackled Stamp or Prop-wise? The frequencies observed are right around 440 Hz +/- 30%.

Thanks,
«1

Comments

  • Heater.Heater. Posts: 21,230
    edited 2014-02-07 05:29
    Not possible on the Stamp.

    Probably possible on the Prop. Depending on what kind of accuracy you want.

    What you need is a Fast Fourier Transform to tell what frequencies are present in your signal.
    There is one here : http://propeller.wikispaces.com/FFT

    Or my FFT is here : http://forums.parallax.com/showthread.php/128292-Heater-s-Fast-Fourier-Transform.

    There are a few similar transforms you can use. Check out this nice Propeller Sound analyser demo video: http://www.youtube.com/watch?v=qvjG2j6uh94

    You may need a steep low pass filter to get this working nicely.
  • Mark_TMark_T Posts: 1,981
    edited 2014-02-07 13:54
    FFT is a sledgehammer to crack a nut here, you use correlation to pick out a single
    frequency. Or equivalently a narrow band-pass filter.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-02-07 13:58
    Why not just amplify the signal, threshold it, and count the number of edges in a fixed interval?

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-02-07 14:05
    I'm curious ... You can get at least 3 distinguishable frequencies from a single metal rod depending on where you hold it, and where you strike it. Is the method for holding the object and striking it regulated/consistent from sample to sample?


    BTW) you could do this with a Stamp and obviously a Propeller if you knew the >> exact << frequency that you were looking for.
  • mklrobomklrobo Posts: 420
    edited 2014-02-07 14:25
    I'm curious ... You can get at least 3 distinguishable frequencies from a single metal rod depending on where you hold it, and where you strike it. Is the method for holding the object and striking it regulated/consistent from sample to sample?


    BTW) you could do this with a Stamp and obviously a Propeller if you knew the >> exact << frequency that you were looking for.

    Good observation. To build upon that, I would say the 2 harmonics, and one prime frequency.(need to review my physics book, :frown:)
    Where you hold it, may shorten or lengthen the frequency depending on the attributes of the hammer, relative to the oscillating arm. The energy imparted to the hammer when struck, is
    energy converted to Moment around the point where you are holding it. I would suggest doing a "Free Body Diagram" of the hammer/material model,
    Maybe the movement of the hammer (oscillations) could be measured to produce a result of the frequency. If the oscillation could be observed, then
    maybe an infrared light source could help in discerning the frequency, which the basic stamp can be used in.:cool:
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-02-07 15:04
    As far as detecting the frequency I was thinking something much simpler ... a missing pulse detector would do the job where the pulse duration were set through a simple RC ... the R could also be a digital pot providing a sweep ability, but depending on the number of unique parts, you could just have a few 'fixed value' frequency detectors. Since the object is being struck, I will assume that the resonant noise will be far enough above the noise floor that amplitude detection will not be an issue.


    Alternatively:
    A derivative of this would be to use acoustic resonance mechanical propagation delay through the object. Essentially a speaker at one end of the object, and a microphone on the other end of the object creating a mechanical feedback loop with the object under detection in the middle. By measuring the frequency (at this point the frequency would easily be a digital signal) and just counting the number of pulses over a determined amount of time you can determine the resonant frequency.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-07 15:08
    Mark_T
    FFT is a sledgehammer to crack a nut here, you use correlation to pick out a single frequency....
    Not really. That is exactly what an FFT does. Except very efficiently.


    Phil,
    Why not just amplify the signal, threshold it, and count the number of edges in a fixed interval?
    Because it does not work.


    Back in uni some guys were trying to measure the frequency of a good old fashioned brass bell that way. What with all the noise of striking it and all the harmonics going on it's impossible.
  • RforbesRforbes Posts: 281
    edited 2014-02-07 17:47
    By "hammer" do you mean a simplenmechanical lever type run of the mill hammer? Or are you referring to a "force hammer" (which is often used to determine deadblow/fundamental frequencies)

    Im asking because it sounds like the application is using the latter- a force hammer for finding deadblow frequencies.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-02-07 17:57
    heater wrote:
    Phil,
    Why not just amplify the signal, threshold it, and count the number of edges in a fixed interval?
    Because it does not work.
    The stated range of the fundamental is 440 Hz +/- 30%. That does not include any harmonics. A PASM bandpass FIR filter could easily get rid of the spurious stuff, leaving only a sinewave whose frequency could be determined by edge counting a squarewave derived from a threshold with hysteresis..

    -Phil
  • CuriousOneCuriousOne Posts: 931
    edited 2014-02-07 21:02
    Actually, it is possible to do the task purely in analogue, without any CPU, with quite high accuracy. Take two crystals, say 439 and 441 hz. pass the signal trough both of them, connect microammeter with 0 in center, so you'll see the deviation and it's direction.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-08 00:27
    Phil,

    I could be wrong, as usual, but I always understood that if you want to look at any signals in the digital domain you are going to have to filter out the high frequencies that you are not interested in before you digitise it. Reason being that anything above the Nyquist frequency will get aliased to a lower frequency. That rather implies you cannot do that low pass filtering digitally but have to have an analogue filter.

    With that in place, yes I think your scheme would work. But isn't it rather hard to make such a steep analogue filter?



    CuriousOne,

    I suspect that a crystal that operated in the 440Hz range would be huge. Certainly I have never heard of one.

    But your idea is good. In the old days they would measure the frequency of the mains power by having a row of tuning forks of slightly varying lengths excited by coils driven from the mains. A different tuning fork would resonate as the mains frequency changed. Accurate to 1Hz or so.
  • RS_JimRS_Jim Posts: 1,765
    edited 2014-02-08 05:11
    Didn't someone here build an audio spectrum analyzer on a prop? I would think that would be a good start.
    Jim
  • stamptrolstamptrol Posts: 1,731
    edited 2014-02-08 05:23
    Hello, all

    Thanks for all the discussion.

    The hammer is a machined rod which dropped from a fixed distance. Picture a solenoid that lets the rod drop straight down then retracts it. A microphone picks up the resulting ring.

    The sample material under test rests on two supports that are acoustically isolated from the sample. The samples all get placed in exactly the same position by the transfer mechanism.

    The machine at present takes about 10 seconds to weigh, freq check, imprint a label and bin sort each material sample. The overall aim is to get the cycle down to 4 seconds or so.

    I'm meeting with the client next week so should have more details then.

    Cheers,
  • CuriousOneCuriousOne Posts: 931
    edited 2014-02-08 05:33
    I have crystal marked as 443Hz. It is plastic cylinder with legs, size about 18500 battery.

    If such crystals are hard to get, there's workaround. go get two IF crystals from AM radios, 455 and 465khz (dirt cheap, available everywhere). Buld a FCO (frequency controlled oscillator), tuned at 450khz. also quite simple, can be done using 1 transistor, and use your mic output as frequency shifter for that FCO. Remaining is same as written above. There's no need to make things too complicated.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-08 07:03
    Do you have a picture or link to such a 443Hz XTAL? I'm curious. I would never imagine there is such a thing. You sure there isn't a K missing somewhere.

    The International Crystal Manufacturing Company lists low frequency crystals only down to 10KHz.
    http://www.icmfg.com/crystal_hc51u.html

    Do you have a circuit of that Frequency Controlled Oscillator? I have also never heard of such a thing. Google is not helping.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-08 07:08
    RS_Jim
    Didn't someone here build an audio spectrum analyzer on a prop? I would think that would be a good start.
    Yes. Follow that You Tube link I posted above.
  • mklrobomklrobo Posts: 420
    edited 2014-02-08 07:21
    stamptrol wrote: »
    Hi folks,

    A client has a machine to analyze the materials used in making his product. It basically hits the material sample with a small hammer and listens for the resulting "ring". The sound is analyzed by a PC and the fundamental frequency is used to sort the material.

    I suspect the PC is needed to do an analysis in software.

    Any thoughts on how this analysis can be tackled Stamp or Prop-wise? The frequencies observed are right around 440 Hz +/- 30%.

    Thanks,



    Everyone has put in excellent ideas. I would like to give an overall suggestion. If the goal is to identify A frequency with the object, then a very simple approach is required, as
    noted by others with ambient noise, which may inject error into your project. Measuring the oscillations of the hammer by infrared, magnetic, or other means will be simple,
    cheap, and cut down of software/memory demands. IF, that is your goal.
    IF you goal is to use the frequency & harmonics to provide an "audio signature" of the target material, then, by all means, a spectrum/frequency analyzer is needed.
    Your target goal will determine the software, hardware, money, and logistics of were you want to be.
    If you are trying an "audio signature" approach, then more information will be needed. Knowledge of target materials & hammer will be needed, depending
    on the quality of the level of results you are trying to "drill" down to. Good Luck!
  • CuriousOneCuriousOne Posts: 931
    edited 2014-02-08 07:43
    Here are 4.2khz crystals (picture not mine):

    http://f-page.ru/fp/8a56fa7b9f184ca48a2cdaeedafd4646

    I had similar designed 1khz one. The quartz was formed in shape of rod, with about 5x5mm sides and length about 20mm.

    For my 443hz one, I will have look in my junk box, to find that crystal again, I've aquired it more than 30 years ago.

    FCO is modification of VCO with added lowpass or highpass filter, so change of input (low) frequency results change in frequency of high output frequency signal.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-08 08:06
    Ah, good old tube days. I suspect finding a crystal at that low a frequency is pretty much impossible to day.
    Still don't get the FCO idea.

    I was wondering. What is the material we are examining here?
    Is it metallic?

    Perhaps there are other ways to excite it's resonances than hitting it with a hammer.
  • mklrobomklrobo Posts: 420
    edited 2014-02-08 08:31
    Heater. wrote: »
    Ah, good old tube days. I suspect finding a crystal at that low a frequency is pretty much impossible to day.
    Still don't get the FCO idea.

    I was wondering. What is the material we are examining here?
    Is it metallic?

    Perhaps there are other ways to excite it's resonances than hitting it with a hammer.

    :nerd: Brilliant suggestion. These factors suggested can affect the results you may be looking for.

    May I take the time, and humbly suggest, investing time in the HP 50g calculator to basic stamp
    project? Your project is an example of why I started the 50g project. You will have projects in the
    future, and need the processing power to solve/analyze. I plan to use th 50g/basic stamp combo
    for a Rapid Math Model Integrator, for this purpose. Just a thought. I appreciate your time.:smile:
  • mklrobomklrobo Posts: 420
    edited 2014-02-08 09:13
    The HP calc has built - in libraries of funtions. The learning curve is not steep, compared to learning other
    software, in which there are many.(consumes time and money) The HP/stamp combo can get you the point
    of invention creation for profit or ?.
    HPCalc.org has programs already written that may help you. Take the basic stamp input from the transducer,
    put into the specfic variable table in the program in the calc, and Volia!
    You have a spicy "Audio hammer" Parallax sandwich! Just a thought.:smile:
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2014-02-08 19:07
    The kalimba is played by striking metal keys to generate tones. Pete Hemery used the Propeller chip in the project below to determine the notes played in his FFT powered scrolling musical note representation project.

    kalimba on Youtube:
    http://www.youtube.com/watch?v=4XD02oMHC5E

    Project details:

    http://petehemery.github.io/Final-Year-Project/Dissertation.pdf

    Discussion and source code(FFT powered scrolling musical note representation:):
    http://forums.parallax.com/showthread.php/140777-Audio-Signal-Processing-on-the-Propeller-Demo-Board?p=1105502#post1105502


    There used to be a video available for his project but the link doesn't work anymore. However, I have a copy downloaded.
  • stamptrolstamptrol Posts: 1,731
    edited 2014-02-09 04:49
    Thanks Bob,

    That is quite close to what I'm expecting will be needed. Thanks for the links.

    The materials being tested are various wood blanks and it is the resonance of the blanks that is being measured.

    Cheers,
  • HemPeterHemPeter Posts: 28
    edited 2014-03-31 17:43
    Hi guys,

    Interesting discussion =) did my project code help?

    @Bob thanks for the interest, I'll be editing the video and reposting it soon (when I have a machine capable of editing HD videos)

    Cheers,
    Pete
  • Heater.Heater. Posts: 21,230
    edited 2014-03-31 23:38
    Oh, please post the video. I must have missed it first time around. Are going to put it on youtube?
  • stamptrolstamptrol Posts: 1,731
    edited 2014-04-01 05:39
    @HemPeter

    Nothing of substance yet as the client struggles with financing for the upgrade. Will report in as things progress.

    Tom
  • HemPeterHemPeter Posts: 28
    edited 2014-04-01 17:59
    Heater. wrote: »
    Oh, please post the video. I must have missed it first time around. Are going to put it on youtube?

    Hi Heater,
    Sorry you missed it first time. Thanks for your message, you gave me the kick I needed to get my editing hat on ;)
    Here you are:
    http://www.youtube.com/watch?v=xQUO_jfl8SE
  • john_sjohn_s Posts: 369
    edited 2014-04-02 15:31
    stamptrol wrote: »
    Thanks Bob,

    That is quite close to what I'm expecting will be needed. Thanks for the links.

    The materials being tested are various wood blanks and it is the resonance of the blanks that is being measured.

    Cheers,

    Can a wooden instrument (guitar?) "tuning fork" be of any help ?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-04-02 17:17
    stamptrol wrote:
    The materials being tested are various wood blanks
    Is the wood pernambuco, by any chance?

    -Phil
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2014-04-02 19:29
    @Bob thanks for the interest, I'll be editing the video and reposting it soon (when I have a machine capable of editing HD videos)

    Ok thanks! I'll have a look. I have a copy of the unedited version that I could upload should you ever get out of line LOL Actually, I don't know why you are editing because the first version was fine.
Sign In or Register to comment.