Teensy AD sampling


New member

I have ~10 sinus-shaped signal arriving the Teensy at around every 30. second. The frequency of the incoming sinus signal is typically 70kHz. I need to identify the arrival time as accurate as possible (better than milli second accuracy), and also the amplitude (do not need to be very accurate) of the amplitude of the incoming sinus-shaped signal.

Is this possible using the Teensy? If so, do there exist example code which I can use as a start? I have done some arduino programming but am a newbie when it comes to teensy and its audio library.

Best regards
I'm not sure that the Audio library will work well with a 70KHz signal. I think the Audio signal chain is designed around 44.1KHz sampling of signals up to about 20KHz. For a 70KHz signal you will need input amplifiers with greater bandwidth and faster sampling.

Detecting a low-amplitude 70KHz signal will probably require sampling at ~200KHz with an ADC. That's possible with the T4.x ADC converters, but processing the signal in real time will be difficult. If the signal characteristics are well-known, you could use correlation techniques to sift through the incoming data and add some precessing gain, but that will use a lot of CPU cycles.

Another possibility is to use a very narrow analog filter centered on the 70KHz frequency. Many years ago I used a very narrow 455KHz analog intermediate frequency filter designed for communications use. After amplifying and filtering I was able to detect the signal peaks.

Is this for an acoustic ranging application? The 1mSec accuracy is about 1 foot of distance accuracy. In a Teensy application a few years ago, I used chirps of about 10mSec with a frequency variation over the output ping. I used autocorrelation with the output waveform to detect the arrival time. The frequency variation and correlation gives you a better arrival time resolution than you would get by just looking at the peak amplitudes. The problem with that method is that the outgoing 10mSec pulse swamps the input signal and sets a minimum range.

I also did some experiments with 40KHz ultrasonic sources. I found that they didn't work as well as I had hoped. The transmitters are highly resonant and take several cycles to start up and don't work over a very wide frequency range. Thus my shift to a standard audio tweeter and frequencies in the 800-1200 Hz region.
Thanks for the reply mborgerson !

Since 70kHz seems challenging, I will reduce sender frequency to 44.1kHz.

I think your idea of use autocorrelation is good.

Will thereby try to :
1) Copy sampled data for a short time to memory
2) Perform autocorrelation and write result to ie. serial line
3) Wait for more data.

Do you know of code which could be a good start ?

Best regards
I did the correlation experiments about 3-4 years ago. I've attached a zip file with several sample sketches. Most were done with a T3.6, so that I could use the onboard DAC for signal output. I think you could probably get by with a 3-bit R2R resistor ladder to generate outputs for a pseud-sine wave with 8 levels. If you add an RC filter on the output, it will probably be good enough to drive a small speaker.

A 44.1KHz SIGNAL is still pretty fast. You will need to sample at more than 88KSamples per second to avoid aliasing. The T4.1 ADC can sample and record data up to about 1 millions samples/second, but you will need a high-bandwidth amplifier in your receiver.

See this thread for more information about high-speed sampling with the T4.1:

High-Speed ADC of T4.x

I'm pretty wrapped up in a USB project at the moment, but I'll see if I can update some of those 3-year-old sketches over the weekend.


  • 0_ChirpStuff.zip
    17.5 KB · Views: 9