Sonar

Page 1

Corentin Macqueron – Promotion 2008

Research & Development Internship Report Summer 2007

CONCEPTION OF A

SONAR

1


Corentin Macqueron – Promotion 2008

ABSTRACT As a project in Research & Development at the Blekinge Institute of Technology during the summer 2007, Corentin Macqueron worked on a sonar prototype for Acoustic Agree AB. The goal was to determinate the profile of a surface using ultrasounds and automate it for some possible commercial applications.

KEYWORDS 

Sonar

LabVIEW

Acoustics

Matlab

Ultrasounds

Signal processing

Data acquisition

Filter

2


Corentin Macqueron – Promotion 2008

TABLE OF CONTENTS 1. Introduction................................................................................4 2. Objective.....................................................................................4 3. Basics of a sonar.........................................................................4 4. Equipment..................................................................................4 5. Emission......................................................................................5 6. Reception....................................................................................6 7. Signal processing........................................................................6 8. Analogous filtering.....................................................................6 9. FAST SONAR..............................................................................8 Correlation..................................................................................8 Virtual Instrument......................................................................8 Block-diagram.............................................................................9 10. SMART SONAR.......................................................................10 Digital filtering..........................................................................10 Correlation................................................................................12 Virtual Instrument....................................................................13 Block-diagram...........................................................................14 11. Conclusion................................................................................14 12. Appendix..................................................................................15 3


Corentin Macqueron – Promotion 2008

Introduction As a training period during the summer 2007, I worked on a Research & Development project in acoustics. The work was done in a laboratory of the Blekinge Institute of Technonoly in Karlskrona, Sweden, for a company named Acoustic Agree AB located in Ronneby.

Objective The project is to determinate the shape of an object using ultrasounds. A possible application would be to scan a car tire profile to determinate if it is too old to be used, but many other things could be imagined. Evaluate the shape of an object using ultrasounds might seem odd. A laser would probably be fare more precise because it is perfectly unidirectionnal and can be very thin. Nevertheless, ultrasounds might be more convenient. You may want for instance to scan someone's face but people may be afraid of a laser eventhough there are no risks. In this case, using a sonar producing only non-destructive and completely silent waves could be better. Anyway, this work was done in a research & development approach to determinate what could be done using ultrasound to scan a surface.

Basics of a sonar A sonar is like a radar but it is using sound waves instead of electromagnetic waves. In our case, we are using ultrasounds because human beings cannot hear them, which is very convenient. The main purpose of a sonar is to detect objects by sending a signal towards it and waiting for the echo. Considering the sound speed, the time of return will lead to the distance between the sonar and the obstacle. To determinate this time, the mathematical tool called cross-correlation is used. Applyed to emission and reception, it can determinate the delay in between.

Equipment To build our sonar we need to generate, acquire and process signals. To do so, we are using:      

a generator (Agilent 33220 A) an amplifyer (Vincent SP-331) a couple of ultrasonic transducers a communication device (National Instruments BNC-2110) a computer with LabVIEW and Matlab (OS: Windows XP, processor: Core 2 Duo) a carriage (from a printer)

4


Corentin Macqueron – Promotion 2008 The generator creates an electric wave which is amplifyed. This signal is converted into a mechanic wave in the air, using an ultrasonic transducer. The returning signal is reconverted into an electric wave using another transducer. This couple of transducers is settled on a carriage controlled by an electric engine. This mechanism allows us to scan the surface by moving the transducers at a constant speed (slow or fast). The computer controls both emission and acquisition of the signals trough the communication device. It is then possible to process the data in order to determinate the surface shape. LabVIEW is used to trig the generator and to acquire the returning signals through the communication device. Once the signals are acquired, the inner processing is performed by both LabVIEW and Matlab. The two softwares can communicate very easily. The whole process could have been done entirely with LabVIEW but as I was a novice with it, I preferred to do as many things as possible with Matlab because I have a good knowledge of this software. Emission We are sending sine burst towards the scanned surface. The generator creates 25 sine waves at a 200 kHz frequency and then shut down, waiting for the reception. Another burst can then be produced, and so on, at a 100 Hz frequency. Here you can see the sine burst:

The transducers appear to be very directionnal, as if we were using lasers. This is of a huge value because sound beams are usually spread in the whole space, making things very difficult to interpret. However, the sound beams are very large, which is clearly limiting the accuracy of the surface detection.

5


Corentin Macqueron – Promotion 2008 Reception As we are sending a sine burst, we are expecting the same sine burst in return with a delay corresponding to the distance. Nevertheless, things are not that simple. There are a lot of electromagnetic and mechanical disturbances: the generated signal is appearing on the reception channel, there is the omnipresent 50 Hz and other noise disturbances. All in all, we do not acquire a clear and beautiful sine burst but rather a messy signal:

Signal Processing In the acquired data, we can of course recognize where is our expected signal. But seeing it and automating it are two very different things. In between, there is signal processing. This is about extracting valuable information from a disturbed signal. Our brain achieves it very efficiently but we have to make the same on a computer. Analogous filtering We should obviously filter the reception as much as we can. As we are only looking for a 200 kHz returning signal, any other frequences such as 50 Hz disturbances should be removed. There are a lot of numeric filters available on both LabVIEW and Matlab but the first thing to do is to create a hardware filter. This is done with an analog bandpass filter made using passives high and lowpass filters:

6


Corentin Macqueron – Promotion 2008 These are made by soldering resistances and capacitors. As we are looking for a 200 kHz signal, we chose a 100 kHz stop frequency for the high-pass filter and a 300 kHz stop frequency for the low-pass filter, leading to a 100-300 kHz band-pass filter. To do so, we chose correct couples of values for R 1-C1 and R2-C2 to reach these stopfrequencies calculated as: f stop =

1 2  RC

 Hz

This leads to a 200 kHz bandwidth around the 200 kHz frequency we are looking for:

7


Corentin Macqueron – Promotion 2008

FAST SONAR Correlation Once the reception signal is acquired we are computing the cross-correlation between emission and reception using LabVIEW. We can thenfind the time delay and evaluate the distance to the obstacle. Virtual Instrument LabVIEW allows us to create a virtual instrument (VI), that is to say a device with screens, buttons and many other things in order to control or sonar. Here is the front pannel of the sonar VI:

This VI is rather simple. You can see the number of pulse, which is in fact the number of signals we are emitting. This value, combined with the speed of our transducers carriage, control the resolution and/or the size of the scanned area. Pulse count, emission/reception and correlation graphics are just data allowing the user to see in real time what is happening. The acquisition file is the name of the document where the data are saved. This document must me erased before each new measurement. In fact, this VI could be even simpler by being reduced to a single “push start button” and the way to the acquisition file to erase it.

8


Corentin Macqueron – Promotion 2008 Block-diagram LabVIEW is using the G programmation language. This is a graphical language, where usual programmation command lines are replaced by block-diagram drawings. The G code of our sonar is given below:

You can recognize the data from the front pannel of the VI: number of pulse, pulse count, acquisition file, emission/reception and correlation graphics. There are two main blocks in this code, represented by the two big grey boxes. They are executed sequentially. The left block is executed first, triggering the generator as many times as the “number of pulse” is set. For each pulse, reception signal is acquired. Its first hundred samples are canceled using a very simple Matlab command, in order to erase the emission parasite to avoid any confusion. This signal is then compared to the emission using a cross-correlation block. These three signals are plotted in real time. Each crosscorrelation is saved in the “aquisition file”, one after the other. When this sequence is over, the right block is executed. It is reading the saved data and executing the Matlab script which is evaluating and plotting the profile of the scanned surface. The Matlab script is given in appendix 1.

9


Corentin Macqueron – Promotion 2008

SMART SONAR When the reception signal is not clear, we obtain a wrong image of the profile we are trying to scan. This is because the correlation cannot determinate where is the reception in the messy signal. Sometimes the reception was even so weak that the correlation recognized the emission parasite as the returning signal which was, of course, not the case. That's why the first samples of the reception are canceled in the previous block-diagram. However, it is not always enough to extract the real returning signal. That's why we also worked on another signal processing algorithm in order to make the sonar more efficient. Digital filtering Analogous filtering was just a first step: the returning signal is still very messy. In order to extract a very clear information from it, we use a digital lowpass filter. As mentionned before, this can be found in both LabVIEW and Matlab, but the built-in filters didn't feet that well to our problem. That is why we decided to create our own filtering algorithm, mainly based on a mobile averaging method. This approach is effective because averaging tends to polish signals, absorbing brutal noise variations. Besides, the size of the averaging sample can delete any high-frequency signal when it is corresponding to its period. All in all, it allows us to extract a very clear peak. The process is illustrated below:

On picture #1 you can see the returning signal just as it is acquired. On picture #2 we have taken the absolute values in order to remove positive-negative oscillations. On picture #3 the mobile averaging filtering has been processed. On picture #4 you can see the final filtered signal. 10


Corentin Macqueron – Promotion 2008 The signals are stored in a matrix, with one dimension corresponding to the time and the other dimension corresponding to the space because the transducers are moving. Applying the filtering on both time and space dimensions provides more exploitable data:

Reception signals

Filtered signals

We now have a pretty clear image of the obstacle we are trying to scan:

On the left you have the pure signal, on the right the shape of the obstacle is superposed in black on the pure signal.

11


Corentin Macqueron – Promotion 2008 Correlation Now that we have extracted very clear peaks from our messy signals, we would like to determinate when these peaks are occuring. To do so, we are using the cross-correlation as before. But now, due to the filtering, the returning signal doesn't look like the emission anymore. The solution is to create a model which looks like the peaks we extracted, and it appears that a simple triangle signal suits very well to this problem (see picture on the right). The triangle model should of course begins at t=0, just as the emission. The cross-correlation is then applyed, leading to the time of return.

Here is the result provided by our sonar system:

This is of course a very simple example. The sonar is able to scan more complex shape but its resolution is limited by the very large sound beams it is using. It can basically provide a very good profile for about 5 mm sized obstacles. To reach a better accuracy, we could use more narrow beams.

12


Corentin Macqueron – Promotion 2008 Virtual Instrument Here is the front pannel of our smart sonar:

As for the fast sonar, this is a very simple VI, showing the number of pulse, the pulse count and plotting emission/reception graphics.

13


Corentin Macqueron – Promotion 2008 Block-diagram Here is the block-diagram G code of the smart sonar:

As before, you can recognize the data from the front pannel of the VI: number of pulse, pulse count, acquisition file and emission/reception graphics. There are still two main blocks in this code, executed sequentially. The left block is executed first, triggering the generator as many times as the “number of pulse” is set. Emission and reception are plotted in real time. Every returning signals are saved in the “aquisition file”. This block is not performing cross-correlation nor any signal processing, this is done in the right block sequence: it is reading the saved data and executing the Matlab script to do the signal processing. At the end, the profile of the scanned surface is plotted. The whole Matlab code is given in appendix 2.

Conclusion We managed to determinate the shape of an object using ultrasounds. The image is not always very clear but we definetely have interesting results. It was hard to get a good profile for a car tire because we were using too large sound beams but for bigger obstacles the sonar worked really well. The fast sonar is providing a very quick profile of the scanned object. The result will be fine if the returning signals were pretty clear, otherwise it will be completely wrong. The smart sonar can be used when this occurs. Even with messy reception, it is able to extract the reception in order to get the profile. However, the signal processing is more complex, leading to much slower results, from a few seconds to a couple of minutes sometimes. This work shouldn't stop there as many commercial applications are on its way. 14


Corentin Macqueron – Promotion 2008

APPENDIX Appendix 1: Matlab Script for the fast sonar: % SONAR PROJECT % % MATLAB SCRIPT IN LABVIEW % % ACQUISITION S=length(Y); % Looking for the size of the measurement vector s=S/999; % Splitting the continuous measurement vector % into smaller ones corresponding to each position euhar=zeros(999,s); % Matrix containing the s signals of 999 samples for i=1:s % Sweeping the s number of measurement a=999*(i-1)+1; % Beginning of the corresponding s-th vector (999 sample) b=999*(i-1)+999; % End of this vector euhar(:,i)=Y(1,a:b); % Capturing this s-th vector to fill the matrix end % TIME DELAY result=zeros(100,1); for i=1:s signal=euhar(:,i); check=max(signal); % Calculating the maximum of correlation for j=1:999 if euhar(j,i)==check % Looking for the maximum of correlation delay=j; % Calculating the corresponding delay (in number of sample) end end distance=340/2*delay*0.0005/1000*0.95; % Calculating the distance to the % obstacle (sample beeing converted % in time) result(i,1)=distance; % Final result end

plot(result,'linewidth',2) % Plot of the result 15


Corentin Macqueron – Promotion 2008

Appendix 2: Matlab Script for the smart sonar: % SONAR PROJECT % % MATLAB SCRIPT FOR SIGNAL PROCESSING IN LABVIEW % % ACQUISITION S=length(Y); % Looking for the size of the measurement vector s=S/500; % Splitting the continuous measurement vector % into smaller ones corresponding to each position euhar=zeros(500,s); % Matrix containing the s signals of 500 samples for i=1:s % Sweeping the s number of measurement a=500*(i-1)+1; % Beginning of the corresponding s-th vector (500 sample) b=500*(i-1)+500; % End of this vector euhar(:,i)=Y(1,a:b); % Capturing this s-th vector to fill the matrix end % SIGNAL PROCESSING % TIME FILTERING filtered=zeros(500,s); % Filtered 'Euhar' matrix MOY=zeros(500,1); % Prefiltering vector for tchouk=1:s % Sweeping the s number of measurement reception=abs(euhar(:,tchouk)); % Capturing the time vector % Canceling negative values % Mobile averaging filtering for e=50:450 % Sweeping (most of) the captured vector sum=0; % Initializing the averaging for i=0:99 % Summing on 100 samples sum=sum+reception(e-49+i,1); end moy=sum/100; % Averaging MOY(e,1)=moy; % Filling the filtered vector end MOY(1:150,1)=MOY(151,1); % Canceling the 150 first samples filtered(:,tchouk)=MOY; % Filtered signal put in the matrix end

16


Corentin Macqueron – Promotion 2008 % SPACE FILTERING MOY=zeros(s,1); % Prefiltering vector for tchouk=1:500 % Sweeping on the vectors size signal=filtered(tchouk,:); % Capturing the space vector % Mobile averaging filtering for e=50:s-50 % Sweeping (most of) the captured vector sum=0; % Initializing the averaging for i=0:99 % Summing on 100 samples sum=sum+signal(1,e-49+i); end moy=sum/100; % Averaging MOY(e,1)=moy; % Filling the filtered vector end filtered(tchouk,:)=MOY; % Final filtered signal for e=1:50 % Sweeping the first 50 sample sum=0; % Initializing the averaging for i=0:99 % Summing on 100 samples sum=sum+signal(1,e+i); end moy=sum/100; % Averaging MOY(e,1)=moy; % Filling the filtered vector end filtered(tchouk,:)=MOY; % Final filtered signal for e=s-49:s % Sweeping the last 50 sample sum=0; % Initializing the averaging for i=0:99 % Summing on 100 samples sum=sum+signal(1,e-i); end moy=sum/100; % Averaging MOY(e,1)=moy; % Filling the filtered vector end filtered(tchouk,:)=MOY; % Final filtered signal

17


Corentin Macqueron – Promotion 2008 end % TIME DELAY % MODEL SIGNAL recognition=zeros(500,1); % Creating a triangle model of the expected signal for i=1:100 recognition(i,1)=0.00065+4*10^-5*i; % First part of the triangle end for i=101:200 recognition(i,1)=0.00065+4*10^-5*100-4*10^-5*(i-100); % Second part of the % triangle end recognition(201:500,1)=0.00065; % Last part of the model (constant) % CROSS-CORRELATION result=zeros(s,1); % Time-delay result vector for tchouk=1:s % Sweeping the s number of measurement detection=xcorr(filtered(:,tchouk),recognition); % Calculating the cross % correlation between % reception and model signal for i=1:999 % Sweeping on the whole cross-correlation vector if detection(i,1)==max(detection); % Looking for the maximum of % correlation delay=i-500; % Calculating the corresponding delay (in number of % sample) end end distance=340/2*delay*0.0005/1000*0.95; % Calculating distance to obstacle % (sample beeing converted in time) result(tchouk,1)=distance; % Final result end

plot(-result,'linewidth',2) % Plot of the profile

18


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.