Author Topic: Triggering a scope/frequency counter off of audio tones  (Read 8018 times)

0 Members and 1 Guest are viewing this topic.

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Triggering a scope/frequency counter off of audio tones
« on: September 26, 2016, 11:54:43 pm »
I'm trying to do some experiments with measuring audio (frequency, harmonics, etc.) on my test gear and checking the interfaces between things, and I've run into a small issue that makes the equipment much less versatile than I expected: it's very difficult to find a good trigger level that will work on more than one sound or one sound at different volumes.

Basically, I'm measuring tones from an instrument (periodic but non-sinusoidal), and while some are near sine waves and are very easy to trigger off of, many have a peak and then several smaller peaks in between and it's difficult to get an accurate frequency measurement of the fundamental tone - the highest peak in the pattern.  This is further complicated by playing at a different volume level, and because certain notes have such a pronounced set of harmonics that the fundamental tone is only slightly higher amplitude.

I'm wondering if there's a simple way to find this fundamental and dynamically adjust the trigger level (or dynamically adjust the gain of the signal) so that a scope or a frequency counter can trigger off of the signal easily, or if there's some alternative scheme that would do the job I'm looking for - finding that highest periodic peak even in signals that are softer (lower amplitude) or those with prominent upper harmonics.  I've seen techniques that just increase the gain to the point of clipping most of the signal and then measuring the edge of the clipped waveforms, but I'm not certain this will do a good job on some high-harmonic notes.
 

Offline timb

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Triggering a scope/frequency counter off of audio tones
« Reply #1 on: September 27, 2016, 03:50:14 am »
Have you tried AC coupling the signal and setting the trigger at 0V/div? (+/-100mV if you need to add some noise immunity.)

Failing that, you could try triggering on the falling edge (DC coupled) at a level of the lowest expected signal.
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19511
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Triggering a scope/frequency counter off of audio tones
« Reply #2 on: September 27, 2016, 06:58:19 am »
Exactly what are you trying to measure - and why? In other words, what's your problem to which you think the measurement is a solution?

Try a paper experiment: draw a graph of  a1sin(\$\omega\$t)+a2sin(2\$\omega\$t)+a9sin(9\$\omega\$t) for different amplitudes, and draw on it where you want the trigger to be; you may find that to be impossible.

If you are interested in the amplitude of various frequencies, then a scope is the wrong tool: use a spectrum analyser.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1561
  • Country: gb
Re: Triggering a scope/frequency counter off of audio tones
« Reply #3 on: September 27, 2016, 08:38:45 am »
If you are interested in the amplitude of various frequencies, then a scope is the wrong tool: use a spectrum analyser.
Or you could use the FFT function of your oscilloscope. In that case, run the scope in single-shot mode and don't worry too much about the trigger. So long as you trigger somewhere on the waveform, and capture the start and end points of the time period you are interested in, the FFT display will show peaks at the dominant frequencies in the signal. You can use the scope's cursors to measure their frequencies and amplitudes. The details of this operation depend on the exact scope you are using.
One tip: To get a good FFT you will need to set the scope horizontal controls to a much slower time/div than you would normally use for looking at the shape of the waveform.
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #4 on: September 27, 2016, 06:35:05 pm »
I will try to take some video to show the waveforms and the problem I'm having, but at the moment the sun is backlighting the window in the room and making the screens very hard to read, so it will be a few hours.

Basically, I am trying to measure the frequency of the fundamental tone, the lowest frequency component of the signal and the highest amplitude of the signal, rejecting the harmonic content above that in such a way that I can get a frequency counter to trigger off of it properly.  The end goal is making a high-accuracy tuner - a normal tuner can measure cents, 1/100ths of a half step (1200 divisions per octave), so around three decimal places on the low end of the hearing spectrum and one on the high end, and I want to get at least 3 orders of magnitude better than that using a frequency counter, a precision timebase (GPSDO), and maybe some custom software to give output in note letter and cents as opposed to just a frequency readout.  I do want to do some harmonic analysis stuff, but I'm not expecting the same precision, since my scope won't accept the reference frequency and I don't have the cash to shell out for a proper low frequency spectrum analyzer - so I'd be doing it through an audio interface and a DAW plugin and just relying on whatever oscillator the interface uses.


The best triggering results I've had have been about 350mV (though that doesn't matter since you can just adjust the volume on the line out) AC coupled (lowest fundamental on the horn is just below 60Hz) and matching the level on the frequency counter, but while I can get this to trigger properly for a handful of notes - some notes don't trigger at all without adjustment and some notes have to be played notably louder or quieter to trigger on only the fundamental - not a useful feature for a tuner.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19511
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Triggering a scope/frequency counter off of audio tones
« Reply #5 on: September 27, 2016, 07:12:02 pm »
Digitise using an ADC, store samples in a PC, then do an FFT  on the samples.

If necessary, write your own program and invoke a library FFT function. Such libraries are available in most languages; I would consider Python.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #6 on: September 28, 2016, 02:47:11 am »
I really don't think digitizing and using a PC is a good option for the level of resolution and accuracy I want.  I want to make something that is accurate and repeatable down to 10^-9 or better, and my GPSDO seems to be good to a 10^-11 ballpark - without using something like that or better as a reference timer to clock the ADC samples, I don't think digitizing it to a PC could ever be low enough jitter to be as accurate as I'm looking for.  There's also the fact that any desktop or phone/tablet based tuner app is doing exactly this and already can give you a ballpark 10^-3 or 10^-4 accuracy if they show you the floating point output.

So I've been thinking on how I may do this and I don't know of a readily built-in option that will do the job.... so I'm considering making my own hardware signal conditioner to put between the audio signal and the frequency counter.  I don't know if it's the best way to do it, but something like an opamp peak detector fed into a voltage divider fed into a comparator which turns on if the incoming live signal is within 5% or so of the local peak, so that it will reject any peaks less than ~95% of full amplitude.  The value can be tweaked, but it would mean some automatic max-level compensation for tones that simply translate into higher amplitudes and have a relatively small acceptance window, so to get a good registered sound, you need a repeating waveform with relatively little change in volume, but which can have very prominent harmonics that aren't picked up.

Then the idea would be to feed that into a good frequency counter: something like an HP 5384a for the low end of my accuracy target (10^-9 ballpark), a 53131a for another LSD and a 35132a should be accurate enough that the my GPSDO's accuracy and stability would become the limiting factor - and for the sake of responsiveness of the tuner, I'd be looking at a target gate time of .1s ideally and 1s alternatively, so the counter actually has to be reasonably quick.  A 10s gate time wouldn't be so meaningful given how much the sound can change over a 10 second span.

Anyways, here's a video of the waveforms and a bit of explaining my current experimental setup and methods.  I think I'm on the right track, and I think I have to buy a pretty good frequency counter to really do this project justice, but I think that's a good enough reason to spend a bit on a new toy  :)

https://youtu.be/C9ZbpGGYU5A
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19511
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Triggering a scope/frequency counter off of audio tones
« Reply #7 on: September 28, 2016, 07:11:30 am »
I really don't think digitizing and using a PC is a good option for the level of resolution and accuracy I want.  I want to make something that is accurate and repeatable down to 10^-9 or better, and my GPSDO seems to be good to a 10^-11 ballpark - without using something like that or better as a reference timer to clock the ADC samples, I don't think digitizing it to a PC could ever be low enough jitter to be as accurate as I'm looking for.  There's also the fact that any desktop or phone/tablet based tuner app is doing exactly this and already can give you a ballpark 10^-3 or 10^-4 accuracy if they show you the floating point output.

0.001ppm to 0.000001ppm? For an audio signal?

You should do some calculations that involve the thermal noise and EMI/EMC that you expect to find, and work out the averaging time necessary to measure to that accuracy.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1561
  • Country: gb
Re: Triggering a scope/frequency counter off of audio tones
« Reply #8 on: September 28, 2016, 09:13:50 am »
A back-of-the-envelope calculation shows that for an instrument 3 m from the microphone, playing a 500 Hz tone in a room at standard atmospheric pressure, a measured frequency shift of 1 part in 10^6 will be generated if the air temperature is changing by 0.7 K/hour. This is because of the changing speed of sound with temperature slightly shifting the arrival times of successive sound waves...
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #9 on: September 28, 2016, 04:59:10 pm »
Yeah, my target is 1ppb or better for the measurement hardware, and from the specs I've got, I think it should be possible.  If there's something else that needs to be considered, then by all means I'd like to hear it (and while I think I have a reasonable conceptual basis for what I'm trying to do, I don't know all the math to back it up), but the point of the experiment is to have equipment so precise, you can see the differences that external factors make.  I already know that for the purposes of tuning an instrument to music, this is silly because the human factor will always be the noisiest element - I have reasonable control over tenths of Hz in that video but not much over hundredths and while certain other instruments are better suited to making constant, stable tones, there's going to be virtually no one who can maintain stability at thousandths of Hz for a matter of seconds.


That being said, I want to be able to put a stable tone in a room and see the change in pitch when the AC comes on.  I want to be able to see the effect of an oscillating fan creating localized higher pressure zones.  I want to be able to measure the doppler effect of a theoretical perfectly stable musician swaying around in their chair.

I fully understand that this project is practically useless for tuning over a standard tuner because people can't hear or control pitch stability to such a fine degree that the oscillator on an iPhone running a tuner app will be the limiting factor, but for the sake of being fascinating, I'd like to be able to measure far below that.  If it doesn't look like I'll be able to make it to the ppb level at the receiving end, then I'd like to know, but from what I can tell, it should be possible.
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #10 on: October 03, 2016, 06:19:04 pm »
Found myself a suitable counter and I'm working on a circuit to be a frontend for the counter to reject the upper harmonics from the signal.  Right now the design is:

24v phantom power for a mic
Differential amp to combine the balanced input
Preamp/amp to get the mic signal to several Vpp
Auto gain circuit to boost the level to nearly 12Vpp (12v single supply design)
Opamp peak detector
Comparator with trimmable voltage divider to output the fundamental frequency as a squarewave

Got some additional bits for a non-mic input, a direct output of the waveform, a switchable filter, but I think it will get me a relatively normalized, distortion free signal and a squarewave at the fundamental frequency.
 

Offline montemcguire

  • Regular Contributor
  • *
  • Posts: 88
Re: Triggering a scope/frequency counter off of audio tones
« Reply #11 on: October 03, 2016, 11:29:53 pm »
If you're going to use a comparator, think of what the noise embedded in the signal does to the comparator trigger point - it adds uncertainty into the time domain because of amplitude uncertainty from noise the signal and the comparator. Comparators are essentially high gain saturating amplifiers, so the traditional noise floor of a signal is going to  be greatly raised in the process of squaring it up. Given that you'll be hard pressed to get a signal with an inherent noise of less than 100 ppb without any gain, how do you expect uncertainties in the 1 ppb range? At that point, why not go for 10^-12? They're both equally imaginary and fantastic goals. Yes, one can use averaging to grind the noise down, but then you can't measure rapidly changing events, which you seem to want to do.

It's probably worthwhile to do some thumbnail calculations on the effects you want to measure and the limits of what can be done to measure them, and see if things line up on the "realistic" or "unrealistic" side. You could also just cobble stuff together and see what you can see, and then determine whether you're observing the effects you want to observe, or are simply chasing instrumentation artifacts. But, the first approach can be done pretty quickly and cheaply without much (or any) equipment, so I'd favor that approach.
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #12 on: October 04, 2016, 12:31:56 am »
I'm not exactly certain how signal noise would effect it, and I was asking about things here to try and determine the best way to go about measuring it.

If we're talking raw noise inherent in the comparator, then wouldn't amplifying the theoretically-accurate signal in advance of running into the comparator increase the SnR and lessen the impact of that noise?

Since I am looking at a variation in amplitude to trigger the frequency measurement output, what would give me that most reliably?  Would running it through digital logic be a better solution?  Would you run into the same problem?

Even if the exact trigger point beyond the threshold isn't precisely predictable, will it be the same (or very close to it) in the next cycle?  Since it's only one signal and since I don't care about phase, there is no problem if the comparator reacts somewhat slowly to the stimulus if it reacts with the same characteristic every cycle - because it's the timing between those peaks that counts, not the exact time of a single waveform.


I'm a hobbyist with much more knowledge and experience with music than electronics, so I'm trying to figure out the best way to do this.  I think is the most accurate instrument for measuring frequency is a high precision frequency counter, so I want to manipulate the audio signal for it to be usable by one.  My accuracy target was based off of what counters were available that weren't thousands of dollars and what my reference timebase was capable of, so if it's somehow impossible to measure the fundamental frequency of an audio signal to that 1ppb target - sure I'd like to know that too, but I don't get the impression that that is likely. 

If there is a more accurate way of doing so than what I've proposed, I'm all ears, and if there's particular components that have to be selected very carefully or something, I'm interested in knowing.  I don't know all the ins and outs of measuring signals or frequency, so if there's something especially pertinent, I'd appreciate the help.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26907
  • Country: nl
    • NCT Developments
Re: Triggering a scope/frequency counter off of audio tones
« Reply #13 on: October 04, 2016, 01:57:08 am »
That being said, I want to be able to put a stable tone in a room and see the change in pitch when the AC comes on.  I want to be able to see the effect of an oscillating fan creating localized higher pressure zones.  I want to be able to measure the doppler effect of a theoretical perfectly stable musician swaying around in their chair.
I think you'll also need a distortion analyser (or an oscilloscope with a very good FFT function). Some of what you are describing is likely to cause distortion and not pitch change.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #14 on: October 04, 2016, 04:47:21 am »
While I'm sure it would be interesting to monitor, I'm going to stick with pitch/frequency for now and if I can't see that movement, at least I will be accomplishing my primary goal.


I've done some reading and wading through datasheets and I have found some info on the comparator jitter times - most are not specified, but some extremely high speed ones do.  Opamps also would have some, at least in theory, and they basically never list it on the datasheet.  With that in mind, I think my original block diagram is largely good, but I need to change the components to extremely high speed, low timing jitter variants, and that also means running a lower voltage dual supply instead of the single supply.

Since jitter isn't listed for opamps, I looked for very high slew rate instead of going for low THD like you would for an audio opamp.  I'm considering the THS3202 which has a .45ns rise/fall time and 5100V/us - which, in terms of timing, will probably be the noisiest part of the circuit.

The comparator, on the other hand, is actually quite fast, the ACDMP581 is rated at 10ps of deterministic jitter and 200fs of random jitter - well under the 100ps single shot resolution of the counter I'm planning on using.

These two parts should be the only active components in the signal path, and I plan on using a lesser opamp as the peak detector to keep cost down (it's just setting the threshold for the comparator, after all).  These new opamp choices mean way more gain bandwidth product, so I can do the same amp in fewer stages, which is nice considering they're $10 a chip.  I may have to pick a new jfet for the auto gain circuit though....
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19511
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Triggering a scope/frequency counter off of audio tones
« Reply #15 on: October 04, 2016, 09:17:22 am »
Caution: if you have even considered using an op-amp as a comparator, then you do not know enough to design a PCB layout for an ACDMP581.

In addition, several people have pointed out that you should answer some fundamental questions (i.e. unrelated to implementation details) before bothering to look at components. Start with noise, measurement interval, threshold voltages, and that interesting 0.7K/hour observation from nfmax!
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #16 on: October 04, 2016, 05:58:30 pm »
I'll be honest, I'm not sure how that effect would make a difference on what I'm trying to do.  Yes, it makes a difference in an absolute reference source's stability vs. the received tone, but that's not what I'm trying to measure.  I'm trying to measure the frequency of whatever the incoming sound is to the highest accuracy possible.  A tuner doesn't need to be able to compensate for pressure and temperature effects because all that matters is that you've adjusted to fix it - if you're playing in the heat, an instrument also physically changes along with any change from the sound waves passing through the environment, but the tone you're supposed to be referenced to stays the same.  A tuner is a feedback mechanism for the musician to adjust the pitch, so while it is referenced to an absolute, the input will be anything but.  I'm looking for the highest level of detail feedback regarding what adjustments to make (how far off the incoming tone is from a reference pitch, or in this case, just the frequency of the tone being produced).

Maybe I haven't been clear in explaining my goals, but I don't get the impression that I've really been talking about the same topic as some of the people posting here.

I also haven't considered using an opamp for the frequency output comparator, though I've currently got a different one driving an LED to give an indicator of signal clipping because I had a spare one in the package and didn't want to throw another chip on the board.

So my goals are:
Precise measurement of the fundamental frequency of an audio tone - ideally, precision into the noise floor of the instruments being used to measure it (a 12digit/s counter with a 100ps timestamp resolution and a GPSDO good to around 5*10^-12), but if not that, as precise as possible
An update rate (gate time on the counter) of 1s or less - .2 -.3 seconds is ideal for usable responsiveness, but I fully understand that for full accuracy, 1s is required
Input frequency is the range of human hearing - 20Hz to 20kHz, though for most instruments, 50Hz -5kHz would suffice.
Rejection of higher harmonics entirely in the final frequency output

As for noise levels, I know the frequency counter accepts 10Vpp and has a 15mV + 1% error on the trigger, so the input to that effectively has to be a squarewave.  I'm not certain which aspect of opamp performance contributes most to noise in the time domain, but if we're just looking for the lowest noise floor, there are several choices under 1nV*Sqrt(Hz) - probably the noise bottleneck in the system.  Then something like the ACDMP581's jitter seems to be already on target with the highest performing elements of the system.

To verify, when something is built and operational, I have a signal generator with 150ps of jitter on its output using the internal oscillator (no function given for external timebases) that can direct drive a small speaker and verify down to 10^-9 or so (or if a speaker has enough variance, I can pipe that same signal directly into the box to at least verify the frontend electronics).


I've said before, but I've been continuously trying to evaluate options and I do still think I'm on the right track to meet my goals (this block diagram seems like the right approach).  If you know of another approach, a hard limiting factor of the circuit I've proposed, or some other thing that will effect the measurement of a fundamental frequency I'd love to hear it.  My accuracy target was set based on the instruments I have access to if I could build a circuit that doesn't get in the way of that - I want to make something that is as transparent as possible (in terms of jitter on that fundamental frequency output) at getting an audio tone in the air into a frequency counter.  If it can't meet the accuracy target, so be it, but I want to do the best job that I can and if it really can't even get within a couple orders of magnitude of the target, I should be able to measure that when everything's built up.
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #17 on: October 05, 2016, 03:45:14 am »
Well I've found a resource that addresses phase noise in opamp systems: www.ti.com/lit/an/sboa066a/sboa066a.pdf , and I think I'm starting to understand the sort of noise level I can expect from a given stage or system.

I've also found while wading through datasheets that going for high bandwidth/slew rate opamps actually doesn't help in my case - while they may be down to .9nV*Sqrt(Hz)... that's at 100kHz or more, and the figure balloons at lower frequencies.  With that in mind, I set again looking for lower speed, low noise opamps, and ended up finding the audio-specific OPA1612 as being the winner - audio opamps are almost always specified down to 1kHz or 100Hz in their noise terms, and this one is typically 1.1nV*Sqrt(Hz) at 1KHz, 1.5 at 100Hz, and only 2 at 10Hz - the lowest stated noise I've come across yet in the audio band.

Perhaps more interestingly, investigating into Johnson-Nyquist noise from resistors..... the resistors used for gain in the opamp stages will contribute more noise to the system than any other part.  A 1k resistor at just over room temperature will contriubte about 4nV*Sqrt(Hz), and a 100 ohm resistor is just over 1nV*Sqrt(Hz).

Since all these figures are for fixed voltages (and currents) relative to the frequency of the signal, I should also be able to lower the noise floor by using wider supply voltages (100 nV of noise is a lot more to a 1Vpp signal than a 10Vpp signal), but am limited by current sinking capacity and the fact that going with large voltage swings needs more slew rate to keep up and larger resistors (more noise again) to keep the current levels in check.  It's also to my advantage to have very high gain on the first stage because the mic level input is so small (8mV is specified by the Rode NT1 datasheet) so that later stages' contributions to the noise of the system make less of an impact on the SnR.

Knowing this, I think my priorities for designing the circuit should be:
Fewer amplification stages, the first one with the majority of the gain
Low resistor values to minimize thermal noise (but not so low as to burn out my opamps)
Low noise audio op amps over low noise high speed op amps
A high speed, very low jitter comparator to square the fundamental frequency signal to the point that the frequency counter can trigger accurately on it
Put the whole thing in a freezer to further reduce thermal noise  ;)

As for the back-of-the-envelope calculations....
OPA1612 noise figures: 20Hz ~8nV, 100Hz ~15nV, 1kHz ~34nV, 5kHz ~80nV, 20kHz ~150nV
So on the input stage without figuring in resistors that's:
10^-6 range below 5kHz then 10^-5 range above that
And on a second stage brought to let's say 3Vpp
10^-9 range on the low end and 10^-8 range on the higher frequency end

Then a 250 ohm resistor to limit the 5V supply opamps to 20mA: 2nV*Sqrt(Hz) or
20Hz ~9nV, 100Hz ~20nV, 1kHz ~63nV, 5kHz ~141nV, 20kHz ~243nV

So considering there will be a couple resistors per opamp and one of them will be much larger, you can knock at least one digit off the noise floor estimates from before.  Not exactly the precision I'd hoped for, but at least this is for single waveform period accuracy.  There will be multiple waveforms to average and as the noise floor gets larger, you will get lots more averaging in a given gate time.

And that's just the signal path noise if I can keep the power rails completely still!


If this is the best that can be done without custom parts, thousands of dollars, or cryo cooling, I'm satisfied with doing it and seeing what sort of results I can get, but if you have any ideas for taking out or reducing some of the noise sources, I'd appreciate it.  Getting a mic with an order of magnitude or more output voltage would clean up the first stage noise on the circuit, but I'm not sure if it's worth doing because the NT1 while having a very low output amplitude, is a very low noise floor mic - one of the best available short of a thousand bucks from best I can tell.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19511
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Triggering a scope/frequency counter off of audio tones
« Reply #18 on: October 05, 2016, 07:21:34 am »
You will save yourself a lot of time if you read The Art of Electronics 3.

It has tables listing the "best" components, for varying values of "best". It also has 150 pages on opamp techniques, and 120 pages on low noise techniques. And other chapters on filters.

See http://artofelectronics.net/ from where you can download the chapter on PSUs.

There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Triggering a scope/frequency counter off of audio tones
« Reply #19 on: October 05, 2016, 09:54:50 am »
I think that the math makes it impossible to get the resolution. Rough maths without a calculator... Say you had a perfect 440 Hz sine wave and then sample it for 100 seconds. You can only FFT it into 0.01 Hz wide bins - that is all the information that is in the acquired data.

Any you might end up with something like this (where I have done the math, and I've put in a 440.001 Hz signal, and haven't bothered to window it):

p(439.950000) = 92571.731739
p(439.960000) = 115151.511269
p(439.970000) = 152298.890457
p(439.980000) = 224824.725955
p(439.990000) = 429215.716792
p(440.000000) = 4721426.523022
p(440.010000) = 524608.906715
p(440.020000) = 248501.778760
p(440.030000) = 162813.359698
p(440.040000) = 121067.719610
p(440.050000) = 96361.116269

The peak is clearly near to 440.00 Hz, but it doesn't jump out 440.001 Hz.

(remember that this is a perfect continuous sine wave for 100 seconds, no noise, and no decay).

If the signal decays over time, the peak will be even less clear.... as the signal vanished so does the timing information needed to differentiate between different frequencies.

You might have better luck with a PLL or NCO that follows the input signal's phase. I don't know much about PLLs, but I seems likely that you can't have a very accurate PLL that always locks, tracks rapid changes in frequency, and still work well in the presence of a noisy or dirty input.

Maybe string instruments have slightly higher tension when the string is plucked, and the frequency drops slightly during the note, which could also be a problem
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14206
  • Country: de
Re: Triggering a scope/frequency counter off of audio tones
« Reply #20 on: October 05, 2016, 06:02:03 pm »
Just using an analog trigger (e.g. comparator(s)) will be sensitive to noise. Ideally one would need filtering to reduce noise, and than super low noise parts, not to add new noise.

The more modern way is to use and ADC (e.g. soundcard) to digitize the signal and than do the rest  in software. The simple / fast way would be an FFT, but here frequency resolution is limited. The lowest noise version would be using a full nonlinear least squares fit - with modern PCs this is not that slow anymore and can also include decay as an extra parameter. The FFT could be used to get a good starting point. The fit can give really good resolution, way higher than the FFT. With a reasonable signal/ADC one is limited by the clock (crystal) used for the ADC. I did that some time ago with a rather low cost sound card and old DDS generator: I got something like 8-9 digit resolution/noise limit for a 1 second sample of a 1 kHz signal - however with visible drift, e.g. from crystal temperatures (sound-card and DDS). The limit could have been due to the old DDS generator - theoretical limits from the ADC are even lower.

There is a faster software method using Hilbert transformation - nearly as good as the least square fit, but much faster, lower memory needed (could be important if an µC is used) and less sensitive to a good starting point. It can also handle decaying signals and noisy background quite well.

Analysis of the harmonics is than a second step. Here the FFT should be good enough.
 

Offline VintageNut

  • Frequent Contributor
  • **
  • Posts: 534
  • Country: 00
Re: Triggering a scope/frequency counter off of audio tones
« Reply #21 on: October 05, 2016, 11:48:14 pm »
I have experimented with audio doppler. The source will most likely transmit all kinds of different wonky phase versions of itself bouncing off of anything that can be bounced off of. Move your microphone a fraction of an inch and the demodulated  signal changes drastically.

This is the stuff of PhD dissertations that relate to ultrasound imaging.   
working instruments :Keithley 260,261,2750,7708, 2000 (calibrated), 2015, 236, 237, 238, 147, 220,  Rigol DG1032  PAR Model 128 Lock-In amplifier, Fluke 332A, Gen Res 4107 KVD, 4107D KVD, Fluke 731B X2 (calibrated), Fluke 5450A (calibrated)
 

Offline DaJMastaTopic starter

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Triggering a scope/frequency counter off of audio tones
« Reply #22 on: October 06, 2016, 03:11:59 am »
It's fascinating stuff!  I've got a friend who's in grad school for acoustic engineering, and as a musician I've played in a good range of halls, from some that are a pleasure to play in and listen to (one does not always mean the other), to those that are probably should be used to house noisy children and nothing more.  In some of my recording experiments I've gotten really strange artifacts from how things are reflecting and moving just a few inches has sometimes made a huge difference.  In my last recording at home, I had a mysterious +6dB or so increase in amplitude on one note of my instrument using equipment and a room layout I had used before, but just one one mic of the three I was using.  Eventually found out that extending the boom arm of my mic stand to full instead of keeping the mic centered over the stand led to some sympathetic vibrations that could overcome the shockmount and some weights damping the other side of the bar...

I hadn't heard of the least squares fit before, that sounds like an interesting lead.  I still haven't found a good way to get an ADC to take samples clocked to a high precision reference (at least, one that wasn't a few grand), but this audio stuff is fascinating to me and I already had some plans for FFT analysis software using an interface, so I can at least add that to the list.


Did some more looking into components and put together a schematic that should produce some good results, provided my layout is acceptable and I mange not to overlook something facepalm worthy.... but I'll have a couple floating pads for trimming resistors by adding another and a couple of test points for monitoring voltages, current consumption, and other stuff so at least there's sanity checks if something goes wrong.  Right now the signal path looks like:

AD797 as a preamp with a little under 500 gain - slightly lower drive current than the OPA1612, but ~15% less noise (0.9nV*Sqrt(Hz) vs. 1.1 at 100Hz, with only 1.7 at 10Hz) at the cost of slightly higher rated distortion, but while the resistors will still be the majority, I want to get as low as possible for the input stage.  I looked into some higher current first stages (in metal cans, mostly), but none seemed to be low enough noise on their own to make the resistor size savings worth it.

OPA1612 as an autogain stage (up to about 10).  I don't know exactly how the jfet will perform, so there's some trimmable spots, a pot to limit current through the jfet, and a second one to try if the first one doesn't seem to work (J112 or J113)

RC 22.5KHz low pass filter

OPA1612 buffer amp so you can see the waveform on a scope or what have you

OPA1612 based peak detector (in parallel with the buffer amp) with a fair amount of capacitance to hold it - there's a bleeder resistor too, since I want to be able to catch a note at a lower amplitude after the louder one is done sounding, but the RC time constant is in the 10s of seconds because I don't want the peak to decay so much as to make the comparator trigger at a different part of the next wave.  I'm considering this part highly tweakable in terms of exact values and if the opamp takes enough current from the peak hold, I may just drop the bleeder resistor all together.

Finally a LT1711 comparator to catch the part of the wave above the peak detector circuit (there's also a small voltage divider and pot to make this amplitude distance trimmable between about 91% and 100% of the captured peak).  The ADCMP580 chips are fantastically fast, but this one is actually only 1ps more in rated jitter, and there's no need for GHz level responsiveness when dealing with audio tones, plus it outputs in TTL instead of trying to hack something together by terminating the CML or ECL of the other chip and just ground referencing one side.  It's also 20% if the price.

Then for the power supply, I've a linear reg and two switchmode (for negative rail and phantom and which are MHz range switchers), all of which are spec'd to 0.01%V regulation and expect to be using copious amounts of capacitors, as well as a selection of bypass values on every IC.

Then I'm aiming for wide traces, 2oz copper, ground plane over everything, and inside an aluminum box.  Will be individually matching some resistors and things on the input to be sure the differential signal comes together properly, and then whatever fanciful bodges I deem necessary when the thing's actually being tested out.


I appreciate the help so far, does it seem like I'm missing anything obvious?
« Last Edit: October 06, 2016, 03:19:08 am by DaJMasta »
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14206
  • Country: de
Re: Triggering a scope/frequency counter off of audio tones
« Reply #23 on: October 06, 2016, 04:59:51 pm »
For the input, usual microphones have quite some noise compared to an 16 Bit ADC. So a super low noise input is only needed with something like a dynamic microphone. But there is also acoustic background noise - so needs to be fan - less.

Even rather simple audio ADCs can use a rather constant clock. Usually this is just a normal crystal clock.  This is already quite good compared to the stability you can expect from an mechanical instrument. Changing the clock to a more stable one can be possible if really needed. Alternative one could periodically measure a stable clock in the 10 kHz range (e.g. TCXO derived).

The equivalent time resolution of the 16 Bit audio ADCs is really good, so high resolution ADCs need a stable low jitter clock. Alone for this reason audio hardware already cares about the clock. With just an level trigger, it should be impossible to beat the frequency resolution that is possible by looking at the full waveform, even if without harmonics. Even with an of the shelf sound-card the resolution is not limited by the ADC-clock or ADC but more due to the noise from the microphone, room acoustics, the instrument itself.

One big difficulty for the analog trigger is, that a fast comparator will have high bandwidth and thus reacts to high frequency noise too. Slower comparators will have intrinsic jitter / nonlinearity as the delay depends on the slope. One can slightly get around this limitation by doing amplification with graceful limiting, and than high frequency filtering before the actual trigger. But already this gets complicated.

So of you want an FFT to look at the harmonics anyway - I would leave out the trigger and classical counter.

I would expect to see things like a slight dependence of the frequency on amplitude. So during decay of the tone, the frequency will move by something like a few ppm or at least ppb. At least that is what I saw with miniature tuning forks made from silicon.
 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf