| Electronics > Beginners |
| sound analyzer for automating quality checks? |
| << < (5/10) > >> |
| rhb:
--- Quote from: engineheat on January 15, 2019, 03:53:34 am --- Dumb question...you are supposed to average the magnitude of the spectra right? not the FFT (complex numbers)... --- End quote --- Yes, that is correct. You would need to synchronize the windows if you wanted to also get the phase information. --- Quote --- anyway, I got a crude version working. I used Python with the Pyaudio package and recorded 10 seconds of sound just for test. Sample rate =44k, each frame is 1024 samples. For each frame I plotted the magnitude, and made a dynamic plot thru the 10 seconds. It actually works. I was able to see the magnitudes change as I made various sound. --- End quote --- Each frame is only 23 mS. Try using a longer window 4096 or 8192 samples. --- Quote --- However, I also downloaded a FFT analyzer to my smartphone and compared the results as I turned on a motor. The smartphone app is able to display relatively constant spectrum (not much flutuations) right from the start. In my plot, the magnitudes are very high upon turning on the motor, and only "settled" after a couple of seconds. I wonder why that is. Is it due to my sound card or laptop mic? I tested using another laptop and got similar result. Could it be I recorded in Mono mode? The spectrum changes too much as I move the motor, whereas on the smartphone the spectrum is more stable. Is it because I didn't use a Window function? Thanks --- End quote --- Probably. You're asking me to guess what someone else's program is doing without being able to probe it. Post some plots of the time domain and frequency domain without any averaging using the longer window. If the first and last samples in the window are very different, the discontinuity will distort the spectrum. Put the triangle taper on the window and it should be much more uniform from spectrum sample to spectrum sample. Find a way to create a constant frequency tone, record it and then post plots of the time and frequency domain. If nothing else, just whistle or hum with as constant a pitch as you can manage. Then compare the spectrum you get if you start the recording before the tone and if you start the recording after the tone. The triangle window will give you the sharpest spectral peaks. Try it also using a cosine taper. (cos(-pi) + 1)/2 to (cos(0) +1)/2 at each at the start and the reverse at the end. Then vary the number of samples in the range from -pi to 0 so you change how steep the taper is. |
| engineheat:
--- Quote from: L_Euler on January 14, 2019, 01:09:43 am ---Get one of these, or similar and a piezo probe or microphone. You can use GPIB to automate the testing, pass/fail, and data recording. --- End quote --- Hi, can you program these devices to make pass/fail decision on its own (using your own algorithm) or do you need to connect a PC to grab the signal and perform custom analysis? Thanks |
| rhb:
Attached is the algebra of correcting for sound card errors on a stereo sound card by playing a computed WAV file and recording it. This is for each frequency in the spectrum. Ideally you would do it at all amplitude levels to correct for non-linearities in the ADC and DAC. I've got a reputation for going a bit overboard. :) It requires that you be able to play and record at the same time. It requires playing each channel back into itself and the opposite channel. So 4 equations in 4 unknowns. I'm cleaning up clutter and found this, and I thought it might be useful to someone. This seemed a good place to post it. It's essential to making a THD analyzer using a sound card. Which, naturally, you will need if you read "Max Wein, Mr. Hewlett and a Rainy Sunday Afternoon" by Jim Williams and get motivated to build an ultra low distortion audio signal generator for testing audio gear. |
| engineheat:
--- Quote from: rhb on January 15, 2019, 10:43:53 pm ---Attached is the algebra of correcting for sound card errors on a stereo sound card by playing a computed WAV file and recording it. This is for each frequency in the spectrum. Ideally you would do it at all amplitude levels to correct for non-linearities in the ADC and DAC. I've got a reputation for going a bit overboard. :) It requires that you be able to play and record at the same time. It requires playing each channel back into itself and the opposite channel. So 4 equations in 4 unknowns. I'm cleaning up clutter and found this, and I thought it might be useful to someone. This seemed a good place to post it. It's essential to making a THD analyzer using a sound card. Which, naturally, you will need if you read "Max Wein, Mr. Hewlett and a Rainy Sunday Afternoon" by Jim Williams and get motivated to build an ultra low distortion audio signal generator for testing audio gear. --- End quote --- Thanks. Turns out the problem was due to the auto boost feature of the mic which I deactivated. Now that I got my FFT correct. BTW, I applied a Hanning window to each frame prior to doing FFT. The data comes in both negative and positive quantities. I just applied the window (1024 length array) to the data. Next step is to find features/attributes to differentiate the good and the bad based on the averaged FFT. I noticed bad products makes sounds more in the higher frequency range, whereas for good products the magnitudes are pretty similar across all frequencies (up to 6000k). What are some good attributes to try? I'm thinking average magnitudes across all frequencies (just in case bad ones are louder). Or perhaps average magnitudes across certain frequency ranges. The ambient noise peaks at a few hundred Hz and sharply drops off. If I want to filter out the ambient noise (probably not necessary, but for learning's sake), isn't it as simple as subtracting the magnitudes? And then if I do an inverse FFT I should get a signal with only the motor sound right? Thanks |
| rhb:
How much tolerance do you have for serious mathematics? You don't need to actually learn the details anymore than you need to learn the details to do an FFT, but you will need to not run away in fear. If you record a number of motors with various defects and motors which are good, you can do what I call a "sparse L1 pursuit". The concept is extremely simple, but the mathematical proofs are the most difficult stuff I've ever encountered. The proof of one theorem is 15 pages long! In simple terms, you solve Ax=y where y is your measurement and A is a large array of *all* the possible cases you want to consider. You then solve this with linear programming or some other L1 (least summed absolute error) solver. I use GLPK which is excellent. I've never had it fail. Each column of the A matrix is a spectrum for an example device, good, bad, or intermediate. The result of the pursuit was named a "Dantzig selector" by Emmanuel Candes in honor of the inventor of operations research and the simplex method. What you get back is an x vector which is mostly zeros except for the particular set of columns whose sum best matches the DUT. Given the genomes for a bunch of patients with some exotic disorder, this finds the particular genetic alleles involved. This is absolute state of the art stuff. I call it "sparse L1 pursuits" because there are numerous algorithms and applications. This was the heart of the code that won the Netflix prize. I've posted about this a good bit, so do a search of "sparse L1 pursuit" and my ID and read some of the stuff. I stumbled across it by accident. I was doing it and realized I was solving problems I'd been taught could *not* be solved. I got very interested in how this could be and spent 3 years reading and rereading over 3000 pages of pure mathematics in order to understand how this could be. It's the coolest applied math in 80 years. But I'd been doing it for 6-9 months before I started on the "how can this be" problem. My degrees are in English lit and geology. I did learn a lot more math trying to get a PhD, but this is *way* beyond anything I ever studied. The beauty of it is all you need to know is how to create the A matrix. For your application you only have to do that once unless you discover other failure cases you want to check for. In which case you just add them to the A matrix. If the 4 motors run at different speeds it will tell you which gear trains are good and which are bad. |
| Navigation |
| Message Index |
| Next page |
| Previous page |