Gas station without pumps

2016 March 13

Ultrasonic transmitter pulse shaping

Filed under: freshman design seminar — gasstationwithoutpumps @ 18:45
Tags: , ,

In Ultrasonic rangefinder with loudspeaker, I suggested that non-resonant transducers should be able to “get cleaner deconvolution of the echoes” and last week I wrote a program to try to design a ping that would do that.

  • I wanted the ping to have limited bandwidth (say 20kH–50kHz), so that I did not have to have a transducer that responded to very high frequencies, and so that the ping would not be audible to humans.
  • I wanted the ping to use only {–1, 0, 1} as values, so that it could be easily created with digital outputs from a microcontroller.
  • I wanted a fairly short duration for the ping, so that I could send it, then dedicate the microcontroller to listening for the echo.
  • I wanted the autocorrelation of the ping to have no large peaks after the maximum at τ=0, so that cross-correlating the sent ping with return echo would have (mostly) a single peak for each echo.  The sampling rate for the transmission should be the same as for the receiving, so that cross-correlation is easily computed.

The standard resonant transmitter/receiver with a 40kHz burst does fine on the bandwidth criterion and on the 3-value excitation, and ok on the ping duration.  That is, the ping can be triggered with a short excitation by the microcontroller, but the acoustic signal actually lasts much longer than the excitation signal. The autocorrelation criterion is completely missed, though, as there are strong autocorrelation peaks every 25µs.

I wrote a simple Python program to test the criteria for different excitation waveforms. The waveforms were expressed as patterns of {+1, –1} at 200kHz, which I know is achievable as a sampling rate.  If I can figure out how to set up DMA transfer from the analog-to-digital converter on the Teensy 3.1, then I should be able to use 240kHz, which would be better for comparison with a 40kHz resonant system, since I could then include a 40kHz symmetric ping (repeating 3 high, 3 low) for comparison.

To limit the duration of the ping, I looked only at ones that were exactly 2n samples long (16, 32, or 64, corresponding to 80µs, 160µs or 320µs).

I also looked at the FFT of the ping, and measured the energy within the passband (20kHz–50kHz).

I took the autocorrelation of the ping (by direct computation, rather than using iFFT(|FFT(ping)|2) ), and looked at the magnitude of the largest peak other than the one at τ=0.  The autocorrelation was scaled so that the 0-peak had magnitude 1.

Simple pings (like 5 periods of a 33.33kHz square wave) perform very well by the band-pass measure, but poorly by the autocorrelation measure (shifting over by one period results in a correlation peak that is 4/5 as big as the peak at 0).

I tried a few hand-designed pings, with very bad autocorrelation results, so I switched to making random pings, starting with +1 and having equal numbers of +1 and –1 (to avoid a DC component to the ping, which would have produced an audible click). I then did iterative improvement by swapping random pairs of values in the ping, checking an objective function that was a linear combination of the autocorrelation peak and the bandpass energy.  I found several good solutions this way, with different tradeoffs of energy outside the desired band and the size of the autocorrelation peak.  Changing the boundaries of the band also results in different solutions.  Here are few examples for 20kHz–50kHz, with a 160µs burst:

 [ 1., 1., 1., 1.,-1.,-1.,-1., 1., 1.,-1.,-1., 1., 1.,-1.,-1., 1., 1., 1.,
  -1.,-1.,-1.,-1., 1., 1., 1.,-1.,-1., 1., 1.,-1.,-1.,-1.]
#  bpe= 0.44538406194
#  max autocorrelate= 0.28125

 [ 1., 1.,-1.,-1., 1.,-1.,-1., 1., 1., 1.,-1.,-1., 1., 1.,-1.,-1., 1., 1.,
  -1.,-1., 1., 1., 1.,-1.,-1.,-1., 1., 1., 1.,-1.,-1.,-1.]
#  bpe= 0.41363760532
#  max autocorrelate= 0.1875

 [ 1., 1., 1.,-1.,-1., 1.,-1.,-1., 1., 1., 1.,-1.,-1., 1.,-1.,-1.,-1., 1.,
   1., 1.,-1.,-1.,-1., 1., 1., 1.,-1.,-1., 1., 1.,-1.,-1.]
#   bpe= 0.405535884864
#   max autocorrelate= 0.15625

Once I get a speaker that can produce some output up to 50kHz, I’ll try seeing what the signal looks like for these spread-spectrum pings.  I suspect that the low-pass filtering of the speaker and the microphone will result in a ping that looks very little like the excitation waveform, and that I’ll have to work a bit on coming up with a different strategy for producing a ping that I can cheaply deconvolve.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: