UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

A flexible system for the launch and reconstruction of localized acoustic waves Leung, Isaac Jing Herng 1996

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-ubc_1996-0345.pdf [ 10.24MB ]
Metadata
JSON: 831-1.0064841.json
JSON-LD: 831-1.0064841-ld.json
RDF/XML (Pretty): 831-1.0064841-rdf.xml
RDF/JSON: 831-1.0064841-rdf.json
Turtle: 831-1.0064841-turtle.txt
N-Triples: 831-1.0064841-rdf-ntriples.txt
Original Record: 831-1.0064841-source.json
Full Text
831-1.0064841-fulltext.txt
Citation
831-1.0064841.ris

Full Text

A Flexible System for the Launch and Reconstruction of Localized Acoustic Waves By Isaac Jing Herng Leung B.A.Sc. (Engineering Physics) University of British Columbia A thesis submitted in partial fulfillment of the requirements for the degree of Master of Applied Science  in The Faculty of Graduate Studies Electrical Engineering  We accept this thesis as conforming to the required standard  The University of British Columbia M a y 1996 © Isaac J. H. Leung, 1996  In presenting this thesis in partial fulfillment of the requirements for an advanced degree at the University of British Columbia, I agree that the Library shall make it freely available for reference and study. I further agree that permission for extensive copying of this thesis for scholarly purposes may be granted by the head of my department or by his or her representatives. It is understood that copying or publication of this thesis for financial gain shall not be allowed without my written permission.  Electrical Engineering The University of British Columbia 2075 Wesbrook Place Vancouver, Canada V6T 1W5  Date:  Abstract Abstract A synthetic array system for launching and reconstructing localized acoustic waves has been developed. This low cost system is easily changed to many different configurations and for many different experiments. The major components of this system consist of an ultrasonic transducer transmitter-receiver pair, a high bandwidth amplifier, a single axis motion stage and PC-based data generation, acquisition and control cards. In addition to the design and assembly of this system, the equipment was further characterized so that the performance characteristics can be accounted for in future experiments. The signal amplitude decay with increasing transmitter-receiver distance behaves approximately as predicted by theory. The amplitude remains relatively constant up to the near field boundary. In the far field, the signal amplitude decays at a rate inversely proportional to the transducer separation. Transducer response as a function of the angle between the transmitter and receiver studied. Experimental measurements showed that transmitted fields are highly directional, similar to that predicted by theory. A method was devised to reconstruct received signals. Signals are first processed to remove unwanted low frequency noise. The signal is then integrated twice to recover the original signal, as predicted by theory. A s a final confirmation of the operation of this system, a sample F W M pulse was generated using a 21 x 21 array of sources at a distance of 12 c m from the source array. The  Abstract reconstructed result is compared with the theoretically reconstructed result as well as the ideal F W M pulse. The experimental results show characteristics similar to that which is predicted by theory. A l l required equipment and procedures have been devised to launch localized acoustic waves with this system. The experimental setup is ready to begin further experiments in localized acoustic waves.  s  iv  Table of Contents  Table of Contents ABSTRACT TABLE OF CONTENTS LIST OF FIGURES  i iii viii  ACKNOWLEDGEMENTS  xi  BIBLIOGRAPHY  71  APPENDICES  74  1. INTRODUCTION  1  2. BACKGROUND  5  2.1. LOCALIZED W A V E S  5  2.2. G E N E R A T I N G L O C A L I Z E D W A V E S  8  2.3. P U L S E RECONSTRUCTION  9  3. EXPERIMENTAL SETUP  14  3.1. PROJECT G O A L S  3.1.1. Specifications:  14  14  3.2. S Y S T E M D E S I G N  14  3.3. E X P E R I M E N T A L EQUIPMENT:  15  Table of Contents 3.4. E X P E R I M E N T A L S E T U P  v 16  3.4.1.1. Gage CompuGen 840A  17  3.4.1.2. Gage CompuScope Lite  18  3.4.1.3. Keithlev-Metrabvte M S T E P 3  19  3.4.1.4. API CMD-50 Stepper Motor Driver  20  3.4.1.5. P C I 12" Motion Stage and Water Tank  22  3.4.1.6. Panametrics 3.5MHz Ultrasonic Transducers  25  3.4.1.6.1; Initial preparation of the transducers for use  27  3.4.1.6.2. Signal Generation and Reception Accuracy  27  3.4.1.6.3. Driving the ultrasonic transducer  30  4. EXPERIMENTAL RESULTS 4.1. A M P L I T U D E D E C A Y WITH DISTANCE  36 36  4.1.1. Background  36  4.1.2. Measurements  38  4.1.2.1. Decay at 3.5MHz  39  4.1.2.2. Decay at 2.5 M H z  41  4.1.2.3. Decay of F W M Source Pulse  43  4.2. A M P L I T U D E D E C A Y WITH A N G L E  45  4.2.1. Background  45  4.2.2. Measurements  47  4.2.3. R = 3 cm  48  4.2.4. R = 12 cm  49  Table of Contents 4.2.5. R = 20 cm 4.3.  SIGNAL RECONSTRUCTION  4.3.1. Reconstruction by integration  4.4.  vi 50 51  52  4.3.1.1. Background  52  4.3.1.2. Measurements  53  4.3.1.3. Curve Fitting the Offset  57  4.3.1.4. High Pass Filtering to Remove Offset  58  RECONSTRUCTION F R O M SYNTHETIC A R R A Y  60  5. CONCLUSIONS AND RECOMMENDATIONS  66  5.1'.  RESULTS  66  5.2.  RECOMMENDATIONS  68  APPENDIX A : E X P E R I M E N T A L EQUIPMENT  A. l Signal Amplifier  75  75  A. 1.1 Amplifier Design  75  A. 1.2 Amplifier Performance Characteristics  77  A P P E N D I X B: P R O G R A M FILES  B. l C Program Files  81  81  840_ctrl.h  81  840_ctrl.c  82  control.c  92  cs_ctrl.h  94  cs_ctrl.c  94  Table of Contents  vii  delays.h  98  delays.c  98  expmt.h  101  expmt.c  101  ms3_ctrl.h  Ill  ms3_ctrl.c  111  m_create.c  113  B.1.2 Maple Program Files  116  B.1.3 MatLab Program Files  118  draw_fwm.m  118  fld_calc.m  119  f_source.m  120  fwm_src.m  120  fwmrecon.m  122  process.m  123  processa.m  125  processf.m  127  psi_fwm.m  129  response.m  129  B.1.4 QuickBASIC Program Files  132  make.bat  132  motion.cmd  132  move6.bas  132  viii  List of Figures  List of Figures Figure 2-1: FWM pulse at distance 0.0357 m out from origin. Parameters k=88 m' and zo=6x!0~ m. 7 4  Figure 2-2 FWM source pulse for r-0.  9  Figure 2-3 FWM source at r = 9mm  9  Figure 2-4 Theoretical FWM pulse. k=9 m , zo=6E-5 m. 1  :  11  Figure 2-5 Reconstructed FWM. k=9 m ', zo=6E-5 m, 21x21 elements, element spacing=0.92mm_ 12 Figure 3-1 Overview of Experimental Setup  16  Figure 3-2 CG840A I/O ports, viewed from rear of PC.  17  Figure 3-3 CSLITE I/O Ports, viewed from rear of PC.  18  Figure 3-4 MSTEP-3 Connector, viewed from rear of PC.  ;  19  Figure 3-5 CMD-50 Stepper Motor Driver and required connections.  20  Figure 3-6 CMD-50 Stepper Motor Driver with installed heat sink.  21  Figure 3-7 Connections to control translation stage.  22  Figure 3-8 Motion Stage setup and Time-of-Flight estimates.  24  Figure 3-9 3.5MHz Ultrasonic Transducer  25  Figure 3-10 Schematic of Experiment setup.  27  Figure 3-11 2MHz bandwidth sinc(t) signal.  28  Figure 3-12 8MHz bandwidth sinc(t) signal.  29  Figure 3-13 FWM source pulse at r - 0 mm.  30  Figure 3-14 FWM source pulse at r = 9 mm.  30  Figure 3-15 2MHz bandwidth signal with transducer.  31  Figure 3-16 8MHz bandwidth signal with transducer.  33  Figure 3-17 FWM source at r - 0 cm with transducer.  34  List of Figures  ix  Figure 3-18 FWM source at r = 1.8 cm with transducer.  34  Figure 3-19 FWM source at r - 0 cm, xlO gain.  35  Figure 3-20 FWM source at r = 1.8cm, xlO gain.  35  Figure 4-1 Plot of approximate Near Field Length vs. Frequency for 6mm source.  37  Figure 4-2 Single cycle of 3.5 MHz sine.  40  Figure 4-3 Received signal characteristics.  40  Figure 4-4 Normalized Amplitude Decay vs. Distance  41  Figure 4-5 Single cycle of 2 MHz sine.  42  Figure 4-6 Received signal characteristics.  42  Figure 4-7 Amplitude Decay with Distance for -2.5 MHz signal.  43  Figure 4-8 Transmitted signal characteristics  44  Figure 4-9 Received signal characteristics  44  Figure 4-10 Amplitude Decay with Distance for FWM source signal  45  Figure 4-11 Beam divergence  46  Figure 4-12 Measuring Amplitude Dependence on Angle.  48  Figure 4-13 Amplitude as a function of the angle between source and receiver. R=3cm.  49  Figure 4-14 Amplitude response with angle at source-receiver distance ofR = 12 cm.  50  Figure 4-15 Amplitude response vs. Source-receiver angle at R-20cm.  51  Figure 4-16 FWM source at [8,0].  \  54  Figure 4-17 Received signal after integration.  55  Figure 4-18 Integration of received signal + offset.  56  Figure 4-19 Received signal after offset correction and integration.  57  Figure 4-20 FWM source at [0,0].  58  List of Figures Figure 4-21 FWM  X  source at [10,0].  58  Figure 4-22 [8,0] FWM  source pulse processed with high pass filter.  59  Figure 4-23 [0,0] FWM  source. High pass filter+integration.  60  Figure 4-24 [10,0] FWM  source. High pass filter+integration.  Figure 4-25 Ideal, theoretical FWM  60  pulse  61  Figure 4-26 Theoretical Reconstructed FWM  pulse. 21 x21  sources.  62  Figure 4-27 Experimentally  reconstructed pulse. Cuvefit correction.  63  Figure 4-28 Experimentally  reconstructed pulse. High pass filtering.  63  Figure 4-29 Theoretically  reconstructed pulse. Greyscale coded amplitude plot. (Top view ofpulse)64  Figure 4-30 Experimental  result (curvefitcorrection) Greyscale coded amplitude plot. [Top View] .65  Figure 4-31 Experimental  result (High pass filtering). Greyscale-coded  amplitude plot. [Top view].65  Figure A- J Amplifier Stage J  75  Figure A- 2 Amplifier Stage 2  ;  Figure A- 3 Amplifier Stage 3 Figure A - 4 Amplifier DIN  76 76  connector pin-outs.  77  Figure A- 5 Voltage Divider for limiting the input signal amplitude during testing  78  Figure A- 6 Input and Output Signals  78  Figure A-7  79  Amplifier Frequency  Response  Acknowledgements  xi  Acknowledgements Successful completion of this project would not be possible without the support and direction of my thesis supervisor, Dr. Matthew R. Palmer. H i s contributions have been invaluable in aiding my completion in a timely manner. I would also like to thank Nelson H o for his assistance in solving many experimental problems. Finally, I would like to acknowledge those people who believed in me even when I didn't. Oh, and last of all, let's give the Great Canadian Beaver three cheers.  Chapter v. Introduction  1  1.  Introduction  Over the past decade, ultrasonic imaging has become an indispensable tool in many areas of industry. The tools and methods associated with ultrasound imaging are relatively inexpensive, high-speed, robust and simple to operate. In addition, ultrasound is not an ionizing radiation and is therefore considered safe. The item being imaged is not altered or destroyed. These characteristics make it ideal for the two largest fields of application, nondestructive testing and medical imaging. In the general public, ultrasonic imaging is perhaps most well known from the applications in medicine. The ability to produce high resolution, real-time images with no harmful side effects makes this an extremely desirable tool in medicine. In addition to pre natal imaging, which is the most familiar application, ultrasound is also used for cardiac imaging, imaging of abdominal organs, detection of foreign masses in the eye and cranial imaging for specific head trauma cases. More recent developments include the use of Doppler ultrasound for measuring fluid or tissue velocity. Using this technique, cardiac motion or blood flow characteristics can be measured. While other medical imaging modalities (i.e. X - R a y , C T , P E T , e t c . ) generally make use of transmitted radiation, this is not the case with ultrasonic imaging. In general, the attenuation of sound waves in tissue is far too great for any useful signals to be detected through transmission. While there is active research in transmission ultrasound imaging, few practical applications have yet to be developed. Most commonly, ultrasound makes use of reflection to construct imagery. A s with electromagnetic radiation, reflection occurs at an interface between two media. The strength  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  2  Chapter /.- Introduction of the reflected wave depends on the difference in acoustic impedance between the two media. The acoustic impedance of various soft body tissues does not vary much. This means that only a small portion of the signal is typically reflected back for detection. In addition, secondary effects such as diffraction, absorption and scattering serve to further degrade the reflected signal, limiting the visual quality and resolution of the image.  There have been attempts to overcome some of these problems, especially diffraction, which can be a large contributor to poor resolution. The spreading of the ultrasonic wave through diffraction can be partially overcome by focusing, either through mechanical or electronic means. However, this can bring about other problems related to a specific depth of focus. For example, one method of mechanical focusing makes use of acoustic lenses. The depth of sharpest focus is fixed for a specific lens. In order image at a deeper or shallow depth, a different probe, with a different lens, must be utilized. While ultrasound remains a valuable tool for qualitative diagnostics, the problems mentioned above limit its usefulness as a quantitative diagnostic tool. Much of the current research in the field of ultrasonic imaging is aimed at rectifying this problem. Approaches include making use of transmission ultrasound, computed tomography (CT) ultrasound and ultrasonic holography. One of the most successful applications to date has been in the detection of breast cancer, which uses transmission ultrasound. The breast is a fairly ideal organ for quantitative ultrasound. It is relatively limited in thickness and it is composed of mostly uniform tissue. In addition, ultrasonic methods would be preferable to the conventional x-ray mammograms as  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  3  Chapter v. Introduction  ultrasound is so far known to have no harmful side effects, unlike, x-rays, which pose a small, but quantifiable, degree of risk. Ideally, in order to produce useful, quantitative results with ultrasound, the wave should have the following characteristics: uni-directional, uniform intensity, narrow focus and an extended near field. Over the past decade, new solutions to the scalar wave equation have been found which predict the possibility of highly localized waves which possess these ideal characteristics. There are many variations of localized waves, but all are related to the Brittingham (1983) waves which have been termed focused wave modes (FWM). These F W M ' s , in theory, propagate without diffraction. F W M ' s , just like monochromatic plane waves, have infinite energy and therefore have only theoretical implications. Superpositions or finite-energy approximations, termed localized waves (LW), are physically realizable. The main technical hurdle stems from the strong coupling between spatial and temporal wave components. Each source in an array designed to launch localized waves is required to be independently addressable as each excitation signal is unique. The goal of this project is to design, construct and to characterize a system for generating acoustic localized waves in water. The system is required to be flexible and easily modified in order to explore many different array configurations. Recent research in our laboratory suggests that a cylindrical source geometry may hold some advantages over simpler planar arrays (Allexandre, 1996).  M.A.Sc. Thesis  Isaac Jing Herng Leung  0 6 / 0 7 / 9 6  Chapter v. Introduction  .  The system developed through this work is expected to be critical in the further development and refinement of L W imaging systems. Applications include source design, propagation studies, scattering experiments and synthetic aperture imaging.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  4  5  Chapter 2: Background  2. 2.1.  Localized  Background  Waves  Brittingham (Brittingham, 1983) was the first to described localized waves, his version of which has been termed Focused Wave Modes (FWM). He was originally attempting to find solutions to the homogeneous Maxwell's equations with three-dimensional pulse structures which were continuous, non-singular and non-dispersive. The electromagnetic pulses resulting from these solutions carried infinite energy, which originally created some controversy. This work spurred interest in finding other packet-like solutions. This resulted in many related solutions, including: the modified power spectrum pulse (Ziolkowski, 1985; Ziolkowski, 1989) and X Waves (Lu and Greenleaf, 1992a; Lu et al., 1993). Palmer and Donnely (Palmer and Donnelly, 1993) have described the FWM as a solution of the free space scalar wave equation in moving characteristic coordinates. This result is summarized as follows. The homogenous scalar wave equation is: 1 d  2  (V -^^r)y =o  (M)  2  A  where:  y/h is the scalar wave propagating in a support medium with speed c. We can arbitrarily choose the z axis as the axis of propagation and define two  characteristic variables u = z - ct and v = z + ct. Substituting this into Equation (2-1) gives:  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 2: Background d ( V l + 4 — — )\ir =0 ouov 2  (2-2)  h  ,  where:  d  d  dx  oy  2  2  V , = -r-y + z—j, the transverse Laplacian. One possible set of solutions to Equation (2-2) is given by :  ^ = - _ — / ( v + -^—)  where:  (2-3)  / i s a continuous function, with continuous first derivative, p is the transverse distance, p = ^Jx + y , and 2  2  uo is an arbitrary constant. Suppose we choose u = izo and/(£.)=e' ^, where zo, k are real constants which can be k  0  arbitrarily chosen. Substituting into Equation (2-3) gives: ikp  1  =-^-e *e - ° u + iz ik  (2-4)  u u  ¥h  0  This solution is related to Ziolkowski's original derivation of the FWM solution (denoted here by fa) by the simple relation:  If we substitute into Equation (2-5) i///, and our characteristic variables u = z - ct and v = z + ct, we obtain:  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  7  Chapter 2: Background  (P (Z,PJ) = — " 4m[z + i(z - ct)] h  ____ Uz^^iU-O  .  (2  6)  0  k In order for cph to be bounded as p—>°°, it is required that — > 0 . However, as k and Zo can be arbitrarily chosen, this constraint does not present a problem. Varying k and zo w i l l vary different characteristics of the pulse, including shape and temporal spectrum. Figure 2-1 is a plot of a F W M pulse using the parameter values z.o =8x10' m and k = 88 m . 4  Theoretical  1  FWM  Figure 2-1: FWM pulse at distance 0.0357 m out from origin. Parameters k=88 m' and z_=6x10' m. 1  M.A.Sc. Thesis  Isaac Jing Herng Leung  4  06/07/96  Chapter 2: Background 2.2.  Launching  Localized  Waves  In this project, a rectangular grid of source elements will be employed in launching acoustic waves. The procedure for designing the excitation depends on an approximate Huygen's reconstruction. This is derived in Ziolkowski(1991) and also Palmer (1995) and won't be repeated here. The result is: FWMiz, t)-—  + —  s  Pt  where:  SFWM  (2-7)  is the sound pressure distribution on a plane orthogonal to the z-axis.  We can further simplify Equation (2-7) to suit our needs if we make the arbitrary choices that the z-axis will be the chosen axis of propagation and that the pulse starts at z=0. Including the above assumptions and making the appropriate substitutions for u and v, we obtain another description for the source functions: 2  f FWM  S  (x,y,z,t) = (p (0,Jx  2  h  +  y\t)  2  ik(x +y ) (z + Kz - ct)) 0  i z + Kz - ct) 0  ^ +  (2-8)  IK  J  So, in practice, we merely need to be able to describe the location of a particular source in (x,y,z) coordinates. Once this is done, Equation (2-8) can be used to calculate the required pulse. These source functions have two particular characteristics which make them difficult to deal with in practice. One characteristic is that virtually each source function is unique. Only sources that are situated at exactly the same distance from the origin share the same function. Other sources are completely different and are not related by any simple relation.  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  Chapter 2: Background The other characteristic is that the sources are broadband functions. In practice, developing equipment that will perform well over a large range of frequencies can be difficult. FWM Source at r = 9 mm  FWM Source at r = 0 mm  X 10'  ! 0  Ampi  1  -0.8  -0.6  -0.4  -0  2  0  time (s)  >  02  0.4  0.6  0  8  1  xtO^  1  FWM Source Frequency Spectrum  FWM Source Frequency Spectrum  X10*  5  3  2 1 0  -I )  \. 0.5  1  ;  \  1.5 2 2.5 Frequency (Hz) — ->  3  3.5 X10°  Figure 2-3 FWM source at r = 9mm  Figure 2-2 FWM source pulse for r=0.  Figure 2-2 and Figure 2-3 shows two sample source signals at different distances from the origin. As can be seen on the plot of the signal frequency spectrum, the bandwidth of these signals are in the order of MHz. 2.3.  Pulse  Reconstruction  The final step in the process is to be able to reconstruct an approximation of a localized wave given the known sources. Given an infinite and continuous source array, this M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 2: Background  1o  approximation should be exactly equal tofa.For a planar array, it can be shown that the reconstructed signal can be described as a function of the source by: r* r / (x,y,z,r) = -J  I W  J?  where:  f  R  f  v  x',y\z\t-—  R\i  1  -—dx'dy'  (2-9)  R distance +(y-y') of the observation tothis the source (Ris=the j(x-x') +(z-z'f point ) in case location. 2  2  z' = 0 for a planar array on the x-y plane For the infinite case, X—>°° and Y—>°°. But of course for the real world, this is not possible and so X and Y will assume finite values. Furthermore, it is not possible to obtain a continuous source array, therefore, Equation (2-9) needs to be adapted for the discrete case. For an array of (2M+1) x (2/V+l) sources, the integration should be expressed as a summation and the appropriate equation becomes: 1  = - ^ Y,~nr~ FWM n=-N m=-M ^7tR  f (x,y,z,t)  s  R  I mAx,nAy,z',t  R i — AxAy  (2-10)  mn  where:  Ax is the element spacing in the x direction Ay is the element spacing in the y direction R  mn  (R  is the distance from the observation point to the [m,n] array element = ^(x-mAx)  2  mn  + (y - nAy) + (z - z'f ) in this case 2  z' = 0 for a planar array on the x-y plane  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  Chapter 2: Background  11  Using Equation (2-10), we can now fully simulate the results of launching a F W M pulse from an M x N array of discrete sources at any distance out from the planar source along the z-axis.  Theoretical  FWM  Figure 2-4 Theoretical FWM pulse. k=9 m" , z„=6E-5 m. 1  Figure 2-4 shows the theoretical F W M pulse at some distance out from the source (12 cm). Figure 2-5 shows a reconstructed F W M pulse, at the same distance and using the same parameters. The simulated array has 21x21 source elements and spacing between the elements is 0.92mm.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 2: Background  12  Reconstructed  FWM  Figure 2-5 Reconstructed FWM. k=9 m'\ z„=6E-5 m, 21x21 elements, element spacing=0.92mm  For computational purposes, we can express Equation (2-10) in a different way. If we assume a rectangular array centered at the origin with equally spaced sources in both the horizontal and vertical directions. Then, we can make use of the symmetry of the situation. The x-axis (horizontal) can be arbitrarily chosen to be the axis of symmetry. Furthermore, we can arbitrarily choose the observation point to be only parallel the x-axis (for a given distance out along the z-axis) and co-planar with the y=0 plane. Each source on x>0 w i l l be exactly the same distance away from our observation point as its counterpart on x<0. Therefore, we can simply double the contribution from each source, with the exception of those along the xM.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 2. Background  13  axis (y=0), of which there is only one set of sources. The reconstructed FWM pulse can then be computed using: M  /?  f  i  i V  f (*,y,z,t) R  N  AT 2  I  M M  I  = -J, j  —  AKR "V0 H /  m=-M  f  i  7^ AJZR  *  SPWM  S  F  W  M  \  ^\  mAx,0,z',f-- m O- AxAy V c ) R  mAx, nAy, z\t  \  2ai  (2-11) V  — AxAy  C J  While Equation (2-10) requires (2M+1)(2N+1) summations, Equation (2-11) only requires (2M+1)(N+1) summations. For comparison, consider a 21 x 21 array (elements go from x=[-10 10] x y=[-10 10]). Using Equation (2-10) would require 441 summations, but Equation (2-11) uses only 231 summations. So using Equation (2-11) would take only 52% the computation time that Equation (2-10) would.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  14  Chapter 3: Experimental Setup  3. 3.1.  Project  Experimental Setup  Goals  The purpose of this project is to construct a system for investigating acoustic localized waves. In preparing such a system for use, the pertinent parameters of this system must also be characterized. Although focused wave modes have potential applications in many areas, our main interest lies in medical imaging. Therefore, the experimental equipment will be designed to operate at frequencies most useful to medical ultrasonic imaging. 3.1.1. Specifications: The following is a list of the main criteria which had to be considered for the specification of this system: 1. it should operate at frequencies of interest in medical imaging. (-1-10 MHz); 2. it should have a flexible configuration and 3. be constructed for a limited budget of -$5000 for new equipment acquisitions. 3.2.  System  Design  Due to the requirement for a flexible system setup, a design based on synthetic aperture and synthetic field sampling is an obvious choice. A single degree of freedom motion stage was chosen.. Although this does not limit the types of experiments that can be performed, it does require extra time to set up and operate the system.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 3: Experimental Setup 3.3.  Experimental  15  Equipment:  This system design required the following pieces of major equipment: (  M.A.Sc. Thesis  A  Existing equipment)  1  IBM compatible i486 PC A  1  PC D/A board [Gage CompuGen 840A] A  1  PC data acquisition board [Gage CompuScope Lite] ^  1  PC step motor controller board [Keithley-Metrabyte MSTEP 3]  1  single axis motion stage with 12" travel [DO-12]  1  stepper motor  1  stepper motor driver and heat sink [API CMD-50]  2  3.5 MHz, 0.25" diameter ultrasonic transducers [Panametrics V384]  2  2 meter waterproof UHF to BNC cables  1  high bandwidth receiver amplifier  1  -80 cm x 60 cm x 60 cm Plexiglas water tank^  Isaac Jing Herng Leung  06/07/96  16  Chapter 3: Experimental Setup  3.4.  Experimental  Setup  Figure 3-1 Overview of Experimental Setup  The CompuGen 840A, CompuScope Lite and MSTEP-3 are all installed in the i486 PC. Each card is attached to the appropriate device. The CompuGen D/A waveform generator drives one of the transducers at a signal level up to ±10 V. The CompuScope Lite data acquisition board receives signals from the other transducer, after amplification by a custom built 3-stage, programmable gain amplifier. Finally, the MSTEP-3 stepper motor controller is used to control the translation stage. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  17  Chapter 3: Experimental Setup  3.4.1. l.Gase CompuGen 840A This D/A waveform generator board is equipped with 3 I/O connectors: 1)  BNC trigger input;  2)  pin digital output; and  3)  BNC analog output.  Trigger In  SNC  Digital Out  20 pin  Analog Out  BNC  Figure 3-2 CG840A I/O ports, viewed from rear of PC.  The analog output generates signals between ±1 V, ±2 V, ±5 V and ±10 V corresponding to gain levels of x l , x2, x5 and xlO. For most of the experiments, xlO gain is required to obtain measurable signal levels. This D/A board is capable of 8 bit output at 40Msamples/second. Therefore, it is suitable for generating signals up to a theoretical maximum of 20 MHz. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 3: Experimental Setup  18  3.4.1.2.Gage CompuScope Lite The CompuScope Lite data acquisition board has 3 input BNC connectors: 1)  trigger input;  2)  channel A input; and  3)  channel B input.  Trigger In  BHC  Channel A Channel B In In  BHC  BHC  Figure 3-3 CSLITE I/O Ports, viewed from rear of PC.  This A/D card is capable of sampling at a maximum rate of 40Msamples/s on a single channel or 20Msamples/s on both channels simultaneously. Full scale input voltage range on each channel is ±1 V or, when x5 gain is specified ±200mV. For most of the experiments, one channel is set to x l gain and the other to x5.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  19  Chapter 3: Experimental Setup  3.4.1.3.Keithle\-Metrab\te MSTEP 3 I/O through this board is accessed through a 50 pin connector. Relevant connections are shown in the diagram and table. The connector on the PC card is 3M (Scotchflex) #3433-5303. For ribbon (insulation displacement) cable, the mating connector is 3M #3425-6050.  A Axis Step Pulse Output  A Axis Direction Output  timit 2 Input  timit 1 Input  Figure 3-4 MSTEP-3 Connector, viewed from rear of PC.  Connections required between the M S T E P - 3 controller card and the C M D - 5 0 Stepper Motor driver are: Table 3-1 MSTEP-3 to CMD-50 connections.  Pin 4  A A x i s Direction  (Output from card)  Pin 5 Pin 27 Pin 28  A A x i s Step Pulse A Axis Limit 1 A Axis Limit 2  (Output from card)  Pin 31  Ground  M.A.Sc. Thesis  (Input to card) (Input to card)  Isaac Jing Herng Leung  06/07/96  20  Chapter 3: Experimental Setup 3.4.1.4.API CMD-50 Stepper Motor Driver The C M D - 5 0 Stepper Motor Driver has a total of 15 terminals. However, not all of  the terminals are used for the current experiment. Inputs that are not connected are internally pulled up to logic H I (+5 Volts).  MSTEP-3 A Axis Step Pulse PIN 5 MSTEP-3 A Axis Direction PIN 4 + 5 Volts  RUN/RESET  LP  HAir/riSr  .SJJEP.JHL .cuZEciT.  > *P  CIR/ NON  5j  8 | via  z p  S> |  It  < § Z  .cannon..  Stepper Motor| Black W i r e  v  r  ENA/NOPWR  .sitacjH.  Stepper Motor White W i r e  5  Stepper Motor] Green+White Wire  S  JOP  Stepper Motor| Green W i r e  GROUND  .£RbL.  MSTEP-3 Ground  -REE. -Kill.. .+i!PJLIA££..  Stepper Motor| Red W i r e Stepper Motor| Red+White Wire + 15 Volts  Figure 3-5 CMD-50 Stepper Motor Driver and required connections.  •  STEP IN (left pin 3) connects to MSTEP-3: A AXIS STEP PULSE (pin 4)  •  CW/CCW (left pin 4) connects to MSTEP-3: A AXIS DIRECTION (pin 5)  •  5VDC IN (left pin 7) connects to a +5 Volt power supply.  •  RQI (left pin 8 and 9) connects to a ~6.34kJ3 resistor.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 3: Experimental Setup •  21  COMMON GROUND (left pin 10) connects to MSTEP-3: GROUND (pin 31) as well as most other  grounds, including +5 V ground and +15 V ground but not Stepper Motor (black wire and white wire), which are tied together and left unconnected.  •  G/W (right pin 5) connects to Stepper Motor: White with Green stripe wire.  •  GRN (right pin 4) connects to Stepper Motor: Green wire.  •  RED (right pin 3) connects to Stepper Motor: Red wire.  •  R/W (right pin 2) connects to Stepper Motor: White with Red stripe wire.  •  +V0LTAGE SUPPLY (right pin 1) connects to a +15 Volt power supply. The driver will support up to 40 Volts maximum. However, it is recommended that not more than 20 Volts input is used. In addition to the electrical connections, the heat sink for the C M D - 5 0 is required in  order to keep the motor driver within safe temperatures during operation.  CMD-50 Stepper Motor Driver  Figure 3-6 CMD-50 Stepper Motor Driver with installed heat sink.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  22  Chapter 3: Experimental Setup  Figure 3-7 shows a schematic of the connections required for controlling the translation stage with the PC.  <3reen+White/ Green :' Red:' Red+White-  N/C^L| N/C-^  CMD-50 Stepper M o t o r Driver  4  3 2  N/C-5  To MSTEP-3  (T)l5VDC  34knjP~^  o  h  5VDC  ^  6A  —  Superior Electric M063-LS-502 Stepper Motor  ai =  °- c o o in u 27 28 Axis Limit Switches  Figure 3-7 Connections to control translation stage.  3.4.1.5.DCI 12" Motion Stage and Water Tank The motion stage is driven by a single 2.25 Volt, 4.6 Amp stepper motor. The motor is capable of both full step and half step operation. The lead screw on the motion stage has a claimed repeatable accuracy of 0.0008 in. (0.00002032 m) and is specified to move the motion stage at 0.00508 m / revolution. The water tank measures approximately 80cm x 60cm (viewed from the top). However, the motion stage is not long enough to span the 60cm width of the water tank. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  23  Chapter 3: Experimental Setup  Therefore, the motion stage is first mounted on aluminum spars long enough to span across the length of the water tank. The mount for the receiving transducer is attached to the metal spars of the motion stage. By mounting the receiving transducer directly on the base plate, motion from the surrounding environment is effectively negated as the source and receiver will maintain their relative positions. The motion stage is positioned across the length of the water tank at a position ~20cm from one edge. This is done to maximize the time required for any (unwanted) reflected signals to arrive at the receiving transducers. Let us define an experimental region within the tank, approximately 30 x 20 x 20 cm in size and centered within the tank. The length of the transmitted pulses are on the order of 50 pis or less. If the transmitter and receiver are position at opposite ends of the experimental region, we can then calculate that the total time of flight (TOF) required to transmit the pulse and the time required to receive the entire pulse is approximately 200 |is. Considering the same situation, if we calculate the TOF for pulses reflected off the tank walls, we can find that it will require approximately 400 [is for these reflected pulses to arrive at the receiver. Therefore, it is quite certain that unwanted reflections will not be received along with the direct pulse and sound absorbent material on the water tank walls is not required.  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  Chapter 3: Experimental Setup  M.A.Sc. Thesis  24  Isaac Jing Herng Leung  06/07/96  Chapter 3: Experimental Setup  25  3.4.1.6.Panametrics 3.5MHz Ultrasonic Transducers 2 ultrasonic transducers are used in this system. One is as the pulse generator and one as the receiver. The operational characteristics are nearly identical, as expected The transducers are immersion transducers originally UHf Connector  designed for use in N o n Destructive Testing ( N D T ) 0-Rinq  applications. Operating frequency is centered at ~ 3 . 5 M H z . The active diameter is 0.25"  P a n a m e t r i c s U l t r a s o n i c Transducer 3.5 M H z 0.25" d i a m e t e r (unfocused)  and they are designed to  unfocused. The Panametrics  Figure 3-9 3.5MHz Ultrasonic Transducer  transducers are designed to be operated using a large negative going pulse (in order avoid overheating the transducer and to avoid depoling the piezoelectric crystal) with the maximum energy not exceeding 125mW. Although negative going pulses are not used in these experiments, the pulse power levels are low enough such that damage is not expected to occur to the transducers. The transducers are typically designed to use pulses of several hundreds of volts and milliseconds in duration. Using the technical notes supplied by Panametrics, we can obtain an estimate of the maximum voltage that can be applied to the transducers or our particular operating conditions. Three equations are used in this estimation:  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  26  Chapter 3: Experimental Setup  1 K =-(0.707)V,  peak-peak  TO  (DutyCycle)(V  )  cos(PhaseAngle)  2  rmx  P„  total (Frequency)(Duty  where:  V'peak-peak  Cycle)  Rate  (3-3)  is the peak to peak voltage;  V ,ns  is the RMS voltage;  ^rofa/  is the total power;  r  (3-2)  z  burst  (3-1)  Z is the impedance at the transducer input; Nburst-is  the number of cycles in a burst; and  Rate is the rate of repetition (of bursts). For this particular experiment, we know the following values: Rate < 1 Hz; Nburst = h IZI -50 Q and 0.5 MHz < Frequency < 10 MHz  Using Equation (3-3), and using values to maximize the DutyCycle, we can calculate that DutyCycle = 2x10-6 s/s. Now, using Equation (3-2), assuming maximum allowed power (125 mW) and cos(PhaseAngle )=1, we can calculate that V -1767 V. Finally, using rms  Equation (3-1), the maximum allowable value for V  k-peak^  pea  approximately 5000 V. The  maximum capability of our system is 20 Volts peak to peak, so we are well under the design limits.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  27  Chapter 3: Experimental Setup  3.4.1.6.1.Initial preparation of the transducers for use  The transducers are connected to the data generation and acquisition equipment via waterproof UHF-BNC cables. These are regular UHF-BNC cables which have the UHF end rendered waterproof using a silicone based sealant. The system was quickly assembled for a few initial tests to make sure that all components were working and to fix major problems, if any, with the equipment setup. Figure 3-10 shows a diagram of the experimental setup. A 50Q terminator was connected output line to ensure a proper output load matching for the D/A generator. Transmit  •  x  Receive  —7  .  •  —> X  Gage  Gage  CompuGen 840A  CompuScope Lite  D/A  A/D Trigger  Figure 3-10 Schematic of Experiment setup.  3.4.1.6.2.Signal  Generation and Reception  Accuracy  The first test was to determine if the CompuGen 840A would be capable of accurately reproducing the desired signals. The CompuScope Lite was used to record the signal directly from the CompuGen 840A's output. Both boards were operated at 20 Msamples/second.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  28  Chapter 3: Experimental Setup  Figure 3-11(a) shows a sinc(t) signal with a theoretical 2MHz bandwidth. 256 points were used in the calculated signal. Figure 3-11(b) is the received signal with no averaging and Figure 3-11(c) shows a 20 mean average of the received signals. (a) C a l c u l a t e d S i g n a l ! A i  A  •  •  •  0.8  1 0.6 2  o.4  CD  3  0.2  CL  £  0  -0.2  i  -6  i  - 4  I  -2  0 t i m e (s)  I  I  2  I  4  >  x  1 0  6 -6  (b) R e c e i v e d S i g n a l  A i  0.8  !  0.6  S  0.4  CD "O  3  0.2  CL  1  0  -0.2  i  -6  - 4  -2  0 t i m e (s)  2  6 .  4  >  x10"  6  (c) R e c e i v e d S i g n a l ( a v e r a g e d ) I  I  A i  I  I  I  0.8  !  0.6  2  0.4  CD  3  0.2  CL  -0.2  i  -6  - 4  -2  i  i  i  i  0  2  4  6  time(s)  >  x10"  Figure 3-11 2MHz bandwidth sinc(t) signal.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  6  29  Chapter 3: Experimental Setup  Figure 3-12 shows another sinc(t) signal. Again, 256 points were used to calculate the signal. This time, the theoretical bandwidth of the signal is 8MHz. This is close to the Nyquist frequency for 20MHz sampling, so the signal reproduction is not expected to be as good as that of a 2MHz signal. (a) C a l c u l a t e d S i g n a l  0.8  A i i i >  0.6  0.4  <D -CT _g ]§<C  0.2 0  -0.2 -6  -4  -2  0 t i m e (s)  2  4  >  6 x10"  6  (b) R e c e i v e d S i g n a l  0.8  A i I I >  0.6  0.4  "CT  zzy  "g<c  0.2 0  -0.2 t  -6  -4  -2  0 t i m e (s)  2 >  4  6 xlO"  Figure 3-12 8MHz bandwidth sinc(t) signal.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  6  30  Chapter 3: Experimental Setup  In addition, two FWM source pulses were arbitrarily chose for the test (the relevant parameters are k=12 m' , zo=6xlO' ni). Figure 3-13 shows the FWM source at r = 0 mm and 1  5  Figure 3-14 shows the FWM source pulse for r = 9mm. (a) Calculated Signal  (a) Calculated Signal OB 0.6  "  I i  i  \  A  i  '  0  4  : :>  [  :  !..  !  L  i  ;  -0.6  i  :  -4  -2  0 time(s)  >  2  4 x 1 0  6 -«  -6  -4  y  ^  —  !  1  -0.8 -6  1  "1  AmpIIjtude  i  -2  C time (s  >  2  6  4  X10"  8  (b) Received Signal  (b) Received Signal 0.8 0.6  o  v  i  , ^ ; ,,.... .,. J..... V  V  K  ,,..J  _ i,  o  ,  AmpI «ude(V).-  :> oT  0.4  :  )  A  -U.I  -0.8  ;  ; -6  -4  -2  0  lime(s)—>  2  4  -6  J  -4  ;  .  :  !  -2  0 lime (s) — >  2  6  4  X10"*  Figure 3-14 FWM source pulse at r = 9 mm.  Figure 3-13 FWM source pulse at r = 0 mm.  3.4.1.6.3.Driving  6 X 1 0  ,,L  the ultrasonic  transducer  The next test was to determine the ability of the CompuGen 840A to drive the ultrasonic transducers. The output signal is again measured with CompuScope Lite directly connected to the D/A output. Both boards are operated at 20Msamples/second. The output signal was recorded as in the previous test, and also with the transducer connected directly to the D/A output. The D/A output was set to maximum output levels of ±1 Volt. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  31  Chapter 3: Experimental Setup  The first test signals are sinc(t) signals, which were used in the previous test. Figure 3-15 shows a 2MHz bandwidth signal. At this frequency, the CompuGen 840A appears to have no trouble driving the transducer at this voltage level. (a) C a l c u l a t e d S i g n a l i A  i  1 ^  i  A  •  •  •  0.8 0.6 0.4  CD  TD  B  0.2  Q_  £  0  -0.2  •  i  -6  -4  I  -2  I  0  I  2  t i m e (s)  I  4  6  >  x10"  6  (b) R e c e i v e d S i g n a l ( n o t r a n s d u c e r ) i A  i  1 S  i  L  !  !  !  0.8 0.6 0.4  CD  TD  B 0.2 o_  1  0  -0.2  i  -6  i  -4  I  -2  I  0 t i m e (s)  I  2  I  4  >  x1  0  6 - 6  (c) R e c e i v e d S i g n a l ( w i t h t r a n s d u c e r ) ;  A  i  ! ^  I  jn  I  0.8  !  !  !  [  0.6  j  0.4  CD  TD  B 0.2 ex.  1  \]  0  -0.2  \j  i  i  i  i  i  i  i  -6  -4  -2  0  2  4  6  t i m e (s)  >  x10~  Figure 3-15 2MHz bandwidth signal with transducer.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  6  Chapter 3: Experimental Setup  32  Figure 3-16 shows the result from a 8MHz bandwidth sinc(t) signal. At this frequency, the signal reproduction is clearly inferior to that of a 2MHz signal.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  33  Chapter 3: Experimental Setup (a) Calculated Signal 0.8 0.6 CU  TD  ~cL E <  0.4 0.2 0  -0.2 h  -4  -2  6  0  time (s)  >  x 10"  (b) Received Signal (no transducer) A  0.8h  !  0.61  i  -0.2 0  -4  time (s)  x 10  (c) Received Signal (with transducer)  CD  TD Z3  < -0.2 0  -6  time (s)  >  x 10  Figure 3-16 8MHz bandwidth signal with transducer.  FWM source functions were also tested with and without the load of the transducer. Arbitrary source functions were again chosen. However, this time, the relevant parameters M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  34  Chapter 3: Experimental Setup  used (k=9 m' , zo=6x!0~ m) were selected with the aid of simulations and taking into 1  4  account the performance limits of the translation stage. The values selected are intended to be used in an actual, experimental measurement. Figure 3-17 shows the FWM source at r=0 cm and Figure 3-18 shows the FWM source at r=1.8 cm. Both are reproduced fairly accurately, even when loaded with the transducer. (a) Calculated Signal  (a) Calculated Signal  -1  (b) Received Signal (no transducer)  (c) Received Signal (with transducer)  (c) Received Signal (with transducer)  Figure 3-17 FWM source at r = 0 cm with transducer.  Figure 3-18 FWM source at r = 1.8 cm with transducer.  The same test was repeated for gain levels of x2, x5 and xlO. At these higher output levels, a voltage divider (using a lOkQ POT) was used to scale down the signal levels to ±1 Volt so that it could be recorded using the CompuScope Lite. The results were similar to the  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  35  Chapter 3: Experimental Setup  x l case, except at x 10. At a gain setting of xlO, the output waveform was slightly distorted, regardless of whether the transducer was connected or not. Figure 3-19 and Figure 3-20 show the FWM sources at a xlO gain. Although the wave form is distorted, the CompuGen 840A is able to reproduce approximately the same wave form, with or without the transducer connected. (a) Calculated Signal  -6  -4  -2  bi o O in  >  *  \  v  Amplitude (V)  Ul o Ul O  \ .  i  Amplitude (V)  o  >  -  \  o  (a) Calculated Signal  0  time(s)  >  2  -6  6  4 X  1  Q  - 6  -4  >  2  6  4 X  1  Q  - 6  > ui  p  |  X  1  0  - E  X  1  Q  - 6  0.5  >  o o bi  0  time(s)  (b) Received Signal (no transducer)  (b) Received Signal (no transducer)  Amplitude (V)  -2  V  0  -  •  |-0.5 -6  -4  -2  0  time(s)—>  2  -6  6  4 x 1 Q  -«  -4  0  -4  -2  time  0 ( s )  — >  2  6  4 x 1 0  Figure 3-19 FWM source at r = 0 cm, x10 gain.  M.A.Sc. Thesis  4  6  _.  p  bi  —>  "5. E -0.5 < -6  2  o  QT  >  o ui  V  -  Amplitude (V)  j 0.5  0  time(s)  (c) Received Signal (with transducer)  (c) Received Signal (with transducer)  >  -2  -6  -4  -2  0  lime(s)—>  2  6  4  Figure 3-20 FWM source at r = 1.8cm, x10 gain.  Isaac Jing Herng Leung  06/07/96  36  Chapter 4: Experimental Results  4.  Experimental Results  All following experiments were performed using the equipment set up shown in Figure 3-10 with the addition of the connection between the PC and the translation stage. 4.1.  Amplitude  Decay with Distance  4.1.1. Background  All real sources have a characteristic near field and far field distance. In the far field, the source appears and behaves like an infinitely small point source radiator. In the near field, this is not the case. Spherical wave fronts will not be observed and the wave amplitude does not decrease inversely proportional to the distance from the source, as would be seen in the far field. In fact, the amplitude of the signals will remain relatively constant in the near field. The length of the near field of any particular source can be closely approximated by the following equation (Panametrics Technical Notes): (4-1)  d = length of near field  where:  N  D = diameter of source A = wavelength of the source signal This equation is empirically derived for ultrasonic transducers. It is valid only when D »X.  The exact equation is quite complex and Equation (4-1) suffices for an estimate.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  37  Chapter 4: Experimental Results  Figure 4-1 shows a plot of the near field variation with frequency for the Panametrics transducers which have an active diameter of approximately 6 mm. This plot is obtained using Equation (4-1) and the relation: c = Xv where:  (4-2)  c = speed of sound in the medium (-1540 m/s in water at 20°C); A = wavelength; and v = frequency.  — 0.02  " ' O  1  2  3  4 5 Frequency (Hz)  e  ~7  S  9  lO x  ,  0  ©  Figure 4-1 Plot of approximate Near Field Length vs. Frequency for 6mm source.  In practice, this increase in near field length does not occur like this. This is because the acoustic impedance of a particular medium varies with frequency. In the case of water (or animal tissue), the acoustic impedance increases rapidly as frequency is increased and signal  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  38  Chapter 4: Experimental Results  amplitude begins to drop off earlier for high frequencies than would be predicted by Equation (4-1). In addition, any real signal contains a spectrum of frequencies and the actual near field length is a combination of the results from all the frequencies contained in the signal.  4.1.2. Measurements Although equation (4-1) is accurate, in practice it can be difficult to apply to any detailed measurements. This is partly due to the usual uncertainties in measured values. Most of the problem, though, is in producing a source signal with a single, unique frequency. This is generally not possible and any real source has some spread, however small, of frequencies. In theory, this can be accounted for and the signal amplitude behaviour can be more accurately described. However, this can be computationally intensive. A s a result, this equation is simply used as an estimator to measure the accuracy of measured results. This series of experiments uses the ultrasonic transducers as a transmitter/receiver pair. Measurements were taken at 1mm increments and the value at each point was taken to be the mean over 10 readings at that point. The purpose being simply to reduce random noise. The frequency of a particular signal, for computational purposes, was taken to be the average frequency of the signal. The average frequency was calculated using the following equation (used for discrete measurements):  n  II*. where:  M.A.Sc. Thesis  (4-3)  favg = average frequency of the signal  Isaac Jing Herng Leung  06/07/96  39  Chapter 4: Experimental Results  /„ = frequency,/„ = n/T, n=l,...,N, T= time length of the signal. X = the Fourier coefficient at frequency /„ n  N = number of points for which f> 0 4.1.2.1.Decay at 3.5MHz The first set of measurements used a single sine cycle as input with an f  avg  -3.7 MHz.  The characteristics of this signal are plotted in Figure 4-2. The actual received signal has different characteristics. This signal has f  avg  - 3.5MHz  and its characteristics are show in Figure 4-3. Using Equation (4-1) and f=3.5—>3.7 MHz, we can estimate that the near field distance should be ~ 2.0—>2.2 cm per transducer. Therefore, for the transmitter-receiver pair, the near field distance should be roughly twice that, or approximately 4—>4.4 cm.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  40  Chapter 4: Experimental Results  Signals were recorded from ~0 to 20 cm from the source in 1 rnm increments. At each measurement point, only the maximum point of the detected signal was recorded. The final data consists of 200 points representing the maximum signal amplitude at each point.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  41  Chapter 4: Experimental Results  The results are plotted in Figure 4-4. The dashed lines are the asymptotes for constant amplitude and 1/r (where r represents the transmitter-receiver distance) amplitude decay. Using the -3dB point, the near field can be estimated to be ~ 4.5 cm, which is in approximate agreement with the theoretical result.  i o  ( -- 3 . 5 M h z )  Signal Amplitude Decay 2  •  •  ' !!!!!!  !  ;  . . . .. . . !  : : i  :  :  :  :  :  :  :  :  .• - • • i  -• • ' X'  -  •X  /\  :N  ...  cu pi  I  "ex  i  cn  •N•  I  : s  "s  10°  > :  N  10  3  IO"  2  Distance  (m)  >  10  1  10°  Figure 4-4 Normalized Amplitude Decay vs. Distance  4.1.2.2.Decay at 2.5 MHz The 2nd set of measurements used a signal with average frequency of approximately 2.5 MHz. The input signal is again a single cycle of a sine with a peak frequency of  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  42  Chapter 4: Experimental Results  approximately 2 MHz, but f  avg  =* 2.5 MHz. The characteristics of this signal are plotted in  Figure 4-5. Original Source Signal  Received Signal  seconds  >  Signal Frequency Spectrum  Signal Frequency Spectrum  Figure 4-6 Received signal characteristics.  Figure 4-5 Single cycle of 2 MHz sine.  The received signal characteristics is shown in Figure 4-6 and has the transducer frequency response imposed on it so that the f  avg  = 2.9 MHz, which is also close to the peak  frequency. Using these values, we can calculate the near field distance for a single transducer to be ~ 1.5—>1.7 cm. For the entire system then, the near field length should be = 3.0—>3.4 cm. Measurements were taken as in the previous experiment, recording the maximum signal amplitude in 1 mm increments out to 20 cm from the source. The results of the  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 4: Experimental Results  43  experiment are plotted in Figure 4-7. Again, using the -3dB point as an estimator, we can see that the near field distance is ~ 3.5cm.  Figure 4-7 Amplitude Decay with Distance for = 2.5 MHz signal.  4.1.2.3.Decay of FWM Source Pulse For the third measurement, a different pulse was used. This pulse is one of the source pulses required to generate a FWM pulse. This particular signal is the signal required for the central source of an FWM generating array. The parameter values are k=12 m~ , zo=6xlO' m l  5  The characteristics for the generated and received pulse are shown in Figure 4-8 and Figure 4-9, respectively. For the generated pulse, average frequency is calculated to be f 1.8 MHz while the received signal has f M.A.Sc. Thesis  avg  avg  -2.6 MHz.  Isaac Jing Herng Leung  06/07/96  =  44  Chapter 4: Experimental Results  Using these values, we can then calculated the expected near field length, for the entire system, to be approximately  2—»3  cm, probably close to 3 cm. The experimental data is  plotted in Figure 4-10. The observed near field length is approximately 4cm, which is in close agreement with the theoretical value. Original Source Signal  Received Signal  j  0.8 0.6 0.4  S o.2j 0 5 -02 -0.4  Signal Frequency Spectrum  Figure 4-8 Transmitted signal characteristics  M.A.Sc. Thesis  Signal Frequency Spectrum  Figure 4-9 Received signal characteristics  Isaac Jing Herng Leung  06/07/96  45  Chapter 4: Experimental Results  A m p l i t u d e D e c a y v s . Distance ( F W M [ 0 , 0 ] :  1 o  :  :  ^' V  '  :  : :  Source)  :  1  :  : V. : :  s J  I  i  ! : : :  Normaliz  I  i  •  o°  .: : _i • • • • • • • v ••••••••••••• ••  -L.  . . . . . . . . .  :  v  :  .  .  .  :V :  : : :  '  :  : X;  V  -i o 1 c _ i  10"  1 o  2  Distance <m)  1  1 o°  :,  Figure 4-10 Amplitude Decay with Distance for FWM source signal  4.2.  Amplitude  Decay  with  Angle  4.2.1. Background The amplitude response with angle of the transmitter/receiver pair was also measured. For an ideal point source, the signal amplitude does not vary with the angle between the source and the receiver. It should only vary with the distance between the source and the receiver. However, these are real transducers with an element diameter of ~6mm and the signal amplitude w i l l exhibit some sort of angular dependence.  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  46  Chapter 4: Experimental Results  Figure 4-11 Beam divergence  In practice, the width of the beam cannot be smaller than the diameter of the transducer. For a circular radiating transducer, a commonly used first approximation to model the spread of the beam is to assume that the beam is well confined within a cylinder of radius D  — up to the distance ZF- Thereafter, it is assumed that the beam diverges within a cone of apex angle 6 . This angle is calculated . & using: 0.6 U T  s  where:  i  n  (  T  )  =  _  (4-4)  ^ ~  0 is the spread angle at which the beam is -6db from its central value; T  X is the wavelength; and D is the transducer diameter. 0  T  For these particular transducers, we can calculate that — ~ 5.2° at 3.5 MHz. Using this result, we can also determine that ZF -3.3 cm. Therefore, for distances less than ZF, we -i  D  can determine the spread angle as 6 ~ tan ( — ) . For distances greater than ZF, the spread 2z angle will be 6 M.A.Sc. Thesis  6  T  Isaac Jing Herng Leung  06/07/96  47  Chapter 4: Experimental Results  4.2.2. Measurements Measurements were taken at various distances of transmitter-receiver separation. The purpose of this experiment is to verify that they transducers behave approximately as predicted by theory, and to document the'operational characteristics for future use. For each separation distance, the appropriate perpendicular and parallel distances were calculated to achieve the desired transmitter-receiver angle. This is easily calculated with: (4-5)  d = Rcos(6) l  and  d = Rs'm(d) ±  (4-6)  du was achieved by using the motion stage to move the appropriate distance. The motion stage has a claimed repeatable accuracy of ±0.0008 in. d± was moved manually using a scale. Repeatable accuracy is approximately ±0.5 mm.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  48  Chapter 4: Experimental Results  4.2.3. R = 3cm  Source  Receiver  Figure 4-12 Measuring Amplitude Dependence on Angle.  The first set of measurements was made at a transmitter-receiver distance of 3 cm. A signal with average frequency of ~ 3 . 5 M H z was used, the same signal as was used i n measuring the amplitude decay with distance (single cycle of sine wave). A t this frequency and distance, the signal is being measured within its near field distance. The data plotted in Figure 4-13 results from the mean of 20 measurements at each point. Measurements were taken in 2° increments until 20°, at which point measurements occurred in 10° increments.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  49  Chapter 4: Experimental Results  Amplitude vs.  Source—Receiver Angle, R—Ocm (—3.SrVIHz)  eo  9  0  Figure 4-13 Amplitude as a function of the angle between source and receiver. R=3cm.  4.2.4. R = 12 cm A similar measurement was made at a source-receiver distance of 12 cm. A t this distance and frequency, we should be in the transition between the near and far field. Figure 4-14 shows the measured results. Although the amplitude still varies with angle, one can see that the amplitude response with angle is becoming more spread out, relative to that at R = 3cm.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  50  Chapter 4: Experimental Results Amplitude  vs. Source—Receiver  Angle,  R=12cm  (~3.5IV1 H z )  ^1 — ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ O  20  30  40  50  60  70  SO  Figure 4-14 Amplitude response with angle at source-receiver distance of R = 12 cm.  4.2.5. R = 20 cm Further measurements were taken a source-receiver distance of 20 cm to see i f the response differs greatly from that at R=12cm. A t this distance, the signals measured should be well into the far field. These results are plotted in Figure 4-15. A s you can see, it does not vary very much from the response at R=12cm. Past angles of ~ ± 1 0 ° , the signal amplitude falls off rapidly.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  51  Chapter 4: Experimental Results A m p l i t u d e  1  R e s p o n s e  vs. A n g l e ,  R = 2 0 c m  ( ~ 3 . 5 M H z )  i  0.9  0.8  0.7  o.e  ¥ -CT  a_>  0.5  EE  0.4  0.3  0.2  O.I  1  O  O  2 0  3 0  4 0 D e g r e e s  5 0  6 0  7 0  S O  9 0  >-  Figure 4-15 Amplitude response vs. Source-receiver angle at R=20cm.  Although the transducers do not exhibit point source behaviour at distances up to 20 c m apart as we would like, this does not prevent us from performing future experiments. For this synthetic array system with only 1 axis of motion, the amplitude response with angle need not be accounted for as the transmitter-receiver pair are always directly facing one another(0°)  4.3.  Signal  Reconstruction  A method of reconstructing the transmitted signal is necessary for future experiments. The received signal w i l l be corrupted by noise and the non-ideal performance of the  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  52  Chapter 4: Experimental Results  experimental equipment. Processing of the received signal is required i n order to recover the original, transmitted signal.  4.3.1.  Reconstruction by integration  4.3.1.1. Background Previous work has shown that the equivalent system response for transmitting and receiving a an acoustic wave from a piezoelectric can be described by (Duck, 1977): H (co) = H (co)  (4-7)  2  s  where:  ft)  p  denotes frequency; H (co) is the transfer function describing transmitting and receiving; s  v(&>) HJco) = - -^; ' F(co) A  p{  F(co) is the driving function of the piezoelectric crystal; and v(co) is a disturbance i n the propagation medium (the propagating signal). Furthermore, from the Mason or K L M model of a piezoelectric acoustic transducer, we know that:  V(co)oc— (co) jco " v  where:  (4-8)  V(co) is the voltage on the piezoelectric; and  v (CO) is the velocity of the crystal surface. P  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  53  Chapter 4: Experimental Results In the ideal case, the crystal velocity, v (co), is directly related to the fluid particle p  velocity and hence the wave propagation, v(co), in the water. Using this, we can determine that H (co) = jco and therefore H,(co) = (jco) . 2  p  Given a known driving function V (co), we can then (neglecting some constant in  multiplicative factors) describe the received the received signal V (co) as: out  V (co) = (jco) V (co) 2  out  (4-9)  in  In the time domain, this then corresponds to two differentiations. So, we can theoretically recover v (t) knowing only v ,(t) by using: in  ou  (4-10)  Observing the plot of the system frequency response, one can see that the experimental result seems to be a good match to the theory. Therefore, we should be able to calculate and reconstruct the original signal by simply integrating (twice) the received signal.  4.3.1.2.Measurements The first signal is a F W M source function at location [8,0] in the source array. The relevant parameters for this pulse are k=5 m , zo=4xlO' m and source element spacing of 1  4  1.8 mm. The received signal is averaged over 30 separate readings. Figure 4-16 shows the calculated and received signals. A s well, the calculated result has been differentiated twice to compare with the received value.  M.A.Sc. Thesis  Isaac Jing Hemg Leung  0 6 / 0 7 / 9 6  54  Chapter 4: Experimental Results  Calculated Signal 1  i  0.5 O -0.5 1  0  0.2  0.4  U  0.6 t i m e (s)  0.8  1  >  1.2 x  1  0  - 5  Received Signal i  A.  0.5 ; 0 -0.5  0  0.2  0.4  0.6 t i m e (s)  0.8  1  >  1.2 x  1 0  -s  C a l c u l a t e d S i g n a l after 2 differentiations i :  ft  0.5 0  1  -0.5  0  0.2  0.4  |  If ^  0.6 t i m e (s)  i  l  0.8  1  >  1.2 x  1  0  -  5  Figure 4-16 FWM source at [8,0].  Since the theoretical results appears to be a good match to the received signal, we proceeded to integrate the received signal. Figure 4-17 shows the results from one and two consecutive integrations.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  55  Chapter 4: Experimental Results  R e c e i v e d S i g n a l after 1 integration  -0.5 -1 -1.5 -2 -2.5 -3 -3.5 -4  0.2  0.4  0.6 time (s)  1.2  0.8 >  x 10"  R e c e i v e d S i g n a l after 2 integrations  -100  -200 h  -300  -400  -500  -600  0.2  0.4  0.6 time (s)  0.8 >  1.2  1.4 x 10"  5  Figure 4-17 Received signal after integration.  As can be seen in the Figure 4-17(top), the first integration exhibits a slope in the result, which manifests itself as a curve in the second integration At first glance, this appears to be the result from a small DC offset in the original signal. Correction of this error is then simply achieved by including the value of this offset in the integration. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  56  Chapter 4: Experimental Results  However, a few simple trials can show that this is not the case. Figure 4-18 shows the result of including a constant offset in the integration. In this case, the offset value has been calculated by obtaining the mean value of the received signal. R e c e i v e d S i g n a l after 1 integration 1  !  ,  i  ,  i  0.8 0.6 0.4 0.2 _  O -0.2  " 1  N  . . y  :  ; ;  A  -0.4 -0.6 -0.8 -1  i  i  0.2  0.4  i V  0.6 time (s)  0.8 >  1.2 x 10"  R e c e i v e d S i g n a l after 2 integrations  0.6 time (s)  Figure 4-18 Integration of received signal + offset.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 4: Experimental Results  57  4.3.1.3.Curve Fitting the Offset To solve this problem, we accounted for the varying offset by fitting a polynomial curve to this and subtracting this off before integration. The polynomial curve fit was calculated using M a t L a b ' s p o l y f i t , which calculates the polynomial coefficients and p o l y v a l which calculates the result given the coeffcients and the dependent variable (for more details, refer to Appendix B : p r o c e s s a . m ) . The final result is shown in Figure 4-19. Calculated Signal  A  0.5  <C - 0 . 5  1.5  0.5  time (s)  x  10  x  10  x  10  Received Signal  A  0.5  I M.  ° -0.5  1 .5  time (s)  -5  Reconstructed Signal 1  A 1 1  CD <—  0.5  O -0.5  -1  1.5  0.5  time (s)  >  Figure 4-19 Received signal after offset correction and integration. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  58  Chapter 4: Experimental Results This method of reconstruction was then applied to several other signals to test its effectiveness. The results are shown in the following graphs: Calculated Signal  c  A  :  Q  o  Amplitude  ;  Calculated Signal  0.5  0  time (s) — >  1  1.5 x10  time (s)  J  >  Received Signal  Received Signal 1  ' :  m 3  l  0  '•r^~'—H"  1-0.5 0  „  0.5 ime (s)  >  1  •• 1.5 x 10'  s  Reconstructed Signal  Reconstructed Signal  j  A  0.5  CO  I ° I  < -0.5  ; V 0.5  0  time (s)  Figure 4-20 FWM source at [0,0].  >  1  1.5 X 10"  s  Figure 4-21 FWM source at [10,0].  4.3.1.4.High Pass Filtering to Remove Offset A s the unwanted offset is an apparently low frequency signal in comparison to the signal waveform, another possible method of correcting this problem is through high pass filtering of the signal. A F I R filter using a Bartlett window was implemented using MatLab's built in functions f i r l and b a r t l e t t . After some experimentation the lower cutoff frequency was  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  59  Chapter 4: Experimental Results set at 300 k H z . A s an initial test, the F W M source pulse at location [8,0] in the array was used. The parameters are the same as in the previous section. Figure 4-22 shows the result. C a l c u l a t e d Signal  R e c e i v e d Signal  Reconstructed Signal  Figure 4-22 [8,0] FWM source pulse processed with high pass filter.  This method of processing was then used on several other F W M source pulses so that the results could be compared with the previous technique. The results of this are shown in the following two figures.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 4: Experimental Results  4.4.  Reconstruction  60  from Synthetic  Array  Reconstruction of a pulse from a synthetic array source is relatively simple, in principle. In order to reconstruct the pulse, one needs to record the signals from each of the separate sources. Then, using the methods developed above, each individual pulse is processed to determine the 'actual' signal. Finally, the results of this are all summed together to produce the final result. For this experiment, the system was used to generate, and record the necessary signals for launching a F W M pulse. Measurements were taken at a receiver-central source distance  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 4: Experimental Results  61  of 12 cm. The size of the array is 21 x 21 elements and the spacing between elements is taken to be 1.8 mm. The relevant parameters for the F W M pulse are k=5 m' , zo=4xlO~ m. 1  4  Theoretical FWM  z-ct (m)  -0.01  0  radius (m)  Figure 4-25 Ideal, theoretical FWM pulse  Figure 4-25 shows an ideal F W M pulse at a distance 12 c m from the origin. It has been simulated with the same number of points and resolution as the experimental pulse. The experiment records 256 points along the axis of propagation and 16 sets of measurements a recorded at equally spaced distances from the central propagation axis up to a maximum of 3 c m out. Figure 4-26 shows a simulated F W M pulse, reconstructed at 12 c m from the source. The simulated source uses the same parameters as the experimental pulse. It uses 2 1 x 2 1  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  62  Chapter 4: Experimental Results sources separated by 1.8 mm and k-5 rri , z -4xl0' 1  4  0  m. Again, the reconstructed resolution  has been set to the same as that of the experimental pulse. Reconstructed FWM  z-ct (m)  -0.01  0  radius (m)  Figure 4-26 Theoretical Reconstructed FWM pulse. 21 x 21 sources.  For the experimental pulse, 256 points of data were collected from each source. Further, 16 equally spaced sets of measurements were taken out to 3 cm radially out from the axis of propagation. The data was processed in Matlab (see Appendix B , m _ c r e a t e .  c)  to  give the result shown in Figure 4-27 and Figure 4-28. Figure 4-27 shows the result of processing using the polynomial curve fit method described previously. Figure 4-28 shows the result using the high pass filtering method.  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  Chapter 4: Experimental Results  63  Experimental Result (Curve Fit)  z-ct (m)  -0.01  0  radius (m)  Figure 4-27 Experimentally reconstructed pulse. Cuve fit correction. Experimental Result (HP Filter)  z - c t (m)  -0.01  0  radius (m)  Figure 4-28 Experimentally reconstructed pulse. High pass filtering. M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  64  Chapter 4: Experimental Results As is expected, the two methods give very nearly the same result. The experimental  results provide an excellent match to the theoretically reconstructed result. A 'top' view, with amplitude coded by grey scale, of the same plots are shown below. Figure 4-29 is the theoretically reconstructed pulse. Figure 4-30 and Figure 4-31 show the experimental result resulting from each of the two different signal reconstrution methods. These plots further highlight the similarity between the experimental and theoretical results. Reconstructed FWM 1  0.8  0.6  0.4  0.2  0  0.01  0.005  0 z-ct (m)  -0.005  -0.01  Figure 4-29 Theoretically reconstructed pulse. Greyscale coded amplitude plot (Top view of pulse)  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 4: Experimental Results Experimental Result (Curve Fit) 0.015  1  0.8  0.6 0.01 0.4  (fl 3  1  0.2  •  0.005  I  H H • 0  -0.2  u— 0.01  0.005  0 z-ct (m)  -0.005  -0.01  Figure 4-30 Experimental result (curve fit correction) Greyscale coded amplitude plot [Top View].  Experimental Result (HP Filter)  0.01  0.005  0 z-ct (m)  -0.005  -0.01  Figure 4-31 Experimental result (High pass filtering). Greyscale-coded amplitude plot [Top view].  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  66  Chapter 5: Conclusions and Recommendations  5. 5.1.  Conclusions and Recommendations  Results  The goal of this project was to design, construct and characterize a system for launching localized waves. In order to save costs and provide flexibility in configuration, the system is designed for synthetic array generation of localized wave sources. The main components of this system consist of: •  Immersible, ultrasonic transducer pair for transmitting and receiving.  •  High frequency signal amplifier.  •  Computer controlled motion stage.  •  Computer controlled signal generator.  •  Computer controlled data acquisition hardware.  All software has been written to control and acquire data for various experiments. Most of the relevant software is written in C and can be easily upgraded for new experiments. In addition, Matlab signal processing routines have been created for use in these experiments. Several experiments were conducted in order to characterize the system for future use. Measurements were obtained to evaluate the signal amplitude decay with distance, and to determine the angular response of the transducer pair. In addition, an algorithm was devised to process received signals to recover the original transmitted signals. Finally, the system was tested in the generation and reconstruction of a sample FWM pulse The signal amplitude decay with distance agrees very closely to the predicted result. In theory, the signal amplitude will remain constant until the end of the near field distance of M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  67  Chapter 5: Conclusions and Recommendations  the source. At which point the signal amplitude should decay inversely with the distance. Several sets of measurements were taken, with source signals having various average and peak frequencies. Using calculated information on signal frequency and known data on the size of the transducer, the near field length was calculated. The experimental results agree closely with the theoretical results. Beyond the near field length, the amplitude decays as 1/r, while within the near field length, the amplitude stays roughly constant. Near the near fieldfar field boundary, the experimental results exhibits a smooth roll-off to join the two regions. Using a simple theoretical model, the beam spread is predicted to be confined within a cone beyond approximately 4 cm. The experimental results showed characteristics which are similar that which is predicted. The angle at which signal amplitude falls to half the central value appears to be approximately constant (-7°) at transmitter receiver distances from 6 cm up to 20 cm. In order to properly conduct future experiments, it is necessary to account for the system's effect on the signals. We need to be able to reconstruct transmitted signals from the received signal. Theory predicts that the received signal in such a system will be the second time derivative of the transmitted signal. This was found to be true. However, there was one major problem in processing the received signals due to some slowly time varying signal imposed on our received signal. Two methods were developed to correct for this. This first procedure involves correcting for a lower frequency signal by using a polynomial curve fit. This curve is then subtracted from the received signal before further processing. This corrected signal is then integrated twice to recover the original signal. M.A.Sc.  Thesis  Isaac Jing  Herng Leung  06/07/96  Chapter 5: Conclusions and Recommendations  68  The second method involves using a high pass filter to remove the unwanted low frequency signal. A Bartlett windowed FIR filter is used to remove the low frequency signals. The result is then integrated twice to recover the original signals. As a final test of the system performance, a test experiment was run in an attempt to generate and reconstruct a sample FWM pulse. This was done at a simulated distance of 12 cm from the FWM source array. The source array used 2 1 x 2 1 sources each set at equal spacings of 1.8mm apart. The experimental result was compared with the expected, theoretical result. Although this does not confirm the launch or propagation of a FWM pulse, it does show the capability of this system to launch a wave from a synthetic array source and reconstruct a result. Hopefully, future experiments will be able to confirm the launch of a FWM pulse and to measure its characteristics. 5.2.  Recommendations  At the present time, the experimental system is in complete operation. All hardware and software is available to run at least some rudimentary localized wave experiments. Possible experiments include: •  Generation and reconstruction of FWM pulses.  •  Measuring Amplitude decay with distance of such pulses.  •  Measuring the degree of localization of a FWM pulse as a function of distance. Software is completely functioning. However, improvements in ease of use and speed  of execution would be beneficial. Currently, some options require complete re-compilation of M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 5: Conclusions and Recommendations  69  the code in order to change them. As well, an entire experimental run for generating a single FWM pulse requires approximately 9 hours for a 21 x 21 source array and 16 sets of measurements taken radially. This has already be decreased from the original requirement of 20 hours through careful programming and optimization. The hardware for this system is also in functioning order. Again, improvements can also be made in ease of use. The signal amplifier is sufficiently useful at the current time. However, an ideal amplifier would have a larger bandwidth and also have continuously variable, computer controllable gain settings. Although this may not be achievable, a new amplifier incorporating some of these enhancements would increase the usability of the current system. Much of the experimental equipment can also be further improved by increasing the compactness of the setup. Steps can be taken to use smaller equipment casings, shorter wire leads and more compact connectors. Not only does this increase visual appeal, but it will also lessen the chances of accidents. By careful placement of equipment and shortening of wire leads, chances of accidentally tripping or catching on some loose wires are greatly reduced. Although noise levels are not currently a large problem with this system, proper equipment shielding and other noise reduction techniques would go further towards increasing the accuracy and reliability of this system. One rare bug that occurs in this system is that a trigger signal is missed during an experiment and the system is halted, waiting for the trigger. Noise is a suspect in this problem. Significant improvements can be made by acquiring faster and better signal generators and acquisition equipment. At the current time, the equipment can generate and measure M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Chapter 5: Conclusions and Recommendations  70  signals of up to 10MHz. However, this is only the theoretical limit imposed by the Nyquist frequency. In practice, accurate measurement and generation of signals are limited to those signals with frequencies much lower than 10 M H z . The system current is designed to operate near l - 2 M H z for the generation of F W M source pulses. However, this is not close enough to the central frequency of the ultrasonic transducers which have a peak response at 3 . 5 M H z . A s a result, efficiency of the system is reduced. Although the current system does have some flaws and many improvements can be made, it has been shown that the equipment functions properly and is capable of carrying out at least simple localized wave experiments.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  71  Bibliography  Bibliography Allexandre, Dider. (1996). Focused Wave Mode Launch from a Cylindrical Aperture. M.A.Sc. Thesis, Department of Electrical Engineering, U.B.C. Bie, L. (1994). A Study of Localized Waves and Their Application to Medical Ultrasound Imaging. MA.Sc. Thesis, Department of Electrical Engineering, U.B.C. Brittingham, J.N. (1983). Focus waves modes in homogeneous Maxwell's equations: Transverse electric mode. J. Appl. Phys., 54(3): 1179-1189 Chivers, R.C. and Duck, FA. (1977). On the Reference Spectrum of a Pulse-Excited Transducer. Conference on The Evaluation and Calibration of Ultrasonic pages 33-40.  Transducers,  Curry, T.S., Dowdey, J.E. and Murry Jr., R.C. (1990). Christensen's Physics of Diagnostic Radiology, 4 Ed. Lea & Febiger Ltd. th  Hykes, D.L., Hedrick, W.R. and Starchman, D.E. (1992). Ultrasound Physics and Instrumentation. Mosby-Year Book Inc. Fitzgerald, K. (1991). Medical Electronics, IEEE Spectrum. Pages 76-78. Greenleaf, J.F. (1983). Computerized tomography with ultrasound. Proceedings of the IEEE, 71(3):330-337. Jain, A.K. (1989). Fundamentals of Digital Image Processing. Prentice Hall, Inc. Kino, G.S. (1987). Acoustic Waves: Devices, Imaging, and Analog Signal Processing. Prentice-Hall, Inc. Chapter 1.  M . A . S c . Thesis  Isaac Jing Herng Leung  06/07/96  72  Bibliography  Krimholtz, R., Leedom, D.A. and Matthaei (1970). New Equivalent Circuits for Elementary Piezoelectric Transducers. Electron. Lett., 6(13) pages 398-399 Moses, H.E. (1984). The time-dependent inverse source problem for the acoustic and electromagnetic equations in the one- and three-dimensional cases. J. Math. Phys., 25(6): 1905-1923 Moses, H.E. and Prosser, R.T. (1986). Initial Conditions, Sources, and Currents for Prescribed Time-Dependent Acoustic and Electromagnetic Fields in Three Dimensions, Part I: The Inverse Initial Value Problem. Acoustic and Electromagnetic "Bullets," Expanding Waves, and Imploding Waves. IEEE Transactions on Antennas and Propagation,  34(2): 188-196.  Lu, J.-y. and Greenleaf, J.F. (1992b). Steering of limited diffraction beams with a twodimensional array transducer. In McAvoy, B.R., editor, IEEE Ultrasonics  Sumposium,  pages 603-607. Ultrasonics, Ferroelectric, and Frequency Control Society. Lu, J.-y. and Greenleaf, J.F. (1992). Nondiffracting X Waves - Exact Solutions to Free-Space Scalar Wave Equation and Their Finite Aperture Realizations. IEEE Transactions on Ultrasonics, Ferroelectrics,  and Frequency Control,  39(1): 19-31.  Palmer, M.R. and Donnelly, R. (1993). Focused waves and the scalar wave equation. J. Math. /%s.,34(9):4007-4013. Palmer, M.R. Localized waves and limited diffraction beams. Advanced Foundations, Theory and Applications,  Electromagnetism  [Barrett, T.W. and Grimes, D.M. (Editors)]  World Scientific Publishing Co. Pte. Ltd. (1995), pages 667-681.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Bibliography  73  Webster, J.G. (1992). Important Devices in Biomedical Engineering. International Biomedical Engineering Days,  pages 1-9.  Wu, T.T. (1985). Electromagnetic missiles. J. Appl. Phys., 57(7):2370-2373. Ylitalo, H., Alasaarela, E. and Koivukangas, J. (1989). Ultrasound Holographic B-Scan Imaging, IEEE Transactions on Ultrasonics, Ferroelectrics and Frequency Control, 36(3). Ziolkowski, R.W. (1985). Exact solutions of the wave equation with complex source locations. J. of Math. Phys., 26(4):861-863). Ziolkowski, R.W. (1988). Localized Transmission of Wave Energy. Engineering Research, November pages 16-23. Ziolkowski, R.W. (1988). Evidence of localized Wave Transmission. Engineering Research, November pages 24-28. Ziolkowski, R.W. (1989). Localized transmission of electromagnetic energy, Phys. Rev. A, 39(4):2005-2033. Ziolkowski, R.W., Lewis, D. K. and Cook, B.D. (1989). Evidence of Localized Wave Transmission, Phys. Rev. Letters, 62(2): 147-150.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  7 4  Appendices  •  A p p e n d i x A: Signal Amplifier  •  A p p e n d i x B: P r o g r a m L i s t i n g s  M.A.Sc. Thesis  Isaac Jing Herng Leung  0 6 / 0 7 / 9 6  Appendices  Appendix  75  A: Experimental  Equipment  A.l Signal Amplifier Design and construction by Dr. M.R. Palmer  A. 1.1 Amplifier Design The non-inverting amplifier consists of 3 major stages with selectable gain levels. The schematics for the amplifier are shown below. +7.5 v  •±- G N D  Figure A-1 Amplifier Stage 1  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  76  Appendices  +7.5v  Figure A- 2 Amplifier Stage 2  +7.5v  Figure A- 3 Amplifier Stage 3  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  77  Appendices  DIN Connector Pinout  iokn  Brown White* Black Orange  T  i  V 2N4403  -^W^+7.5v  1kn 1kn  •»+7.5v 22jtF  iookn 22>i.F  !  - i - GND  >-7.5v  -7.5 v .  .  iokn  iS  Blue> iookn  -7.5 v Green  iokn  ^ 2N4403 'C3  iookn  -7.5 v Figure A- 4 Amplifier DIN connector pin-outs.  A.l.2 Amplifier Performance Characteristics In order to characterize the amplifier performance, a broadband signal was used as the test signal. In this case, an inverted sinc(t) function was used. This particular sinc(t) function has a bandwidth of ~ 9.5 MHz and was truncated using a rectangular window. The amplifier was set to x 10 gain level (the lowest available) for all the measurements. In order to avoid saturation of the output, the input signal from the Gage CompuGen 840A was passed through a lOkQ potentiometer voltage divider.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  78  Appendices  + o From Amplifier / /  -  o +  10 k n ^ ( -  y r\) in  o  o  • i - GND  To CompGen 840A  out  -  Figure A- 5 Voltage Divider for limiting the input signal amplitude during testing  The following graphs shows the results of the characterization: Original  S o u r c e  Signal  R e c e i v e d  1  S i g n a l  1  0.8  1  0.6 ]  0.4  |  0 . 4  0.2  £  0.2  S  CD  •o s  0  HW """  t x  M.  -o  £§ O.  ^  -0.2  °  .  —  •jU*'' ' " j  _  l  -0.2  15  S.-0.4  05  co  CO  0.4  :  •  :  -  0.6  -0.6  0.8  -0.8 -1  r  -1  0.5  0.5 s e c o n d s  s e c o n d s  S i g n a l  F r e q u e n c y  S p e c t r u m  S i g n a l  F r e q u e n c y  x 10  S p e c t r u m  5 4.5  4.5  4  4  3.5  3.5  3  3  2.5  2.5  2  r  r  r  2 1.5  1.511  1  0.5  0.5  O  5 H z  10 >  0  x 10  10 H z  x 10  Figure A- 6 Input and Output Signals  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  79  Appendices  System Phase  Response  o o  u o 6 0  o o  o  o  si 0) 01 0 0 0 0 0 0  Phase (deg)—>  to  -i  o  :  10  s  HZ  =-  10  System Amplitude  a  10  7  Response  10'  10°  lO"'  -i n~  2  1O  1O  1O  s  Hz  a  =>  1  o  7  Figure A- 7 Amplifier Frequency Response  Figure A- 6 is a plot of both the input signal and the output signal. Figure A- 7 shows a plot of the magnitude and phase response of the amplifier at the x 10 gain setting.  Notes: [1] The displayed amplitude response over 9.5 MHz should be ignored as the input signal's bandwidth is only 9.5 MHz.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  80  [2] The phase response merely indicates the constant time delay performance of the amplifier. It is not an indicator of the absolute time delay. The signal must propagate through the entire data collection system and the exact value of the time delay is very dependent on when the trigger occurs and what section of the collected data is considered. For example, considering as little as 5 data points earlier or later can cause the absolute value of the time delay to vary by as much as an order of magnitude. [3] Certain signals may be distorted by the P O T voltage divider, particularly i f the signal is high amplitude and frequency. This should be visually obvious on an oscilloscope as the attenuation is gradually increased. The best way to attenuate the signal is to get a proper attenuator for a co-axial line. If that is not available, a l O x oscilloscope probe w i l l also serve as a quick and temporary solution.  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  81  Appendices  Appendix  B: Program  Files  B.l C Program Files This section contains the C files used in this project. The C programs controlling the Gage CompuGen 840A and CompuScope Lite utilize C drivers supplied by Gage. These are, respectively, CG84 ODRV. C and CSLITDRV. C. In addition, TIMING. OBJ, a pre-compiled  file also supplied by Gage is required. 840_ctrl.h /*****************************  Header f i l e f o r 840_CTRL.C Control routines for CompuGen 84OA *****************************/ #define #define int  SOFTWARE EXTERNAL  0 1  initialize_cg840  ( i n t MODE, i n t SINGLE_SHOT, i n t GAIN, i n t RATE, i n t TRIGGER, i n t FILTER); int c a l c u l a t e _ d i g i t a l _ t r i g g e r (cg840_buffer_type o u t p u t _ b u f f e r ) ; int c a l c u l a t e _ s i n c ( i n t p o i n t s , f l o a t t i m e _ s t a r t , f l o a t time_end, f l o a t f r e q , i n t FILE_OUT, cg840_buffer_type o u t p u t _ b u f f e r ) ; int c a l c u l a t e _ s i n _ t 2 ( i n t p o i n t s , f l o a t t i m e _ s t a r t , f l o a t time_end, f l o a t f r e q , i n t FILE_OUT, cg840_buffer_type o u t p u t _ b u f f e r ) ; int c a l c u l a t e _ s i n e ( i n t p o i n t s , f l o a t t i m e _ s t a r t , f l o a t time_end, f l o a t f r e q , i n t FILE_0UT, cg840_buffer_type o u t p u t _ b u f f e r ) ; double sqr(double x ) ; int c o n v e r t _ f l o a t _ t o _ d i g i t a l ( d o u b l e d p o i n t , double signal_max); f l o a t c o n v e r t _ d i g i t a l _ t o _ f l o a t ( b y t e d i g i t a l _ v a l , double signal_max); double c a l c u l a t e _ f w m _ p o i n t ( f l o a t t, f l o a t s p a c i n g , i n t X, i n t Y, f l o a t k, f l o a t zO); int c a l c u l a t e _ f w m _ p u l s e ( i n t p o i n t s , f l o a t time_range, f l o a t s p a c i n g , i n t X, i n t Y, f l o a t k, f l o a t zO, cg840_buffer_type o u t p u t _ b u f f e r , double *Norm_Factor, i n t FILE_0UT); int output_waveform ( i n t DIGITAL_TRIG, cg840_buffer_type o u t p u t _ b u f f e r ) ; /* END */  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  82  840 c t r l . c *  *  *  CompuGen 840A_Control  *  * * *  Version: 0.98 R e v i s i o n Date: A p r i l 17, 1996 W r i t t e n by: Isaac Leung  * * *  *  *  *********************************************************/  #include #include ttinclude ttinclude #include #include #include  <conio.h> <math.h> <process.h> <stdio.h> "cg840drv.h" "840_CTRL.H" "DELAYS.H"  #define  VERSION  ttdefine ttdefine  pi c  #define ttdefine #define #define #define ttdefine  SOFTWARE 0 EXTERNAL 1 samples_per_cycle 12 8 bits 8 CG840_DEFAULT_CONFIG_FILE DELAY 10  int  0.98 3.14159265358 1540  "CG840.INC"  i n i t i a l i z e _ c g 8 4 0 ( i n t MODE, i n t SINGLE_SHOT, i n t TRIGGER, i n t FILTER)  i n t GAIN, i n t RATE,  {  int  i,result,result_840;  clrscr(); •pj-intf ("************************************\ n") ; p r i n t f ( " * I n i t i a l i z e CompuGen 840A V%3.2f *\n" , VERSION) ; P r i n t f ( " * * * * * -k * -k **************************** \ ) . result_840 = c g 8 4 0 _ d r i v e r _ i n i t i a l i z e i f ( r e s u l t _ 8 4 0 == 0)  (CG840_DEFAULT_CONFIG_FILE);  {  p r i n t f (" No CompuGen 840 boards were found.\n"); p r i n t f ("\n An e r r o r o c c u r r e d ! \ n " ) ; p r i n t f (" Press a key t o end...\n"); getch(); e x i t (1); }  else { if { - r e s u l t 840) M.A.Sc. Thesis  ( r e s u l t _ 8 4 0 < 0) printf printf  (" ("  Not a l l CompuGen 840 boards were found. \n") ,Number of CompuGen 840 boards found = %d\n", Isaac Jing Herng Leung  06/07/96  Appendices  83  p r i n t f ("\n An e r r o r o c c u r r e d ! \ n " ) ; p r i n t f (" Press a key to end...\n"); getch(); e x i t (1); } /* Okay, e v e r y t h i n g seems to be a l r i g h t w i t h the 840A */ else {  printf  ("  Number of CompuGen 840 boards found = %d\n",  result_840); p r i n t f ("\n"); r e s u l t = TRUE; } }  for {  ( i = 1 ; i <= r e s u l t _ 8 4 0  ; i++)  p r i n t f ("Using board number: %d\n", i ) ; i f (cg840_select_board ( i ) != i ) {  p r i n t f ("Can not s e l e c t board: %d\n", i ) ; return(-1); }  "CompuGen "CompuGen "CompuGen "CompuGen "CompuGen  /* Set the output g a i n to XI, X2, X5 or XlO */ s w i t c h (GAIN) { case 1: cg840_set_gain(CG840_GAIN_X1); 840A => S e t t i n g g a i n to %dX\n",GAIN); break; case 2: cg840_set_gain(CG840_GAIN_X2); 840A => S e t t i n g g a i n to %dX\n",GAIN); break; case 5: cg840_set_gain(CG840_GAIN_X5); 840A => S e t t i n g g a i n to %dX\n",GAIN); break; case 10: cg840_set_gain(CG840_GAIN_X10); 840A => S e t t i n g g a i n to %dX\n",GAIN); break; default: cg840_set_gain(CG840_GAIN_Xl); 840A => S e t t i n g g a i n to %dX\n",GAIN); exit(1); }  printf printf printf printf printf  if(SINGLE_SHOT)  C  }  p r i n t f ("CompuGen 840A => S e t t i n g to S i n g l e Shot.\n" cg840_single_shot(TRUE);  /* S e l e c t D u a l / S i n g l e Channel Mode (Analog & D i g i t a l ) cg840_select_mode(MODE);  */  /* Set the CG840 Sample C o n v e r s i o n C l o c k Rate to 40 MHz /* I n c l u d e v a r i o u s r a t e s s w i t c h i n g l a t e r */ printf("\n"); s w i t c h (RATE)  */  {  /* Dummy S t u f f here. F i l l i n l a t e r . */ default: cg840_set_clock_rate(CG840_RATE_40, CG840_MHZ); } M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  84  p r i n t f ("CompuGen 840A => S e t t i n g the sampling r a t e t o 40 MHz output sampling r a t e . \ n " ) ; c g 8 4 0 _ s e t _ c l o c k _ r a t e (CG840_RATE_40, CG840_MHZ); cg840_need_ram (FALSE); /* Set t r i g g e r i n g t o Software T r i g g e r and check f o r e r r o r . * / if(TRIGGER == SOFTWARE) { i f (cg840_set_trigger_source (CG840_SOFTWARE_TRIG) != CG840_SOFTWARE_TRIG) {  printf("CompuGen 840A  => S e t t i n g t o SOFTWARE  printf("CompuGen 840A  => E r r o r  " TRIGGERING\n") ; trigger  initializing  settings.\n"); }  } if(TRIGGER == EXTERNAL) { i f (cg840_set_trigger_source CG84 0_SOFTWARE_TRIG)  (CG840_EXTERNAL_TRIG) !=  {  printf("CompuGen 840A  => S e t t i n g t o EXTERNAL  printf("CompuGen 840A  => E r r o r  TRIGGERING\n"); trigger  initializing  settings.\n"); } }  /* Turn o n / o f f the f i l t e r */ i f ( F I L T E R == FALSE) {  p r i n t f ("CompuGen 840A => T u r n i n g o f f the f i l t e r . \ n " ) ; c g 8 4 0 _ s e t _ f i l t e r _ o n (FALSE); }  i f ( F I L T E R == TRUE) { p r i n t f ("CompuGen 840A => T u r n i n g on the f i l t e r . \ n " ) ; c g 8 4 0 _ s e t _ f i l t e r _ o n (TRUE); } /* Set t r i g g e r i n g t o Software T r i g g e r and check f o r e r r o r . * / i f (cg840_set_trigger_source (CG840_SOFTWARE_TRIG) != CG840_SOFTWARE_TRIG) { printf("CompuGen 840A => E r r o r i n i t i a l i z i n g t r i g g e r settings.\n"); } } if {  (cg840_select_board  }  (1) != 1)  p r i n t f ("Can not r e s e l e c t board: %d\n", 1 ) ; return(-1);  return(result); M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  85  Appendices } /***********************************************************  T h i s i s j u s t a l i t t l e h e l p e r program t o perform s q u a r i n g ************************************************** double s q r ( d o u b l e x) {  return(pow(x,2)); } ~k -k "k -k  This i s just a l i t t l e values.  h e l p e r program convert a f l o a t  t o Gage d i g i t a l  *************************************************************************** * ** j  int {  convert_float_to_digital(double int  d p o i n t , double signal_max)  result;  result  = 128 + ( b y t e ) ( - d p o i n t / s i g n a l _ m a x  * 127);  return(result); }  float {  convert_digital_to_float(byte float result  digital_val,  double signal_max)  result; = signal_max/127*(128-digital_val);  return(result); }  int {  calculate_digital_trigger int max = (1 «  (cg840_buffer_type  output_buffer)  i , max; b i t s ) - 1;  printf("\nCompuGen 840A => C a l c u l a t i n g f o r ( i = 0 ; i <= max ; i++)  digital  trigger.\n");  {  output_buffer[CG840_FULL_DEPTH + i ] = 255; }  max = CG840_FULL_DEPTH - 1 ; f o r ( i = CG840_DOUBLE_DEPTH + (1 « o u t p u t _ b u f f e r [ i ] = 0; return  int {  (1 <<  M.A.Sc. Thesis  ; i <= max  ; i++)  bits);  output_waveform int  bits)  ( i n t DIGITAL_TRIG, cg840_buffer_type  output_buffer)  length;  Isaac Jing Hemg Leung  06/07/96  Appendices  86  /* C l e a r any c u r r e n t cg840_abort ( ) ; /* Here, we are l o a d i n g /* if(DIGITAL_TRIG)  output of the CG840 */  the d i g i t a l b u f f e r .  */ */  {  if <<  ((length = c a l c u l a t e _ d i g i t a l _ t r i g g e r  (output_buffer))  !=  bits) {  return(-1);  }  if {  (cg840_load_buffer  (2, l e n g t h ,  output_buffer)  p r i n t f ( " E r r o r attempting to l o a d D i g i t a l p r i n t f ( " Press a key to c o n t i n u e . . . " ) ; getch(); return(-1);  printf("CompuGen 840A printf("CompuGen 840A return(0);  => =>  !=  2)  Buffer!\n");  P r e p a r i n g to dump d a t a from b u f f e r . \ n " ) ; Data dumped, w a i t i n g f o r t r i g g e r . \ n " ) ;  int  c a l c u l a t e _ s i n c ( i n t p o i n t s , f l o a t t i m e _ s t a r t , f l o a t time_end, f l o a t f r e q , i n t FILE_OUT, cg840_buffer_type output_buffer) { double t; int i; FILE *fp; printf("\nCompuGen 840A  =>  C a l c u l a t i n g Sine  Pulse.\n"),•  if(FILE_OUT) { p r i n t f (" \nWrite Output F i l e Selected\n") ,fp = fopen("SINC.TXT", "wb"); }  for { } for {  ( i = 0 ; i <=  CG840_FULL_DEPTH-1 ;  output_buffer[i] ( i = 0 ; i <=  M.A.Sc. Thesis  = 12 8;  points-1  t = ((double)(i) time_start))+(time_start); i f (t!=0) {  /  i++)  ;  i++)  (double)(points)*(time_end-  Isaac Jing Herng Leung  06/07/96  (1  Appendices  87  output_buffer[i] = c o n v e r t _ f l o a t _ t o _ d i g i t a l ( l * s i n ( 2 * p i * f r e q * t ) / ( 2 * p i * f r e q * t ) , 1) ; if(FILE_OUT) fprintf(fp,"%g\r\n", -l*sin(2*pi*freq*t)/(2*pi*freq*t) } else { output_buffer[i] = convert_float_to_digital(-1,1); if(FILE_OUT) f p r i n t f ( f p , " % g \ r \ n " , ( f l o a t ) -1 ) ;  );  }  }  if(FILE_OUT) fclose(fp); printf("XnCompuGen 840A => T r y i n g t o l o a d CompuGen 840A b u f f e r . \ n " ) ; /* Load DELAY times a c t u a l l e n g t h o f s i g n a l ( j u s t a e x p e r i m e n t a l kludge f o r a 128 p o i n t s i g n a l ) Reason: At end o f D i g i t a l t r i g g e r , r a t h e r l a r g e n e g a t i v e p u l s e comes on i n the Analog l i n e . By e x t e n d i n g the l e n g t h o f the analog s i g n a l , we 'push' the p u l s e f a r away so we don't r e c o r d i t . In the ACTUAL output, the Analog s i g n a l a c t u a l l y occurs BEFORE the d i g i t a l t r i g g e r . F o r t u n a t e l y , there's d e l a y i n the system. C a r e f u l , i f you push the 'noise p u l s e ' too f a r away, the Analog s i g n a l w i l l once a g a i n precede the t r i g g e r , even through the system's d e l a y s . */ if {  (cg84 0 _ l o a d _ b u f f e r  (1, points*DELAY, o u t p u t _ b u f f e r )  printf("ERROR attempting t o l o a d Analog return(-1);  != 1)  Buffer!\n");  }  r e t u r n (CG840_FULL_DEPTH); int  c a l c u l a t e _ s i n _ t 2 ( i n t p o i n t s , f l o a t t i m e _ s t a r t , f l o a t time_end, f l o a t f r e q , i n t FILE_0UT, c g 8 4 0 _ b u f f e r _ t y p e output_buffer) { double t; int i; FILE *fp; printf("XnCompuGen 840A  => C a l c u l a t i n g Sine  Pulse.\n");  if(FILE_0UT) { p r i n t f ( " \ n W r i t e Output F i l e S e l e c t e d \ n " ) ; fp = fopen("SIN_T2.TXT", "wb"); } for {  ( i = 0 ; i <= CG840_FULL_DEPTH-1 ; i++) output_buffer[i]  = 12 8;  }  for  ( i = 0 ; i <= p o i n t s - 1  M . A . S c . Thesis  ; i++)  Isaac Jing Hemg Leung  06/07/96  88  Appendices {  t = ((double)(i) / (double)(points)*(time_endtime_start))+(time_start); output_buffer[i] = c o n v e r t _ f l o a t _ t o _ d i g i t a l ( sin(2*pi*freq*t*t),1); if(FILE_OUT) fprintf(fp,"%g\r\n", -sin(2*pi*freq*t*t)); }  if(FILE_OUT) fclose(fp); printf("\nCompuGen 840A => T r y i n g t o l o a d CompuGen 840A b u f f e r . \ n " ) ; /* Load DELAY times a c t u a l l e n g t h of s i g n a l ( j u s t a e x p e r i m e n t a l kludge f o r a 128 p o i n t s i g n a l ) Reason: At end of D i g i t a l t r i g g e r , r a t h e r l a r g e n e g a t i v e p u l s e comes on i n the Analog l i n e . By e x t e n d i n g the l e n g t h of the analog s i g n a l , we 'push' the p u l s e f a r away so we don't r e c o r d i t . In the ACTUAL output, the Analog s i g n a l a c t u a l l y occurs BEFORE the d i g i t a l t r i g g e r . F o r t u n a t e l y , there's d e l a y i n the system. C a r e f u l , i f you push the 'noise p u l s e ' too f a r away, the Analog s i g n a l w i l l once a g a i n precede the t r i g g e r , even through the system's d e l a y s . */ if {  (cg840_load_buffer  (1, points*DELAY, o u t p u t _ b u f f e r )  != 1)  printf("ERROR attempting t o l o a d Analog Buf f e r ! \n" ) ,return(-1);  } r e t u r n (CG840_FULL_DEPTH); }  int  c a l c u l a t e _ s i n e ( i n t p o i n t s , f l o a t t i m e _ s t a r t , f l o a t time_end, f l o a t f r e q , i n t FILE_OUT, c g 8 4 0 _ b u f f e r _ t y p e output_buffer) { double t; int i; FILE *fp; printf("\nCompuGen 840A  => C a l c u l a t i n g Sine  Pulse.\n");  if(FILE_OUT) { p r i n t f ( " \ n W r i t e Output F i l e S e l e c t e d \ n " ) ; fp = fopen("SINE.TXT", "wb"); }  for {  ( i = 0 ; i <= CG840_FULL_DEPTH-1 ; i++) output_buffer[i]  = 12 8;  }  for {  ( i = 0 ; i <= p o i n t s - 1  t = ((double)(i) time_start))+(time_start); M.A.Sc. Thesis  /  ; i++) (double)(points)*(time_end-  Isaac Jing Herng Leung  06/07/96  Appendices  89  output_buffer[i] = convert_float_to_digital(s i n ( 2 * p i * f r e q * t ) , 1) ; if(FILE_OUT) fprintf(fp,"%g\r\n", -sin(2*pi*freq*t)); }  if(FILE_OUT) fclose(fp); printf("XnCompuGen 840A => T r y i n g to l o a d CompuGen 840A b u f f e r . \ n " ) ; /* Load DELAY times a c t u a l l e n g t h of s i g n a l ( j u s t a e x p e r i m e n t a l kludge f o r a 12 8 p o i n t s i g n a l ) Reason: At end of D i g i t a l t r i g g e r , r a t h e r l a r g e n e g a t i v e p u l s e comes on i n the Analog l i n e . By e x t e n d i n g the l e n g t h of the analog s i g n a l , we 'push' the p u l s e f a r away so we don't r e c o r d i t . In the ACTUAL output, the Analog s i g n a l a c t u a l l y occurs BEFORE the d i g i t a l t r i g g e r . F o r t u n a t e l y , t h e r e ' s d e l a y i n the system. C a r e f u l , i f you push the 'noise p u l s e ' too f a r away, the Analog s i g n a l w i l l once a g a i n precede the t r i g g e r , even through the system's d e l a y s . */ if {  (cg840_load_buffer printf("ERROR return(-1);  (1, p o i n t s * 4 0 , o u t p u t _ b u f f e r )  != 1)  attempting to l o a d Analog B u f f e r ! \ n " ) ;  }  return  (CG840_FULL_DEPTH);  } / * * * * * * * *~* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  Need t o c a l c u l a t e the source p u l s e a t each p o i n t i n the a r r a y (X,Y) s p e c i f y the a r r a y element c i s the speed of sound ( i n water i n t h i s case) s p a c i n g i s the a r r a y element s p a c i n g (assuming square g r i d ) k, zO a r e parameters s p e c i f i c to the FWM a t a p a r t i c u l a r frequency *********************************************************************/ double c a l c u l a t e _ f w m _ p o i n t ( f l o a t t, f l o a t s p a c i n g , i n t X, i n t Y, f l o a t k, f l o a t zO) { double double  s i , s2, s3, s4, s5, s6, s7, s8, d p o i n t ; rhos, krho, z p c t , zmct, k c t ;  /************************************************************  In the f o l l o w i n g s e c t i o n , we c a l c u l a t e the source p u l s e r e q u i r e d (at some s p e c i f i e d l o c a t i o n i n the source a r r a y ) to generate a FWM p u l s e . ************************************************************/ rhos = s q r ( X * spacing)+sqr(Y*spacing) ; z p c t = sqr(zO ) + s q r ( c * t ) ; zmct = sqr(zO ) - s q r ( c * t ) ; k c t =: k * c * t ; si = s2 = s3 = M.A.Sc. Thesis  (double) (sqr(zmct) + s q r ( 2 * z 0 * c (double) s i n ( k c t * r h o s / z p c t ) ; (double) e x p ( - k * r h o s * z O / z p c t ) ; Isaac Jing Herng Leung  06/07/96  Appendices  90 s4 = s5 = s6 =  (double) ( z O * c o s ( k c t ) - c * t * s i n ( k c t ) ) / - 4 / p i / z p c t ; (double) c o s ( k c t * r h o s / z p c t ) ; (double) ( c * t * c o s ( k c t ) + z O * s i n ( k c t ) ) / 4 / p i / z p c t ;  dpoint =  (s6*s3*s5+s4*s3*s2) * -(s4*s3*s5-s6*s3*s2) *  (-2*kct*rhos*z0/sl+c*t/zpct) (k*rhos*zmct/sl-zO/zpct+k);  return(dpoint); }  int calculate_fwm_pulse ( i n t p o i n t s , f l o a t time_range, f l o a t s p a c i n g , i n t X, i n t Y, f l o a t k, f l o a t zO, cg840_buffer_type output_buffer, double *Norm_Factor, i n t FILE_OUT) {  int i c o u n t , max; f l o a t t,temp_buffer[512] ; double dpoint; double signal_max; FILE *fp; /* Check to see i f too many p o i n t s were asked f o r */ i f ( p o i n t s > CG840_FULL_DEPTH) r e t u r n (-1); /* L e t ' s c l e a r the b u f f e r b e f o r e we s t a r t */ f o r ( i c o u n t = 0 ; i c o u n t <= CG840_FULL_DEPTH-1 ; icount++) o u t p u t _ b u f f e r [ i c o u n t ] = 128; if(FILE_OUT) { p r i n t f ( " \ n W r i t e Output F i l e S e l e c t e d \ n " ) ; fp = fopen("FWM.TXT", "wb"); }  max  = p o i n t s - 1;  /*************************************************************  T h i s i s a f i r s t pass so t h a t we can f i n d the maximum and n o r m a l i z e the s i g n a l . The s i g n a l w i l l have to be 'un-normalized' b e f o r e we p r o c e s s the d a t a .  *************************************************************  j  signal_max = 0; printf("\nCompuGen 840A => C a l c u l a t i n g n o r m a l i z i n g f a c t o r . \ n " ) ; f o r ( i c o u n t = 0 ; i c o u n t <= max ; icount++) { /* Convert i c o u n t to a time v a l u e */ t = ((double)(icount) / (double)(points)*time_range)~ (time_range/2); d p o i n t = c a l c u l a t e _ f w m _ p o i n t ( t , spacing, X, Y, k, zO); temp_buffer[icount]=dpoint,• if(FILE_0UT) fprintf(fp,"%g\r\n",dpoint); if M.A.Sc. Thesis  ( f a b s ( d p o i n t ) > signal_max) Isaac Jing Herng Leung  06/07/96  91  Appendices {  signal_max = f a b s ( d p o i n t ) ;  }  wait3(); } textcolor(7); if(FILE_OUT) fclose(fp); /*  End c a l c u l a t e n o r m a l i z i n g f a c t o r  printf("CompuGen 840A Buffer\n"); for {  => W r i t i n g output  data t o CompuGen 840A  ( i c o u n t = 0 ; i c o u n t <= p o i n t s - 1 ; icount++)  y************************************************************  /* i  In the f o l l o w i n g s e c t i o n , we c a l c u l a t e the source p u l s e r e q u i r e d (at some s p e c i f i e d l o c a t i o n i n the source a r r a y ) to generate a FWM p u l s e . The f i n a l r e s u l t , b e f o r e w r i t i n g t o the CompuGen 840A b u f f e r , must be normalized, due t o the extremely h i g h maximum v a l u e of the f u n c t i o n . *****************************************************  t = ((double)(icount) / (double)(points)*time_range)(time_range/2); d p o i n t = c a l c u l a t e _ f w m _ p o i n t ( t , s p a c i n g , abs(X), abs(Y), k, zO) ; */ /* End o f p u l s e c a l c u l a t i o n */ /********************************************************** Now, c o n v e r t v a l u e s t o byte format so it- can be w r i t t e n p r o p e r l y t o the CompuGen 840A b u f f e r . **********************************************************i output_buffer[icount] = convert_float_to_digital(temp_buffer[icount],signal_max); } textcolor(7); *Norm_Factor = signal_max; /* Load DELAY times a c t u a l l e n g t h o f s i g n a l ( j u s t a e x p e r i m e n t a l kludge f o r a 12 8 p o i n t s i g n a l ) Reason: At end of D i g i t a l t r i g g e r , r a t h e r l a r g e n e g a t i v e p u l s e comes on i n the Analog l i n e . By extending the l e n g t h o f the analog s i g n a l , we 'push' the p u l s e f a r away so we don't r e c o r d i t . In the ACTUAL output, the Analog s i g n a l a c t u a l l y occurs BEFORE the d i g i t a l t r i g g e r . F o r t u n a t e l y , t h e r e ' s d e l a y i n the system. C a r e f u l , i f you push the 'noise p u l s e ' too f a r away, the Analog s i g n a l w i l l once a g a i n precede the t r i g g e r , even through the system's d e l a y s . */ M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  92  Appendices if {  (cg840_load_buffer printf("ERROR return(-1);  }  return  (1, points*DELAY, o u t p u t _ b u f f e r )  attempting to l o a d Analog  != 1)  Buffer!\n");  (CG840_FULL_DEPTH);  }  /* END  */  control.c / * * * * * * * * * * * * * *'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *  *  Experiment_Control  *  * * *  Version: 0.70 R e v i s i o n Date: February 6, 1996 W r i t t e n by: Isaac Leung  * * *  *  *  *  *  * * *********************************************************/  #include #include •include •include •include •include •include •include •include •include  <math.h> <conio.h> <process.h> <stdio.h> <stdlib.h> <string.h> "cslitdrv.h" "cg840drv.h" "EXPMT.H" "DELAYS.H"  •include  "MS3_CTRL.H"  •define  VERSION  •define •define •define  CS220_DEFAULT_CONFIG_FILE C G 8 4 0_DE FAUL T_C ONFIG_FILE DEFAULT_OUTPUT_DIRECTORY  v o i d main  0.70  ( i n t argc, char  "CS220.INC" "CG840.INC" "C:/ISAAC/PROJECT/DATA/"  **argv)  int choice; char driver_840_file[255],driver_cslite_file[81],output_file[255]; char temp[16], answer;  clrscr(); Check command l i n e f o r u s e r s u p p l i e d i n c l u d e f i l e , o t h e r w i s e t r y t o use the f i l e s M.A.Sc. Thesis  Isaac Jing Herng Leung  i f found use i t .  06/07/96  Appendices  93  "CS220.INC" f o r the CompuScope LITE "CG840.INC" f o r the CompuGen840A "OUTPUT.TXT" f o r the output f i l e NOTE: Copy the .INC f i l e s t o the working d i r e c t o r AFTER you have s e t up the boards w i t h CSINST.EXE and CGINST.EXE i f (argc == 1) { s t r c p y ( d r i v e r _ c s l i t e _ f i l e , CS22 0_DEFAULT_CONFIG_FILE); s t r c p y ( d r i v e r _ 8 4 0 _ f i l e , CG840_DEFAULT_CONFIG_FILE); s t r c p y ( o u t p u t _ f i l e , DEFAULT_OUTPUT_DIRECTORY);  */  }  else { if {  (argc == 4) strcpy strcpy strcpy  (driver_cslite_file, argvfl]); (driver_840_file, argv[2]); (6utput_file, argv[3]);  }  else { p r i n t f ("usage: FWM_EXP [ C S L I T E _ d r i v e r _ f i l e ] [ C G 8 4 0 A _ d r i v e r _ f i l e ] [Data_Directory]\n"),e x i t (1); } } /* I n i t i a l i z e the Gage boards. I f e v e r y t h i n g okay, then p r o c e e d . */ i f ( E X P _ i n i t ( ) == TRUE) {  printf clrscr  "\n\nALRIGHT! Things seem t o be working!\n"  printf * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n") ; printf Experiment C o n t r o l V%3.2f *\n",VERSION) printf * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n") ; printf \n\n") ; printf \ .. ) . printf | C u r r e n t l y A v a i l a b l e Experiments: |\n"); printf \n\n"); printf [0] Move the s t a g e \ n " ) ; printf [1] Generate and a c q u i r e s i n g l e p u l s e \ n " ) ; printf [2] Measure the amplitude decay w i t h d i s t a n c e \ n " ' printf [3] S y n t h e t i c FWM experiment\n"); printf \n P l e a s e e n t e r Experiment Number: " ) ; answer getche(); switch(answer) { break; case '3' EXP_synthetic_FWM() case '2' EXP_decay_distance(' ; break; case '1' E X P _ s i n g l e _ p u l s e ( ) ; break; break; case '0' EXP_move_stage(); EXP_single_pulse(); default: exit(1); n  } M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  94  }  else { clrscr(); p r i n t f ( " \ n T h e r e appears t o have been an ERROR w h i l e attempting\n"); p r i n t f ( " t o i n i t i a l i z e the hardware.\n"); }  p r i n t f ( " \ n T h a n k you f o r your s u p p o r t ! \ n " ) ; } /*  End o f main r o u t i n e . */  cs_ctrl.h /***************************************  T h i s i s t h e header f i l e f o r CS_CTRL.C A set of c o n t r o l routins f o r the CompuScope L i t e Board  *************************************/  ttdefine int int void  BUF_SIZE  8192  initialize_compuscope_lite  ( i n t MODE, i n t GAIN, i n t RATE, i n t TRIGGER); c s l i t e _ g r a b _ d a t a ( b y t e A_Buffer[BUF_SIZE+1], byte B_Buffer[BUF_SIZE+1],int PRE_DATA); w r i t e _ b u f f e r _ t o _ f i l e ( c h a r * o u t p u t _ f i l e , i n t DATA_FILE_LENGTH, i n t WRITE_A, i n t WRITE_B, byte *A_Buffer, byte *B_Buffer, double Norm_Factor);  /* END */  cs  ctrl.c  **********************************************************  *  * *  CompuScope L I T E _ C o n t r o l  *  * * *  Version: 0.80 R e v i s i o n Date: March 16, 1996 W r i t t e n by: Isaac Leung  * * *  *  *  *********************************************************j  #include #include #include #include #include #include #include #include  M.A.Sc. Thesis  <conio.h> <process.h> <stdio.h> <math.h> "cslitdrv.h" "cg840drv.h" "CS_CTRL.H" "DELAYS.H"  Isaac Jing Hemg Leung  06/07/96  Appendices  95  •define  VERSION  •define •define  BUF_SIZE 8192 CS220_DEFAULT_CONFIG_FILE  •define  EXTERNAL  int  0.8  CSLITE  initialize_compuscope_lite  "CS220.INC  EXTERNAL  ( i n t MODE, i n t GAIN, i n t RATE, i n t TRIGGER)  { int i , r e s u l t _ c s l i t e , r e s u l t , count ,long trigger_address,address; byte *cslite_board_location; r e s u l t = FALSE; clrscr(); p r i n t f ( " * I n i t i a l i z e CompuScope L i t e V%3.2f *\n",VERSION); p f("**************************************\n") ; r  cslite_read_config_file (CS220_DEFAULT_CONFIG_FILE,cslite_board_location); result_cslite = c s l i t e _ d r i v e r _ i n i t i a l i z e (cslite_board_location, CSLITE_MEMORY_SIZE_TEST); i f ( r e s u l t _ c s l i t e == 0) {  p r i n t f (" No CompuScope LITE boards were found.\n"); p r i n t f ("\n An e r r o r o c c u r r e d ! \ n " ) ; p r i n t f (" Press a key t o end...\n"); getch(); e x i t (1); } else { if {  (result_cslite printf  ("  < 0) Not a l l CompuScope LITE boards were  found.\n"); p r i n t f (" Number o f CompuScope LITE boards -result_cslite); p r i n t f ("\n An e r r o r o c c u r r e d ! \ n " ) ; p r i n t f (" Press a key t o end...\n"); getch();  %d\n",  found =  e x i t (1); }  /* Okay e v e r y t h i n g seems t o be okay w i t h the CSLITE */ else { p r i n t f (" Number of CompuScope LITE boards found = result_cslite); r e s u l t = TRUE;  %d\n",  }  }  for  ( i = 1 ; i <= r e s u l t _ c s l i t e  M.A.Sc. Thesis  ; i++)  Isaac Jing Herng Leung  06/07/96  Appendices  96  {  if {  (cslite_select_board char  s t r [81];  sprintf  %d.", i ) ;  }  ( i ) != i )  ( s t r , "An e r r o r was encountered s e l e c t i n g  board  printf (str); p r i n t f ("press any key t o c o n t i n u e . " ) ; getch ( ) ; continue;  /* Set S i n g l e / D u a l Channel Mode */ /* Leave Rate as a dummy s e t t i n g f o r now */ s w i t c h (RATE) { /* Dummy stub f o r now */ default: cslite_capture_mode(MODE, CSLITE_MHZ);  CSLITE_RATE_20,  }  cslite_capture_mode  (MODE, CSLITE_RATE_2 0,  CSLITE_MHZ);  i f ( G A I N == 1) { /* Dummy Stub f o r now */ } i f ( G A I N == 5) { /* Dummy Stub f o r now */ } c s l i t e _ i n p u t _ c o n t r o l (CSLITE_CHAN_A, CSLITE_INPUT_ENABLE, CSLITE_AC, CSLITE_TIMES_5); c s l i t e _ i n p u t _ c o n t r o l (CSLITE_CHAN_B, CSLITE_INPUT_ENABLE, CSLITE_AC, CSLITE_TIMES_1); if(TRIGGER == EXTERNAL) {  /* Dummy Stub f o r now */ } i f ( c s l i t e _ t r i g g e r _ c o n t r o l (CSLITE_EXTERNAL, CSLITE_AC, CSLITE_TIMES_1, CSLITE_POSITIVE, 0x90, CSLITE_P0ST_8K)==0) { printf("CompuScope Lite=> ERROR i n s e t t i n g t r i g g e r parameters!\n"); p r i n t f ( " P r e s s a key t o c o n t i n u e . . . " ) ; getch(); }  /* G o t t a a l l o w time f o r the board t o s e t up e l s e , you get a bunch o f n o i s e a t the b e g i n n i n g o f the s i g n a l . */ printf("\n"); printf("CompuScope Lite=> W a i t i n g f o r board t o i n i t i a l i z e . " ) ; return(result);  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  97  Appendices int c s l i t e _ g r a b _ d a t a ( b y t e A_Buffer[BUF_SIZE+1],byte B_Buffer[BUF_SIZE+1],int PRE_DATA) {  int long  count, r e s u l t ; address;  r e s u l t = 0; printf("CompuScope Lite=> T r i g g e r i n g CompuGen 840A.\n"); printf("CompuScope Lite=> E n a b l i n g Channel A.\n"); cslite_channel_enable(CSLITE_CHAN_A, CSLITE_INPUT_ENABLE); printf("CompuScope Lite=> E n a b l i n g Channel B.\n"); cslite_channel_enable(CSLITE_CHAN_B, CSLITE_INPUT_ENABLE); printf("CompuScope Lite=> G e t t i n g data i n t o CompuScope LITE RAM.\n"); p r i n t f ( " N o w Dumping CompuGen 840A Data\n"); cg840_dump_data(); p r i n t f ( " G e t t i n g data\n"); cslite_get_data(); p r i n t f ( " C a l l i n g CompuGen 840A T r i g g e r \ n " ) ; cg840_software_trigger(); printf("CompuScope Lite=> A w a i t i n g T r i g g e r ...\n") ; while(!cslite_triggered()) {  /* Wait t i l l CSLITE i s t r i g g e r e d */ } while(cslite_busy()) { /* Hold on i f CSLITE i s busy */ } printf("CompuScope Lite=> Reading CompuScope RAM  into  buffer.\n"); address = c s l i t e _ t r i g g e r _ a d d r e s s ( ) - P R E _ D A T A ; cslite_need_ram(TRUE); count=0; w h i l e ( c o u n t <= BUF_SIZE) { A_Buffer[count]=cslite_mem_read_chan_a(address); B_Buffer[count]=cslite_mem_read_chan_b(address); address++; count++; } cslite_need_ram(FALSE); return(result); }  void  w r i t e _ b u f f e r _ t o _ f i l e ( c h a r * o u t p u t _ f i l e , i n t DATA_FILE_LENGTH, i n t WRITE_A, i n t WRITE_B, byte *A_Buffer, byte *B_Buffer, double Norm_Factor)  { int FILE M . A . S c . Thesis  count; *fp; Isaac Jing Hemg Leung  06/07/96  98  Appendices  fp = f o p e n ( o u t p u t _ f i l e , "wb"); printf("CompuScope Lite=> Output F i l e : %s\n", o u t p u t _ f i l e ) ; count = 0; printf("CompuScope Lite=> W r i t i n g b u f f e r to F i l e . \ n " ) ; i f ( N o r m _ F a c t o r != 1) { f p r i n t f ( f p , " % g " , Norm_Factor); if(WRITE_A && WRITE_B) fprintf(fp," %g", Norm_Factor); fprintf(fp,"\r\n"); } w h i l e ( c o u n t < DATA_FILE_LENGTH) { if(WRITE_A) fprintf(fp,"%f6",(float)(128-A_Buffer[count])/127); fprintf(fp," "); if(WRITE_B) fprintf(fp,"%f6",(float)(128-B_Buffer[count])/127); fprintf(fp,"\r\n"); count++; } fclose(fp); /* END  */  delays.h /**************************  Header f i l e f o r DELAYS.C A s e t of u t i l i t y r o u t i n e s f o r d e l a y s and a l e r t s . **************  * * **********  j  i n t w a i t ( i n t Delay_Length); i n t w a i t 2 ( i n t Delay_Length) ; int wait3(void); void a l e r t l ( i n t length); /* END  */  delays.c '***********************************************************************  DELAYS.C Author: Date:  Isaac Leung March 12, 1996  Description: M . A . S c . Thesis  Isaac Jing Herng Leung  06/07/96  99  Appendices T h i s i s a s e t of u t i l i t y r o u t i n e s used to generate v a r i o u s delay functions, a l e r t s , e t c . *************************************************************  •include •include •include •include int  <conio.h> <time.h> <stdio.h> <dos.h>  POSITION=0;  i n t wait3() { time_t char int spin[0] spin[l] spin[2] spin[3]  tl; spin[4]; oldx,oldy; = = = =  0xC4; 0x5C; 0xB3; 0x2F;  /* /* /* /*  -\  */ */ | */ / */  oldx=wherex(); oldy=wherey(); gotoxy(79,2); textcolor(10); cprintf("%c",spin[POSITION] textcolor(16); delay(8); if(POSITION == 3) POSITION = 0; else POSITION = POSITION + 1; gotoxy(oldx,oldy); return(0);  i n t w a i t 2 ( i n t Delay_Length) { time_t t l ; char spin[4]; int count,oldx,oldy; spin[0] spin[1] spin[2] spin[3]  0xC4 0x5C 0xB3 0x2F  oldx=wherex(); oldy=wherey(); t l = time(NULL); while((time(NULL) { count = 0; M.A.Sc. Thesis  t l ) <= Delay_Length)  Isaac Jing Herng Leung  06/07/96  Appendices  100 w h i l e (count <=3) { gotoxy(80,1); textcolor(10); cprintf("%c",spin[count]); textcolor(16); delay(64); count++; }  }  gotoxy(oldx,oldy); textcolor(7); printf("\n"); return(0);  int wait(int  Delay_Length)  time_t char int int spin[0] spin[1] spin[2] spin[3] spin[4] spin[5] spin[6] spin[7]  tl; spin[8],ball; count,oldx,oldy; x[8],y[8]; = = = = = = = =  0xC4 ; 0x5C; 0xB3 ; 0x2 F; 0x5C; 0xB3 ; 0x2 F; 0xC4 ;  /*  _  */  /* /* /*  \  */  1  */ */  /  b a l l = 0xF9 ; x[0] x[l] x[2] x[3] x[4] x[5] x[6] x[7]  = = = = = = = =  80; 80; 79; 78; 7 8; 78; 79; 80;  y[0] y[i] y[2] y[3] y[4] y[5] y[6] y[7]  2; 3; 3; 3; 2; = 1; = 1; = 1;  = = = = =  oldx=wherex(); oldy=wherey(); t l = time(NULL); while((time(NULL) - t l ) <= Delay_Length) { count = 0; w h i l e (count <=7) { i f ( c o u n t == 0) { gotoxy(x[7],y[7]); } M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  101  else { gotoxy(x[count-1],y[count-l]); }  cprintf(" "); gotoxy(x[count],y[count]); textcolor(14); cprintf("%c",ball); gotoxy(79,2); textcolor(10); cprintf("%c",spin[count]); textcolor(16); delay(16); count++; }  }  gotoxy(oldx,oldy); printf("\n"); textcolor(7); return(0) ; } v o i d a l e r t l ( i n t length) { i n t count; f o r ( c o u n t = 0 ; count < l e n g t h printf("%c",0x07);  ; count++)  }  /* END */  expmt. h  T h i s i s the header f i l e f o r EXPMT.C A s e t of r o u t i n e s f o r c o n t r o l l i n g v a r i o u s experiments. *************************************/ int void void void void  EXP_init(void); EXP_move_stage(void); EXP_single_pulse(void) ; EXP_decay_distance(void) ; EXP_synthetic_FWM(void);  /* END */  expmt.c * *  * Experiment_List  M.A.Sc. Thesis  * Isaac Jing Herng Leung  06/07/96  102  Appendices  0 . 95 Version: R e v i s i o n Date: A p r i l 18, 1996 Isaac Leung W r i t t e n by:  ******************************************  •include •include •include •include •include •include •include •include •include •include •include •include  <stdio.h> <stdlib.h> <conio.h> <string.h> <math.h> "cslitdrv.h" "cg840drv.h" "840_CTRL.H" "CS_CTRL.H" "MS3_CTRL.H" "EXPMT.H" "DELAYS.H"  •define •define •define  VERSION 0.95 DEFAULT_OUTPUT_DIRECTORY pi 3.14159265358  int {  "C:/ISAAC/PROJECT/DATA/  1  EXP_init() int char  success, OK_CSLITE, answer;  OK_840,  SINGLE_SHOT,OUTPUT_GAIN,temp;  SINGLE_SHOT = TRUE; OK_840 = FALSE; OK_CSLITE = FALSE; success = FALSE; OUTPUT GAIN = 0;  /*  clrscr(); I n i t i a l i z e the CompuScope LITE d r i v e r and r e p o r t the number o f boards found. I f a l l i s c o r r e c t then c o n t i n u e w i t h the program. */ p i r i n t f  ( " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  printf("*  J *  Experiment Equipment I n t i a l i z a t i o n V % 3 . 2 f *\n",VERSION);  printf("\n"); p r i n t f ( " = > A t t e m p t i n g t o I n i t i a l i z e CompuScope L i t e b o a r d . \ n " ) ; printf(" Status:\n"); p r i n t f (" \n") ; OK_CSLITE = i n i t i a l i z e _ c o m p u s c o p e _ l i t e (CSLITE_DUAL_CHAN, 1,20, CSLITE_EXTERNAL); /* I n i t i a l i z e the CompuGen 840A d r i v e r and r e p o r t the number o f boards found. I f a l l i s c o r r e c t then c o n t i n u e w i t h the program. */ printf("\n"); p r i n t f ( " = > A t t e m p t i n g t o I n i t i a l i z e CompuGen printf(" Status:\n"); p r i n t f ("  M.A.Sc. Thesis  Isaac Jing Herng Leung  840A b o a r d . \ n " ) ; \n") ;  06/07/96  Appendices /* */  103  F o r now, we a r b i t r a r i l y set. some v a l u e s f o r t h e boards t o work w i t h . printf("\n"); p r i n t f ("Compugen 840A Output L e v e l +./-[ 1 | 2 | 5 | 10] : " ) ; s c a n f ( " % d " , &OUTPUT_GAIN); p r i n t f ( " D o you want S i n g l e Shot output (y/n)? " ) ; answer=getche(); i f ((answer == 'n') || (answer == 'N')) { SINGLE_SHOT=FALSE; }  OK_840 = i n i t i a l i z e _ c g 8 4 0 (CG840_DUAL_MODE, SINGLE_SHOT,OUTPUT_GAIN, 20, CG840_SOFTWARE_TRIG, FALSE); if  ((OK_840 == TRUE) && (0K_CSLITE == TRUE)) success = TRUE;  return(success); }  void {  EXP_move_stage(void) f l o a t range; char answer; clrscr(); printf("##########################\n") ; p r i n t f ( " # Experiment: Move Stage #\n"); printf("##########################\n"),printf("\n\n"); p r i n t f ( " P l e a s e e n t e r a l l v a l u e s i n meters\n"); p r i n t f (" \n\n") ; printf("Measuring distance: " ) ; s c a n f ( " % g " , &range); m o v e _ s t a g e _ s t r a i g h t ( r a n g e , METERS,0); p r i n t f ( " S h a l l I move the stage back t o the s t a r t answer = g e t c h e ( ) ; i f ((answer == 'y') || (answer == 'Y')) { m o v e _ s t a g e _ s t r a i g h t ( - r a n g e , METERS,0); }  position  (y/n)? " ) ;  }  void {  EXP_single_pulse() byte  A _ B u f f e r [ 8 1 9 3 ] , B_Buffer[8193], output_buffer[CG840_DOUBLE_DEPTH]; double *Norm_Factor; f l o a t r a n g e , t s t a r t , t e n d , f r e q , T A _ B u f f e r [ 1 0 2 5],TB_Buffer[102 5]; int choice,X,Y,points,N,count,count2,N_out,PRE_DATA; char fname[16],answer;  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  104  range = 0; /* Note: These b u f f e r s a r e f o r temporary c o l l e c t i o n and a v e r a g i n g . U n f o r t u n a t e l y , due t o memory c o n s t r a i n t s , i f t h i s 'option' i s compiled i n , the maximum number of p o i n t s we can c o l l e c t i s 1024. */  f o r ( c o u n t 2 = 0 ; count2 <= 1025 ; count2++) { TA_Buffer[count2] = 0; T B _ B u f f e r [ c o u n t 2 ] = 0; } clrscr(); printf("############################\n") ; p r i n t f ( " # Experiment: S i n g l e Pulse #\n"); printf("############################\n"); printf("\n\n"); p r i n t f ( " Please e n t e r a l l v a l u e s i n meters\n"); p r i n t f (" \n\n") ,p r i n t f ( " O u t p u t filename: ") ; s c a n f ( " % s " , &fname); printf("Measuring distance: " ) ; s c a n f ( " % g " , &range) ; printf("Number of points to c o l l e c t : " ) ; ,scanf("%d", & p o i n t s ) ; p r i n t f ( " N u m b e r of runs t o average: ") ; s c a n f ( " % d " , &N); p r i n t f ( " [1] Pseudo-Impulse\n"); p r i n t f ( " [2] Sine P u l s e \ n " ) ; p r i n t f ( " [3] FWM P u l s e \ n " ) ; p r i n t f ( " [4] s i n ( t ) \ n " ) ; p r i n t f ( " [5] s i n ( t * t ) \ n " ) ; p r i n t f ( " T y p e of pulse: " ) ; choice=getche(); printf("\n"); i f ( c h o i c e == ' 1' ) {  tstart=-3.2e-6 ; tend=3.2e-6 ; c a l c u l a t e _ s i n c (128, t s t a r t , tend, 9.5E6, TRUE, o u t p u t _ b u f f e r ) ; /* Okay, PRE_DATA i s p r e t t y kludgy. I t ' s d i f f e r e n t f o r d i f f e r e n t distances' f o r 12cm, use ~ 930; f o r 6cm, use -1760; d i r e c t D/A -> A/D, use 2600*/ PRE_DATA=460; }  i f ( c h o i c e == '2') { tstart=-6.4e-6; tend=6.4e-6; p r i n t f ( " F r e q u e n c y [ 9 E 6 ] : ") ; scanf("%g", &freq); calculate_sinc(256,tstart,tend,freq,TRUE,output_buffer); PRE_DATA=2 600; }  i f ( c h o i c e == '3') { M . A . S c . Thesis  Isaac Jing Herng Leung  06/07/96  f  Appendices  105  p r i n t f ( " \ n W h i c h source p u l s e [X,Y]?\n"); printf("X: " ) ; s c a n f ( " % d " , &X); printf("Y: "); s c a n f ( " % d " , &Y); calculate_fwm_pulse (256, 1.28E-5, 0.0018,X, Y,5,4E-4, output_buffer,Norm_Factor, TRUE); PRE_DATA=93 0; printf("PreDATA= " ) ; scanf("%d",&PRE_DATA); }  i f ( c h o i c e == 4 ) { printf("Frequency[1.0E6]: " ) ; scanf("%g", &freq); tstart=0; /* A c t u a l Freq=freq*total_time/128samples*20E6Samples/sec. tend=l; N_out=(int) (20E6/freq); calculate_sine(N_out,tstart,tend,1,TRUE,output_buffer); PRE_DATA=500; 1  1  */  }  i f ( c h o i c e == '5') { p r i n t f ( " S t a r t time [0]: " ) ; scanf ("%g", k t s t a r t ) ; p r i n t f ( " E n d Time [1.6E-4]: " ) ; s c a n f ( " % g " , &tend); calculate_sin_t2(128,tstart,tend,5E8,TRUE,output_buffer); PRE_DATA=10;  .  (  }  move_stage_straight(range, METERS,0); calculate_digital_trigger(output_buffer); output_waveform (TRUE, o u t p u t _ b u f f e r ) ; wait(1); /* Note: c s l i t e _ g r a b _ d a t a a l s o i n i t i a t e s the waveform output count = 1; w h i l e ( c o u n t <= N)  */  {  c s l i t e _ g r a b _ d a t a ( A _ B u f f e r , B_Buffer,PRE_DATA); for(count2=0 ; count2 <= 1025 ; count2++) {  TA_Buffer[count2]=TA_Buffer[count2]+convert_digital_to_float(A_Buffer[count 2] ,1) ; TB_Buffer[count2]=TB_Buffer[count2]+convert_digital_to_float(B_Buffer[count 2 ] , 1) ; } count++; }  for(count2=0 ; count2 <= 1025 ; count2++) { A_Buffer[count2]=convert_float_to_digital(TA_Buffer[count2]/N,1); B_Buf f e r [ c o u n t 2 ] = c o n v e r t _ f l o a t _ t o _ d i g i t a l ( T B _ B u f f e r [ c o u n t 2 ] / N , 1 ) ; } ' w r i t e _ b u f f e r _ t o _ f i l e ( f n a m e , p o i n t s , TRUE, TRUE, A _ B u f f e r , B _ B u f f e r , 1 ) ; M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  106  p r i n t f ( " S h a l l I move the stage back t o the s t a r t p o s i t i o n answer = g e t c h e ( ) ; i f ((answer == 'y') || (answer == 'Y')) { m o v e _ s t a g e _ s t r a i g h t ( - r a n g e , METERS,0); .  void {  (y/n)? "  EXP_decay_distance()  byte A _ B u f f e r [ 8 1 9 3 ] , B_Buffer[8193], outputjouffer[CG840_DOUBLE_DEPTH],peaks_buffer[1024]; double *Norm_Factor; f l o a t range,min,tstart,tend,freq,max; int count,count2,count3,N,index,num_points,choice,  GAIN,N_out,X,Y,PRE_DATA  char fname[16],answer; range = 0; f o r ( c o u n t 2 = ( count2 <= 1024 ; count2++) { peaks_buf f er [count2 0; } clrscr ############################################\n" printf # Experiment: Amplitude Decay v s . D i s t a n c e #\n" printf ############################################\n" printf \n\n" ) ; printf printf P l e a s e e n t e r a l l v a l u e s i n meters\n"); \ \ n j . printf printf Output F i l e : ") ; s c a n f ( %s" , &fname); n  n  printf Measure out t o d i s t a n c e : " ) ; s c a n f ( %g", &range); Number o f data p o i n t s : ") ; printf &num_points); s c a n f ( %d", printf [1] 1 x R e c e i v e r Gain = + /- 1.0 V (Channel B ) \ n " ) ; printf [5] 5 x R e c e i v e r Gain +/1 200 mV (Channel A ) \ n " ) ; printf Gain l e v e l : " ) ; s c a n f ( %d",&GAIN); printf \n") ; printf Number o f runs t o average: " ) ; s c a n f ( %d", &N); printf [1] Sine P u l s e \ n " ) ; printf [2] FWM PulseXn"); printf [3] s i n ( t ) \ n " ) ; printf Type o f p u l s e : ) ; choice getche(); p r i n t f "\n") ; '1' ) if(choice { p r i n t f ( " S t a r t time [-1 OE-6] ) ; scanf("%g", &tstart); p r i n t f ( " E n d Time [1.0E-6]: M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  Appendices  107  s c a n f ( " % g " , &tend); printf("Frequency[2E7]: " ) ; scanf ("%g" &freq) ; calculate_sinc(12 8,tstart,tend,freq,TRUE,output_buffer); PRE_DATA=10; j(  }  i f ( c h o i c e == '2') { p r i n t f ( " \ n W h i c h source p u l s e [X,Y]?\n"); printf("X: " ) ; s c a n f ( " % d " , &X); printf("Y:" ) ; s c a n f ( " % d " , &Y); calculate_fwm_pulse (128, 1.4E-6, 0.00092,X, Y, 12,0.6E-4, output_buffer,Norm_Factor, TRUE); PRE_DATA=12 8 0; }  i f ( c h o i c e == 3') { printf("Frequency[1.0E6]: " ) ; scanf("%g", &freq); tstart=0; /* A c t u a l Freq=freq*total_time/128samples*20E6Samples/sec. */ tend=l; N_out=(int) (20E6/freq); calculate_sine(N_out,tstart,tend,1,TRUE,output_buffer); PRE_DATA=100; 1  }  calculate_digital_trigger(output_buffer); index= 0; w h i l e ( i n d e x < num_points) { move_stage_straight(range/num_points, METERS,0); output_waveform (TRUE, o u t p u t _ b u f f e r ) ; wait(1);  V o l t s */  M.A.Sc. Thesis  /* Note: c s l i t e _ g r a b _ d a t a a l s o i n i t i a t e s t h e waveform output */ /* S t a r t A v e r a g i n g Loop */ count2 = 1; w h i l e ( c o u n t 2 <= N) { c s l i t e _ g r a b _ d a t a ( A _ B u f f e r , B_Buffer,PRE_DATA); count = 0; /* Use min because i n byte form, 0 i s +1 V o l t s , 255 i s -1 /* Use min or max t o d e t e c t e i t h e r peaks o r v a l l e y s */ min=2 55; max=0; f o r (count = 0 ; count <= 4096 ; count++) { i f ( G A I N == 1) { i f ( B _ B u f f e r [ c o u n t ] < min) min=B_Buffer[count]; } i f ( G A I N == 5) Isaac Jing Herng Leung  06/07/96  Appendices  108 { i f ( A _ B u f f e r [ c o u n t ] < min) min=A_Buffer[count]; } }  peaks_buffer[index]=(peaks_buffer[index]*(count21)+min)/count2; count2++; } /* End Averaging Loop */ index-*-+; } w r i t e _ b u f f e r _ t o _ f i l e ( f n a m e , n u m _ p o i n t s , TRUE, FALSE, p e a k s _ b u f f e r , B_Buffer, 1); alertl(32); p r i n t f ( " S h a l l I move the stage back t o the s t a r t p o s i t i o n (y/n)? " ) ; answer = g e t c h e ( ) ; i f ((answer == 'y') || (answer == 'Y')) { oints,  move_stage_straight(convert_distance_to_steps(ranqe/num STEPS,0); }  points)*num_p  } void {  EXP_synthetic_FWM()  byte A_Buffer[8193], B_Buffer[8193], output_buffer[CG840_DOUBLE_DEPTH]; double *Norm_Factor,distance,current_distance; f l o a t range,radius,k,zO,Source_Spacing,radii[16]; int count,X_MAX,Y_MAX,GAIN,i,i t , j , j t,PRE_DATA,N,count2,rcount,cs tep; char o u t p u t _ d i r [ 1 2 8],temp[16],output_file[255],answer; range = 0.12; r a d i u s = 0.015; cstep=0; strcpy(output_file,DEFAULT_OUTPUT_DIRECTORY); count = 0; while(count  <= 15)  C r a d i i [ c o u n t ] = radius/15*count; count++; }  c u r r e n t _ d i s t a n c e = 0; Source_Spacing = 0.0018; k = 5; zO = 4E-4; X_MAX = 10; Y_MAX = 1 0 ; GAIN = 5; PRE_DATA=93 0; clrscr(); M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  109  printf("########################################\n") p r i n t f ( " # Experiment: S y n t h e t i c FWM G e n e r a t i o n #\n") printf("########################################\n") printf("\n\n"); p r i n t f ( " O u t p u t d i r e c t o r y [%s]: ",DEFAULT_0UTPUT_DIRECT0RY); scanf("%s",&output_dir); p r i n t f ( " \ n Do you wish t o e n t e r your own data v a l u e s (y/n)? " ) ; answer=getche(); i f ((answer == 'y') || (answer == 'Y')) { p r i n t f ("\n \n") ; printf("| Please e n t e r a l l d i s t a n c e s i n meters. |\n"); p r i n t f (" =7 \n\n") ; p r i n t f ( " E n t e r the v a l u e f o r 'k' [%g]: " , k ) ; s c a n f ( " % g " , &k); p r i n t f ( " E n t e r the v a l u e f o r 'zO' [%g]: ",z0); s c a n f ( " % g " , &z0); printf("\n"); p r i n t f ( " E n t e r the Source Spacing [%6.5f]: ",Source_Spacing); s c a n f ( " % g " , &Source_Spacing); p r i n t f ( " E n t e r the c e n t r a l - d e t e c t o r t o c e n t r a l - s o u r c e d i s t a n c e [%4.3f]: ",range); s c a n f ( " % g " , &range); printf("Maximum r a d i u s out from c e n t r a l d e t e c t o r [%4.3f]? , radius) scanf("%g", &radius); count = 0; w h i l e ( c o u n t <= 15) {  r a d i i [ c o u n t ] = radius/15*count; count++; } p r i n t f ( " \ n = > Source a r r a y i s [-X,X] wide and [-Y,Y] t a l l . \ n " ) ; printf(" E n t e r v a l u e f o r X: " ) ; s c a n f ( " % d " , &X_MAX); printf(" Enter v a l u e f o r Y: " ) ; s c a n f ( " % d " , &Y_MAX); printf("\n"); printf("Enter }  scanf("%d",  the v a l u e  f o r output g a i n <1>,<2>,<5> o r <10>:  &GAIN);  p r i n t f ( " \ n The experiment w i l l proceed w i t h \n"  the f o l l o w i n g v a l u e s :  An") printf( Value f o r 'k' = %g\n", k ) ; printf( Value f o r 'zO' = %g\n", zO); printf( Source Spacing = %g\n", Source_Spacing); printf( C e n t r a l source t o c e n t r a l d e t e c t o r = %g m\n" printf( range); Radius out from c e n t r a l d e t e c t o r = %g m\n" printf( radius) printf( Source elements = [-%d,%d] i n width\n",X_MAX, X_MAX); printf( Source elements = [-%d,%d] i n height\n",Y_MAX, Y_MAX) p r i n t f ( \n") ; printf( Output Gain = %d X\n",GAIN); wait(1); rcount = 0; w h i l e ( r c o u n t <= 15)  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  110  Appendices {  i = -X_MAX; w h i l e ( i <= X_MAX) {  j = 0; w h i l e (j <= Y_MAX) { /* Here, we're j u s t b u i l d i n g up t h e output f i l e name. */ itoa(rcount,temp, 10); s t r c a t ( o u t p u t _ f i l e , temp); strcat (output_file, " / " ) ; strcat (output_file, "x"); i f ( i <0 ) strcat (output_file, " _ " ) ; it=abs(i); i t o a ( i t , t e m p , 10); s t r c a t ( o u t p u t _ f i l e , temp); strcat (output_file, "y"); i f (j < 0) strcat (output_file, " _ " ) ; jt=abs(j); i t o a ( j t , t e m p , 10); s t r c a t ( o u t p u t _ f i l e , temp); s t r c a t ( o u t p u t _ f i l e , ".TXT"); printf("Output F i l e : %s\n",output_file); /* End b u i l d output f i l e name. */ distance = sqrt( sqr(Source_Spacing*j)+sqr(radii[rcount] Source_Spacing*i)+sqr(range)); cstep=move_stage_straight (-distance, METERS,cstep); current_distance=distance; calculate_fwm_pulse (256, 1.28E-5, S o u r c e _ S p a c i n g , i , j , output_buffer,Norm_Factor,FALSE); calculate_digital_trigger(output_buffer); output_waveform (TRUE, o u t p u t _ b u f f e r ) ; wait(1);  k,z0,  A_Buffer,  c s l i t e _ g r a b _ d a t a ( A _ B u f f e r , B_Buffer,PRE_DATA); w r i t e _ b u f f e r _ t o _ f i l e ( o u t p u t _ f i l e , 5 1 2 , FALSE, TRUE, B_Buffer, *Norm_Factor); /* Restore  name */  } i++; }  the output  f i l e name t o j u s t t h e d i r e c t o r y  s t r c p y ( o u t p u t _ f i l e , DEFAULT_OUTPUT_DIRECTORY); j++; /* End o f l o o p i n g through Y */  /* End o f l o o p i n g through X */  rcount++; } /* End o f l o o p i n g through t h e r a d i i */  } /* END */  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  ms3  111  ctrl.h  /*****************************************  T h i s i s the header f i l e f o r MS3_CTRL.C A s e t of r o u t i n e s f o r c o n t r o l l i n g the MSTEP-3 Stepper Motor D r i v e r .  * *'* **************************************  #define #define int int  STEPS 0 METERS  j  1  m o v e _ s t a g e _ s t r a i g h t ( d o u b l e d i s t a n c e , i n t UNITS, i n t c s t e p s ) ; convert_distance_to_steps(double distance);  /* END  */  ms3  ctrl.c  I********************************************************* * *  MSTEP-3_Control  * *  * * *  Version: 1.05 R e v i s i o n Date: A p r i l 16, 19 9 6 W r i t t e n by: Isaac Leung  * * *  *  * *  *  * *  *********************************************************j  #include #include #include #include #include #include  <stdio.h> <math.h> <conio.h> <process.h> "MS3_CTRL.H" "DELAYS.H"  #define  VERSION  #define #define  Degrees_per_Step 1.8 Meters_per_Revolution 0.00508  #define #define #define #define  STEPS 0 METERS 1 Motion_Exec "MOVE6.EXE" Command_File "M0TI0N.CMD"  1.02  i n t m o v e _ s t a g e _ s t r a i g h t ( d o u b l e d i s t a n c e , i n t UNITS, i n t c s t e p s ) { int steps,speed,t; FILE * f p ; clrscr(); p-j-~j_ntf (" ************************\n" ) • p r i n t f ( " * FWM Move I t ! V%3.2f *\n",VERSION); p r i n t f ( " * M o d u l e : S t r a i g h t Move * \ n " ) ; p r x n t f ( " ************************\n") • if(UNITS M.A.Sc. Thesis  != STEPS) Isaac Jing Herng Leung  06/07/96  Appendices  else  112  steps = c o n v e r t _ d i s t a n c e _ t o _ s t e p s ( d i s t a n c e ) ; steps = d i s t a n c e ;  printf("MSTEP-3 printf("  => D i s t a n c e t o move = %g m\n",distance); ' H a l f Steps = %d\n",steps);  fp = fopen(Command_File,  "wb");  printf("MSTEP-3 => W r i t i n g t o command f i l e . \ n " ) ; /* Dummy v a r i a b l e speed, i t ' s not a c t u a l l y r e q u i r e d f o r t h i s implementation of move r e l a t i v e */ speed = 40; fprintf(fp,  "%d %d  %d\r\n",3,steps-csteps,speed);  fclose(fp); printf("MSTEP-3 => I n i t i a t e Move R e l a t i v e . \ n " ) ; i f ( s t e p s != 0) { system(Motion_Exec) ; }  /* Okay, we need a d e l a y loop t o a l l o w the Motion stage t o g e t i n t o position. We ought t o be a b l e t o query i t t o see i f i t ' s busy, but, i t ' s i n QuickBASIC o n l y , and i t seems t o generate e r r o r i f you query i t when i t ' s busy!! */  printf("MSTEP-3 => W a i t i n g f o r motion stage t o g e t i n t o i f ((UNITS != STEPS) && (csteps == 0)) t = abs((int) ceil(2*distance/0.03))+1; else t= a b s ( c e i l ( 2 *distance/23 62))+1; wait(t); return(steps);  position.");  }  i n t convert_distance_to_steps(double { int msteps; double asteps; printf("MSTEP-3  distance)  => C o n v e r t i n g d i s t a n c e t o s t e p s . \ n " ) ;  /* The 2 comes from h a l f s t e p p i n g The 360 comes from 360 degrees p e r r e v o l u t i o n */ a s t e p s = (double) (distance/Degrees_per_Step/Meters_per_Revolution*2.0*360.0); i f ( ( a s t e p s - ( ( i n t ) a s t e p s ) ) >= 0.5) msteps=(int)ceil(asteps); else msteps=(int)floor(asteps); return(msteps); }  /* END */  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  113  Appendices  m_create.c /***********************************************************************  M_CREATE.C Author: Date:  Isaac  Leung A p r i l 23,  1996  Description: T h i s i s a C program used t o generate t h e Matlab program which i s i n t u r n used t o process the experiment data i n order t o r e c o n s t r u c t a FWM p u l s e . M a t l a b i s n o t v e r y good a t h a n d l i n g s t r i n g s and a l s o a p p a r e n t l y does n o t a l l o w l o a d i n g w i t h i n l o o p s . T h e r e f o r e , a program t o c r e a t e this f i l e i s required. For a 21x21 source a r r a y and 16 s e t s o f r a d i i measurement, t h e r e s u l t i n g Matlab f i l e i s on the order o f 800kb i n s i z e . *******************************************************************  #include #include  <stdio.h> <stdlib.h>  ttdefine #define #define  Output_File Num_Radii Default_File  "ADD_FWM.M" 16 "." /* T h i s i s t h e d e f a u l t d i r e c t o r y  */  v o i d main(void) { FILE * f p ; char *Data_File,*Disk_File,temp[16]; int X_MAX, Y_MAX,i,it,j,j t,radii_count,pend,pstart,Num_Points,length,N; float DC_OFFSET; strcpy(Disk_File, " " ) ; s t r c p y ( D a t a _ F i l e , "") ; clrscr(); N=12; p r i n t f ( " E n t e r t h e v a l u e f o r X_MAX: " ) ; s c a n f ( " % d " , &X_MAX); p r i n t f ( " E n t e r the v a l u e f o r Y_MAX: " ) ; s c a n f ( " % d " , &Y_MAX); /* Where i s the s t a r t o f the ' u s e f u l ' data? */ p r i n t f ( " E x t r a c t data START POINT: " ) ; scanf("%d", &pstart); /* How many data p o i n t s a r e ' u s e f u l ' ? */ p r i n t f ( " N u m b e r o f Data P o i n t s t o c o l l e c t : " ) ; s c a n f ( " % d " , &length); pend=pstart+length-l; Num_Points=pend-pstart + l ; p r i n t f ( " C r e a t i n g MATLAB f i l e . " ) ; fp = f o p e n ( O u t p u t _ F i l e , "wb"); M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  114  f p r i n t f ( f p , " % T h i s i s a MATLAB f i l e f o r p r o c e s s i n g my d a t a files.\r\n"); fprintf(fp,"\r\n"); f p r i n t f ( f p , "pstart=%d;\r\n",pstart) ; fprintf(fp,"pend=%d;\r\n",pend); fprintf(fp,"SN=%d;\r\n",Num_Points) ,fprintf(fp,"ST=SN/20E6;\r\n"); fprintf(fp,"SigTime=0:ST/(SN-1):ST;\r\n"); fprintf(fp,"SigFreq=zeros(1,SN);\r\n"); f p r i n t f ( f p , " f o r j = 1:1:SN\r\n"); f p r i n t f ( f p , " S i g F r e q ( j ) = j /.ST; \ r \ n " ) ; fprintf(fp,"end\r\n"); fprintf(fp,"FWM_Data = zeros(%d,%d);\r\n",Num_Points,Num_Radii); /* f p r i n t f ( f p , " l o a d %s.mat\r\n",Transfer_Function); f p r i n t f ( f p , " l o a d %s.mat\r\n",Weiner_Filter); f p r i n t f ( f p , " l o a d %s.mat\r\n",Low_Pass_Filter); */  f p r i n t f (fp, " h p f = f i r l (256, 3E5/10E6, 'high' , b a r t l e t t (257 ) ) ,- \ r \ n " ) ; r a d i i _ c o u n t = 0; w h i l e ( r a d i i _ c o u n t < Num_Radii) { f p r i n t f ( f p , " s s d i s p ( 0 , ' % d of %d d o n e ' ) \ r \ n " , r a d i i _ c o u n t + l , N u m _ R a d i i ) ; i = -X_MAX; w h i l e ( i <= X_MAX) { j = 0; w h i l e (j <= Y_MAX) { printf("."); /* Here, we're j u s t b u i l d i n g up the f i l e name. */ s t r c a t (Data_File, "x"); i f ( i < 0) s t r c a t (Data_File, " _ " ) ; it=abs(i); i t o a ( i t , t e m p , 10); s t r c a t ( D a t a _ F i l e , temp); s t r c a t (Data_File, " y " ) ; i f (j < 0) s t r c a t (Data_File, " _ " ) ; jt=abs(j); i t o a ( j t , t e m p , 10); s t r c a t ( D a t a _ F i l e , temp); /* End B u i l d Data F i l e Name */ /* B u i l d the a c t u a l D i s k F i l e Name */ strcat(Disk_File, Default_File); strcat(Disk_File,"\\"); itoa(radii_count,temp,10); strcat(Disk_File,temp); strcat(Disk_File,"\\"); strcat(Disk_File, Data_File); strcat (Disk_File, ".txt"); /* End b u i l d Disk F i l e name. */ /* Okay do what you need t o do f o r EACH data f i l e */ M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  115  Appendices fprintf(fp,"load %s\r\n",Disk_File); fprintf(fp,"ssdisp(0,'%s')\r\n",Disk_File);*/ fprintf(fp,"Norm_Factor = %s(1);\r\n",Data_File) f p r i n t f ( f p , " C u r r e n t _ D a t a = (%s(%d:%d)'mean(%s(%d:%d)));\r\n",Data_File,pstart,pend,Data_File,pstart,pend); /*  /* T h i s i s f o r the High pass f i l t e r method */ /* fprintf(fp,"yf=conv(hpf,Current_Datamean(Current_Data));\r\n"); f p r i n t f ( f p , " y f e = y f ( 1 2 9:129+255);\r\n"); fprintf(fp,"yi=cumsum(yfe);\r\n"); fprintf(fp,"Corrected_Data=cumsum(yimean(yi));\r\n"); */ /* End HP F i l t e r Method */ /* T h i s i s f o r the curve f i t method */ fprintf(fp,"yi=cumsum(Current_Data);\r\n"); fprintf(fp,"f0=polyfit(SigTime,yi,%d);\r\n",N); fprintf(fp,"Corrected_Data=cumsum(yipolyval(f0,SigTime));\r\n"); /* End Curve F i t Method */ /* fprintf(fp,"Corrected_Data = r e a l ( i f f t ( f f t ( C u r r e n t _ D a t a ) .*%s . *%s)) ' ; \ r \ n " , W e i n e r _ F i I t e r , L o w _ P a s s _ F i I t e r )  ;*/  /* Except f o r , t h e ONE s e t of sources on t h e y - a x i s , t h e r e a r e TWO symmetric sources above and below t h e measurement a x i s */ i f (j == 0) { fprintf(fp,"FWM_Data(:,%d) = FWM_Data(:,%d) + l*Norm_Factor*Corrected_Data'/l;\r\n",radii_count+l,radii_count+l); }  else { fprintf(fp,"FWM_Data(:,%d) = FWM_Data(:,%d) + 2*Norm_Factor*Corrected_Data'/l;\r\n",radii_count+l,radii_count+l); }  /* C l e a r t h e v a r i a b l e t o save memory */ fprintf(fp,"clear %s\r\n",Data_File); /* End of what you need t o do t o each data f i l e */ /* Reset the F i l e Names */ strcpy (Data_File, " " ) ; strcpy (Disk_File, " " ) ; j++; /* End of Y_MAX loop */  } i + +; } /* End of X_MAX loop */ radii_count++; }  /* End o f R a d i i count loop */  fclose(fp); printf("\n***  Done  ***\n");  }  /* END */ M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  11  B.1.2 Maple Program Files This section contains the Maple program files used to perform some calculations on localized waves. Maple V R3 for both U N I X and Windows were used.  Mxpie Vprogram for describing the FWM acoustic Author: Isaac J.H. Leung Date: March 31, 1996 (12:03 a.rn.} >with(plots):  wave.  At 0.6 MHz, use K- 2, 40}=4.5E-'S, spacing-0.003 At 1.0 MHz. use k=20, z!0]=2E-4, spacing=0.G0065 At 3.5 MHz, use -J.OE-u. spacing~0.00046 Ai 10MHz. use k-20, z[0>~2£-5, spacing-0.0002 > c : = 1540;k: = 12;Z[0l: = 0.6E-4;Delta[X): = 0 . 0 0 0 9 2 / 2 ; DeltalYl: = 0 . 0 0 0 9 2 / 2 ;  k~.!2,  c : = 1540  k:= 12 Z A  := .00006  := .0004600000000  A^:= > rect: = (start, pulse w i d t h . t ) - >  0  .0004600000000  (Heaviside(t-start)-Heaviside(t-start-pulsewidth));  rect := (start, pulse_width, t) —>  Heaviside(  t— start) - H e a v i s i d e ( t— start - pulse_width)  777/s f's the equation describing Vie FWM. u.-.-z-ct anc! v~.zict > p s i [ F W M ] : = ( z , r h o . t ) - > 1 / ( 4 * P i * l ) / ( Z r 0 ] + l*(z-c*t))»exp(l*k*(z + c * t ) ) * e x p ( - k * r h o " 2 / ( Z r 0 ] + l*(z-c»t >)));  .2  fcp^  w  FWM  :=  (z,  p,  , lie  t)  Z +I(z-c t)  (Ik(z+ct)) e  0  ( z - c t )  "(V  Weil, this is trie source signal, which should be d(PSI}/du d(PS!)/dv > s o u r c e : = ( x . y . z , t ) - > p s i [ F W W I ] ( 0 . s q r t ( x * 2 + y * 2 ) . t ) * ( l * k * ( x * 2 + Y " 2 ) / ( Z [ 0 ] + l * ( z - c * t ) ) ' 2 - l / ( Z [ 0 ] + l*(z>c*t))  +  l*k);  ( x , y , z, t)  s q r t C x + y ) , t) 2  2  Ik(  2 X  y) 2  +  (Z + I(z-ct)\ G  M.A.Sc. Thesis  Isaac Jing Herng Leung  N  2  -+Ik Z + I(z- c t) 0  06/07/96  Appendices  117  Due to the symmetry of the sources, we can save some computation time by simply doubling our result. The top hat! of the array wilt be Ihe same as the bottom half. The only exception being the line of sources at y-0, for which they will not bs doubled. > f r : = (x,y.z,t)->sumC-1*source(Delta[xl*i,0. 0,t-sqrt((x-Delta[x]*i)^2 + y 2 + z 2)/c)*rect(-1.4E-6, 7 >E-7. t-sqrt((x-Delta[x]*ir2 + y"2 + z 2)/c)*Delta[X]*Delta[Y]/4/Pi/sqrtl(x-Delta[x]»ir2 + y"2 + z"2)', i > =-5..5) + >sum( 'sum('-2*source(Delta[X]*i, Delta[Y]»j. 0,t-sqrt((x-Delta[X]*ir2 + (y-Delta[Y]*jr2 + z"2)/c)*re >ct(-1.4E-6, 7E-7, t-sqrt((x-Delta[X]»i|*2 + (y-Delta[Y]*jr2 + z"2)/c(*Delta[X]*Delta[Y]/4/Pi/sqrt((x-D >elta[X]*i)*2 + |y-Delta[Y]*jr2 + z"2)', j = 1..5) T = -5..5); A  A  A  ,  ,  ,  <  >plot3d(Re(psi[FWM](z + 0.25/7.rho,0.25/7/c)). z = -0.005/7..0.005/7, rho = 0..0.1/7, style = patch, a > x e s = boxed,title ='Theoretical FWM'.labels = [ ' z ( m ) " , ' r a d i u s out ( m ) " , " R e { p h i } " ] , orientation = [>45,45]|; >plot3d(Re(fr|x.0,z + 0.25/7.0.25/7/c)),z = - 0 . 0 0 5 / 7 . . 0 . 0 0 5 / 7 . X = 0..0.1/7,style = patch, axes = boxed >.title = 'reconstructed FWM, 11x11 source, d = 25/7cm,delta = 0 . 0 0 0 4 6 ' ) ; >plot(Re|source(10*Delta[X],0,0.t)), t = -2E-6/3.5..2E-6/3.5. title = ' 3.5MHz. spacing = 0 . 4 6 m m , loc >ation [ 1 0 , 0 ] ) ;  M.A.Sc. Thesis  Isaac Jing Hemg Leung  06/07/96  118  Appendices B.1.3 Matlab Program Files  This section contains the Matlab program files that were used to obtain the results presented previously. The program files were run under Matlab 4.2. draw fwm.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DRAW_FWM.M % % Date: March 27, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s Matlab f i l e i s a h e l p e r program t o c a l c u l a t e and p l o t % a 3-D r e p r e s e n t a t i o n o f a Focused Wave Mode (FWM) p u l s e on the % current figure. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % N i s the number o f p o i n t s t o c a l c u l a t e , a l o n g the p r o p a g a t i o n N=2 5 6;  axis  % pN i s the number of p o i n t s t o c a l c u l a t e , a l o n g the r a d i u s out from % the p r o p a g a t i o n a x i s pN=3 2; % Speed o f sound i n water c=1540; % FWM Source s p a c i n g spacing=0.00092/2;  ( i n meters)  % V a r i o u s o t h e r parameters f o r a FWM zO=0.6E-4; k=12;  pulse  % d i s the d i s t a n c e from the source a l o n g the p r o p a g a t i o n a x i s % r a d i u s _ o u t i s the d i s t a n c e t o measure out from the p r o p a g a t i o n % A l l d i s t a n c e s i n meters. d=0.25/7;  axis.  radius_out=0.1/1;  % Here, c a l c u l a t e the t h e o r e t i c a l FWM p u l s e a t a g i v e n TIME out from % the c e n t r a l source. phi=zeros(pN,N); t=0.25/7/c; z=(-0.005/7+d):(2*0.005/7)/(N-l):(0.005/7+d); rho=0:radius_out/(pN-1):radius_out; for j=l:l:pN M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  119  phi(j,:)=!./(4*pi*i*(zO+i*(z-c*t))).*exp(i*k*(z+c*t)).*exp(k*rho(j)^2./(zO+i*(z-c*t))); end % Here, s p e c i f y and c a l c u l a t e the s p e c i f i c FWM source p u l s e % Note t h a t t h i s i s _ n o t _ r e q u i r e d to c a l c u l a t e the a c t u a l FWM % but i s o n l y r e q u i r e d f o r the t h e o r e t i c a l r e c o n s t r u c t i o n . % The source i s NOT a u t o m a t i c a l l y p l o t t e d . X=10*spacing,• Y=0*spacing; tt=(-2E-6/3.5):2*(2E-6/3.5)/(N-1):(2E-6/3.5); source = 1 . / ( 4 * p i * i * ( z O + i * ( - c * t t ) ) ) . * e x p ( i * k * ( + c * t t ) ) . * e x p ( k * ( X " 2 + Y ~ 2 ) . / ( z O + i * ( - c * t t ) ) ) . * ( k-1./(zO+i*(-c*tt))+k*(X^2+Y^2)./(zO+i*(c * t t ) ) . ~ 2 ); % Now p l o t the 3-D FWM p u l s e %mesh(z,rho,real(phi)); surf1(z,rho,real(phi)); %surf1(z,rho,real(gwave)); shading i n t e r p ; colormap(bone); view([3 0 30] ) ; grid; x l a b e l ( ' z (m)'); y l a b e l ( ' r h o (m)'); z l a b e l ( Re{phi} ' ) ; axis([(-0.005/7+d) (0.005/7+d) 0 r a d i u s _ o u t 1  -200  1200])  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  fid  calc.m  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FLD_CALC.M % % Date: March 27, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s Matlab f i l e i s a h e l p e r program to c a l c u l a t e the s e v e r a l % c h a r a c t e r i s t i c s f o r a given s i g n a l . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % c i s the speed of sound i n water c=1540; % D i s the t r a n s d u c e r a c t i v e diameter D=6E-3; xx=0 ; xy=0; ty=0; tx=0;  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96 V  V  120  Appendices % T h i s s e c t i o n c a l c u l a t e s the average frequency of the t r a n s m i t t e d % s i g n a l ( f r e q i n ) and f o r the r e c e i v e d s i g n a l (freqout) for j=l:l:128 ty=ty+abs(FSigOUT(j)); tx=tx+abs(FSigIN(j)); xx=xx+abs(FSigIN(j))*SigFreq(j); xy=xy+abs(FSigOUT(j))*SigFreq(j) ; end freqin=xx/tx freqout=xy/ty % C a l c u l a t e the wavelength lin=c/freqin; lout=c/freqout; % C a l c u l a t e the near f i e l d f o r the t r a n s m i t t e d s i g n a l ( n f i n ) % and a l s o the r e c e i v e d s i g n a l (nfout) nfin=D~2/4/lin*(1-(lin/D)~2) nfout=D 2/4/lout* (1- (lout/D) 2) /s  A  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f  s o u r c e . m  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % F_S0URCE.M % % Date: A p r i l 19, 1996 % Author: Isaac J.H. Leung % % Description: % ' T h i s Matlab f u n c t i o n c a l c u l a t e s the s p e c i f i e d source s i g n a l % r e q u i r e d to generate a FWM p u l s e . % P l a n a r a r r a y i s assumed. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f u n c t i o n src=make_source(x,y,z,t,k,z0) % V a r i o u s parameters f o r the FWM % Note: We should e x t e r n a l i z e these parameters c=1540; src=i*(k*((x)~2+(y) 2)./((zO+i*(z-c*t)). 2)-1./(zO+i*(zc*t))+k).*psi_FWM(0,sqrt(x.^2+y. 2),t,k,zO); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A  A  A  f w m  s r c . m  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  121  Appendices % % FWM_SRC.M % % Date: A p r i l 19, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s M a t l a b f i l e c a l c u l a t e s and p l o t s the t h e o r e t i c a l FWM % p u l s e and a l s o the r e c o n s t r u c t e d FWM p u l s e . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % c i s t h e speed o f sound i n water c=1540; % N = number o f p o i n t s a l o n g z (propagation a x i s ) % rN = number o f p o i n t s t o r a d i a l l y out from p r o p a g a t i o n N=2 5 6; rN=16; % Source Element Spacing dx=0.0018; dy=0.0018; %dx=0.00092; %dy=0.00092;  axis  ( i n meters)  % E x t e n t o f A r r a y Elements xlim=10; ylim=10; % Parameters f o r the FWM %z0=8E-4; %k=88; z0=4E-4;' k=5; fr=zeros(N,rN); tfwm=zeros(N,rN); % S e t up the ranges t o be c o n s i d e r e d % Use t h e time t o s p e c i f y the d i s t a n c e out (t=distance/speed) z=(12 8/20E6*c):(-256/20E6*c)/(N-l):(-128/20E6*c); %z=8E-4:-16E-4/(N-l):-8E-4; t=0.12/c; x=0:(0.015)/(rN-1):0.015; % C a l c u l a t e t h e FWM p u l s e s f o r r r = 1:1:rN rr fr(:,rr)=real(fwmrecon(x(rr),0,z+t*c,t,k,zO,xlim,ylim,dx,dy,N)); tfwm(:,rr)=real(psi_fwm(z+t*c,x(rr),t,k,zO))'; end % P l o t the T h e o r e t i c a l Pulse , figure(1) surf(x,z,real(tfwm/max(max(tfwm)))); %shading i n t e r p ; M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  122  Appendices grid; view([-45 45]) ; colormap(jet); x l a b e l ( ' r a d i u s out ( m ) ) ; y l a b e l ( ' z - c t (m)'); t i t l e ( ' T h e o r e t i c a l FWM'); 1  % P l o t t h e ( a l s o T h e o r e t i c a l ) but R e c o n s t r u c t e d figure(2) surf(x,z,fr/max(max(fr))); %shading i n t e r p ; grid; view([-45 45]) ; colormap(jet); x l a b e l ( ' r a d i u s out (m) ); y l a b e l ( z - c t (m)'); t i t l e ( ' R e c o n s t r u c t e d FWM');.  pulse  1  1  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fwmrecon.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FWMRECON.M % % Date: A p r i l 19, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s Matlab f i l e c a l c u l a t e s the r e c o n s t r u c t e d FWM, b u t o n l y % a l o n g 1 s i n g l e r a d i u s out from the p r o p a g a t i o n a x i s . % I n o r d e r t o view the e n t i r e FWM p u l s e , t h i s program i s used % t o c a l c u l a t e a l o n g many r a d i i o u t . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f u n c t i o n fr=fwmrecon(x,y,z,time,k,zO,xlim,ylim,dx,dy,N) % c i s t h e speed o f sound i n water c=1540; fr=zeros(N,1); % These a r e t h e sources  a l o n g y=0, o f which t h e r e i s o n l y 1 s e t  for i i = -xlim:l:xlim tx=ii*dx; tt=(time-sqrt((x-tx)^2+(y-0)"2+(z). 2)/c); fr=fr+l*(-f_source(tx,0,0,tt,k,zO)*dx*dy/4/pi./sqrt((x-tx)^2+(y0)"2+(z) ."2) ) ' ; end A  % We o n l y c y c l e through 1/2 the sources, % we j u s t m u l t i p l y each r e s u l t by 2. M.A.Sc. Thesis  since i t ' s  Isaac Jing Herng Leung  symmetrical  06/07/96  Appendices  123  for i i = - x l i m : l : x l i m f o r j j = 1:1: ylim tx=ii*dx; t y = j j *dy; tt=(time-sqrt((x-tx) 2+(y-ty)~2+(z). 2)/c); fr=fr+2*(-f_source(tx,ty,0,tt,k,zO)*dx*dy/4/pi./sqrt((x-tx) 2+(yty) 2+(z)."2)) ; end % END j j LOOP end % END i i LOOP A  A  A  A  1  !>%%%%%%%%%%%%%%%%%%%%%%%%  END ^%%%%%%%%%%%%%%%^  %%%%%%%%%%%%%%%%%%%%%%%?  p r o c e s s . m  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % PROCESS.M % % Date: A p r i l 18, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s M a t l a b f i l e i s a h e l p e r program t o p r o c e s s r e c e i v e d % s i g n a l s g i v e n a system t r a n s f e r f u n c t i o n . % The system t r a n s f e r f u n c t i o n must be saved i n the c u r r e n t d i r e c t o r y % as H.MAT % U s i n g t h i s f i l e , the program w i l l read i n the data f i l e , % assumed t o be OUT.TXT and p r o c e e d t o p r o c e s s t h e f i l e u s i n g a % Weiner f i l t e r and a low pass f i l t e r . % The r e s u l t i s p l o t t e d on the c u r r e n t f i g u r e . % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % S p e c i f y the s t a r t and end p o i n t s you want t o a n a l y z e pstart=20; pend=pstart+255; % Channel A i s 1, Channel B i s 2 channel=2; % SN i s the Number o f p o i n t s t o be a n a l y z e d SN=pend-pstart+l; % ST i s t h e time i n t e r v a l f o r the number o f p o i n t s % Sampling Rate i s d e f a u l t a t 20 Msamples/sec. Sampling_Rate=2 0E6; ST=SN/Sampling_Rate; SigTime=0:ST/(SN-1):ST; % C a l c u l a t e t h e ' r e a l ' frequency f o r the a x i s S i g F r e q = zeros(1,SN); f o r j = 1:1:SN S i g F r e q ( j ) = j/ST; end  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  124  Appendices  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Load the Data f i l e s % H.mat = System t r a n s f e r F u n c t i o n % out.txt = Received S i g n a l % fwm.txt = Calculated Signal l o a d H.mat l o a d fwm.txt load out.txt % E x t r a c t the d a t a . % More d a t a i s r e c o r d e d than i s needed, so you can choose t o e x t r a c t % a s p e c i f i e d range o f data. source=zeros(1,pend-pstart+1) ; f o r j=1:1:size(fwm) source(j)=fwm(j)/max(fwm) ; end % % y Y  Set y t o be the p o r t i o n of the data you're i n t e r e s t e d i n . The mean o f the s i g n a l i s s u b t r a c t e d t o remove any DC o f f s e t , = out(pstart:pend,channel)'-mean(out(:,channel)); = fft(y);  % Get a measure o f the n o i s e i f channel==2 n o i s e = 200E-3*out(pstart:pend,1)' ; e l s e i f channel==l noise = out(pstart:pend,2) ' ; end NOISE = f f t ( n o i s e ) ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % C o n s t r u c t i n g a Weiner f i l t e r , G ( f ) Suu=Y.*conj(Y); Snn=NOISE.*conj(NOISE); G=(conj(H).*Suu)./((abs(H). 2).*Suu+l*Snn); A  % Process Data %X=Y./H; X=Y.*G; x=ifft(X); % Making a Low Pass f i l t e r , WN=hanning(SN); LPF=zeros(1,SN); for j=l:(SN/2); LPF(j)=WN(j+128) ; end f o r j=128:256 LPF(j)=WN(j-127); end %XF=X.*LPF; XF=X; xf=(ifft(XF));  M.A.Sc. Thesis  LPF(f)  Isaac Jing Herng Leung  06/07/96  125  Appendices  % P l o t the C a l c u l a t e d S i g n a l subplot(3,1,1) x i = zeros(size(SigTime)) ; f o r j=1:1:size(fwm); xi(j)=fwm(j)/max(fwm); end plot(SigTime,xi); grid a x i s ( [ 0 1.5E-5 -1 1]) x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >') ; title('Calculated Signal'); % P l o t the R e c e i v e d S i g n a l subplot(3,1,2) plot(SigTime,y/max(y)); grid x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >'); title('Received Signal'); a x i s ( [ 0 1.5E-5 -1 1]) % P l o t the R e c o n s t r u c t e d S i g n a l subplot(3,1,3) plot(SigTime,real(xf)/abs(min(real(xf)))); grid a x i s ( [ 0 1.5E-5 -1 1]) x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >'); title('Reconstructed Signal'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  processa.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % PROCESSA.M % % Date: May 2, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s Matlab f i l e i s a h e l p e r program t o p r o c e s s r e c e i v e d % s i g n a l s g i v e n a system t r a n s f e r f u n c t i o n . % T h i s procedure c a l c u l a t e s the s i g n a l by i n t e g r a t i n g the % r e c e i v e d d a t a . C o r r e c t i o n f o r a v a r y i n g DC o f f s e t i s accomplished % by curve f i t t i n g the o f f s e t % The r e s u l t i s p l o t t e d on the c u r r e n t f i g u r e . % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % S p e c i f y the s t a r t and end p o i n t s you want t o a n a l y z e pstart=20; M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  126  Appendices pend=pstart+255; % Channel A i s 1, Channel B i s 2 channel=2; % SN i s the Number of p o i n t s SN=pend-pstart+l;  t o be a n a l y z e d  % ST i s the time i n t e r v a l f o r the number o f p o i n t s % Sampling Rate i s d e f a u l t a t 20 Msamples/sec. Sampling_Rate=2 0E6; ST=SN/Sampling_Rate; SigTime=0:ST/(SN-1):ST; % C a l c u l a t e the ' r e a l ' frequency f o r the a x i s S i g F r e q = zeros(1,SN); f o r j = 1:1:SN S i g F r e q ( j ) = j/ST; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Load the Data f i l e s % out.txt = Received S i g n a l % fwm.txt = Calculated Signal l o a d fwm.txt load out.txt % E x t r a c t the d a t a . % More d a t a i s r e c o r d e d than i s needed, so you can choose t o e x t r a c t % a s p e c i f i e d range o f data. source=zeros(1,pend-pstart+1) ; f o r j=1:1:size(fwm) source(j)=fwm(j)/max(fwm); end % Set y t o be the p o r t i o n o f the data you're i n t e r e s t e d i n . y = out(pstart:pend,channel)'; % Do the f i r s t i n t e g r a t i o n y i = cumsum(y); f l = polyfit(SigTime,yi,12); y i i = cumsum(yi-polyval(f1,SigTime)); % P l o t the C a l c u l a t e d S i g n a l subplot(3,1,1) plot(SigTime,fwm/max(fwm)); grid a x i s ( [ 0 1.5E-5 -1 1]) x l a b e l ( time (s) >'); ylabel('Amplitude >'); title('Calculated Signal'); 1  % P l o t the R e c e i v e d S i g n a l subplot(3,1,2) plot(SigTime,y/max(y)); grid M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  127  Appendices x l a b e l ( ' t i m e (s) >') ; ylabel('Amplitude >'); title('Received Signal'); a x i s ( [ 0 1.5E-5 -1 1]) % P l o t the R e c o n s t r u c t e d S i g n a l subplot(3,1,3) plot(SigTime,yii/max(yii)); grid a x i s ( [ 0 1.5E-5 -1 1]) x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >'); title('Reconstructed Signal'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% processf.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % PROCESSF.M % % Date: May 9, 19 9 6 % Author: Isaac J.H. Leung % % Description: % T h i s matlab f i l e i s a h e l p e r program t o p r o c e s s r e c e i v e d % s i g n a l s g i v e n a system t r a n s f e r f u n c t i o n . % T h i s procedure c a l c u l a t e s the s i g n a l by i n t e g r a t i n g the % r e c e i v e d d a t a . C o r r e c t i o n f o r a v a r y i n g DC o f f s e t i s accomplished % by h i g h pass f i l t e r i n g ( B a r t l e t t window). % The r e s u l t i s p l o t t e d on the c u r r e n t f i g u r e . % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % S p e c i f y the s t a r t and end p o i n t s you want t o a n a l y z e pstart=2 0; pend=pstart+255; % Channel A i s 1, Channel B i s 2 channel=2; % SN i s the Number o f p o i n t s t o be a n a l y z e d SN=pend-pstart+l; % ST i s the time i n t e r v a l f o r the number of p o i n t s % Sampling Rate i s d e f a u l t a t 20 Msamples/sec. Sampling_Rate=20E6; ST=SN/Sampling_Rate; SigTime=0:ST/(SN-1):ST; % C a l c u l a t e the ' r e a l ' frequency f o r the a x i s S i g F r e q = zeros(1,SN); f o r j = 1:1:SN S i g F r e q ( j ) = j/ST; M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  128  Appendices end  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Load the Data f i l e s % out.txt = Received S i g n a l % fwm.txt = Calculated Signal l o a d fwm.txt load out.txt % E x t r a c t the d a t a . % More d a t a i s r e c o r d e d than i s needed, so you can choose t o e x t r a c t % a s p e c i f i e d range of data. source=zeros(1,pend-pstart+1) ; f o r j=1:1:size(fwm) source (j ) =fwm (j ) /max ( fwm) ,end % Set y t o be the p o r t i o n of the data you're i n t e r e s t e d i n . y = out(pstart:pend,channel)'; % B u i l d the f i l t e r CutFreq=3E5; Wn=CutFreq/(Sampling_Rate/2); hpf=firl(SN,Wn,'high',bartlett(SN+1)); %hpf=firl(256,3E5/10E6,'high',bartlett(257)); % Use the f i l t e r yf=conv(hpf,y-mean(y)); % E x t r a c t the p o r t i o n we want. C o n v o l u t i o n g i v e s a l o n g e r v e c t o r . yfe=yf(SN/2+1:SN/2+SN); % Do the f i r s t i n t e g r a t i o n y i = cumsum(yfe); y i i = cumsum(yi-mean(yi)); % P l o t the C a l c u l a t e d S i g n a l subplot(3,1,1) plot(SigTime,fwm/max(fwm)); grid a x i s ( [ 0 1.5E-5 -1 1]) x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >'); title('Calculated Signal'); % P l o t the R e c e i v e d S i g n a l subplot(3,1,2) plot(SigTime,y/max(y)); grid x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >'); title('Received Signal'); a x i s ( [ 0 1.5E-5 -1 1]) % P l o t the R e c o n s t r u c t e d S i g n a l subplot(3,1,3) plot(SigTime,yii/max(yii)); M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  1 2 9  grid a x i s ( [ 0 1.5E-5 - 1 1 ] ) x l a b e l ( ' t i m e (s) >'); ylabel('Amplitude >'); title{'Reconstructed Signal'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  p s i fwm.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % PSI_FWM.M % % Date: A p r i l 19, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s matlab f u n c t i o n c a l c u l a t e s the i d e a l t h e o r e t i c a l FWM % p u l s e ( i n f i n i t e , c o n t i n o u s souce) a t some d i s t a n c e z, a t a g i v e n % time t and a t some rho out from the a x i s o f p r o p a g a t i o n ( z - a x i s ) . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function  s=make_fwm(z,rho,t,k,zO)  % V a r i o u s parameters f o r the FWM % Note: We s h o u l d e x t e r n a l i z e these parameters c=1540; s = 1 / ( 4 * p i * i ) . /(zO + i * ( z - c * t ) ) . * e x p ( i * k * ( z + c * t ) ) c*t)) ) ;  .*exp(-k*(rho"2) ./(zO + i * ( z -  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  response.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % RESPONSE.M % % Date: March 27, 1996 % Author: Isaac J.H. Leung % % Description: % T h i s matlab f i l e i s a h e l p e r program t o c a l c u l a t e the system % response, s t o r e d i n the v a r i a b l e H % U s i n g t h i s f i l e , the program w i l l read i n the data f i l e s : % ROUT.TXT i s assumed t o be the r e c e i v e d s i g n a l % SINC.TXT i s assumed t o be the i n p u t s i g n a l % t h i s can be changed t o whatever you choose the i n p u t s i g n a l t o be. % The c h a r a c t e r i s t i c s of the i n p u t and output s i g n a l as w e l l % as the c a l c u l a t e d system t r a n s f e r f u n c t i o n a r e p l o t t e d . M.A.Sc. Thesis  Isaac Jing Herng Leung  0 6 / 0 7 / 9 6  130  Appendices %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  % Assume t h a t the r e c e i v e d s i g n a l a c t u a l l y c o l l e c t s more d a t a than needed. % S p e c i f y the s t a r t and end p o i n t s you want t o a n a l y z e pstart=55; pend=pstart+255; % SN i s __the Number of p o i n t s SN=pend-pstart+l;  t o be a n a l y z e d  % ST i s the time i n t e r v a l f o r the number o f p o i n t s % The d e f a u l t sampling r a t e i s 20E6 samples/second. Sampling_Rate=2 0E6; ST=SN/Sampling_Rate; SigIN=zeros(1,SN); SigOUT=zeros(1,SN); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Here l o a d the data f i l e s load rout.txt; load s i n c . t x t ; % F o l l o w i n g t h i s s e c t i o n , the r e c e i v e d s i g n a l i s always r e f e r r e d t o % as 'yout' and the c a l c u l a t e d s i g n a l as ' i n ' yout=rout; in=sinc; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % E x t r a c t i n g the p o r t i o n of the s i g n a l t h a t we want. DC_OFFSET=mean(yout(:,2)); for j=pstart:1:pend SigOUT(j-pstart+1)=yout(j,2)-DC_0FFSET; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% for j=1:1:size(in) SigIN(j)=in(j) ; end % F o u r i e r t r a n s f o r m t o get frequency spectrum. FSigIN=fft(SigIN); FSigOUT=fft(SigOUT); % C a l c u l a t e the ' r e a l ' time f o r the a x i s SigTime=0:ST/(SN-1):ST; % C a l c u l a t e the ' r e a l ' frequency f o r the a x i s S i g F r e q = zeros(1,SN); f o r j = 1:1:SN S i g F r e q ( j ) = j/ST; end % P l o t the INPUT s i g n a l figure(1) subplot(2,2,1)  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  131  Appendices plot(SigTime,SigIN,'g') xlabel('seconds > ' ) ; y l a b e l ( ' S i g n a l Amplitude (V) >'); t i t l e ( O r i g i n a l Source S i g n a l ' ) ; g r i d on 1  a x i s ( [ 0 1.5E-5 -1 1] ) subplot(2,2,3) plot(SigFreq,abs(FSigIN),'c') xlabel('Hz > ' ) ; t i t l e ( ' S i g n a l Frequency Spectrum'); g r i d on a x i s ( [ 0 10E6 0 5]) % P l o t the OUTPUT s i g n a l subplot(2,2,2) plot(SigTime,SigOUT,'g') xlabel('seconds > '); y l a b e l ( ' S i g n a l Amplitude (V) >'); title('Received Signal'); g r i d on a x i s ( [ 0 1.5E-5 -1.0 1.0]) subplot(2,2,4) plot(SigFreq,abs(FSigOUT),'c') xlabel('Hz > ') ; t i t l e ( ' S i g n a l Frequency Spectrum'); g r i d on a x i s ( [ 0 10E6 0 5]) % C a l c u l a t e the T r a n s f e r F u n c t i o n H = zeros(1,SN); f o r j = 1:1:SN H(j) = F S i g O U T ( j ) / F S i g I N ( j ) ; end % P l o t the T r a n s f e r F u n c t i o n figure(2) subplot(2,1,1) s e m i l o g x ( S i g F r e q , unwrap(angle(H))/2/pi*360, xlabel('Hz > ' ) ; y l a b e l ( ' P h a s e (deg) >'); t i t l e ( ' S y s t e m Phase Response'); g r i d on axis([5E4  'y');  10E6 0 360])  subplot(2,1,2) l o g l o g ( S i g F r e q , a b s ( H ) , 'm'); t i t l e ( ' S y s t e m Amplitude Response'); xlabel('Hz >'); g r i d on a x i s ( [ 5 E 4 10E6 1E-2 1E1]) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  132  B.1.4 QuickBASIC Program Files Programs for handling the Keithley Metrabyte M - S T E P 3 Step M o t o r Controller were written using Microsoft Q u i c k B A S I C 4.0. This used because the supplied driver files are for Q u i c k B A S I C only. Drivers for other languages are available, but at extra cost. The required Q u i c k B A S I C driver file is called MSTEP . L I B  make.bat echo T h i s i s the r e q u i r e d command t o a c t u a l l y compile the program. c:\qb4\bin\bc f:\project\stepper\move6.bas /E/X/O c : \ q b 4 \ b i n \ l i n k /EX MOVE6,f:\proj ect\stepper\move6.exe,NUL,f:\proj e c t \ s t e p p e r \ m s t e p . l i b ;  motion.cmd 3 3938 40  move6.bas ************************************************* * MOVE6.BAS * Author: * Date:  Isaac Leung March 19, 1996  * Description: * T h i s program p r o v i d e s the f a c i l i t i e s f o r c o n t r o l l i n g the MSTEP-3 * s t e p motor c o n t r o l l e r . Commands a r e i s s u e d by the way of a command * f i l e , which MUST be c a l l e d MOTION.CMD and MUST be l o c a t e d i n the same * d i r e c t o r y as the e x e c u t a b l e . * See the sample MOTION.CMD f o r an example. * The f i l e w i l l be o f the form: <Command> <No.# of Steps> <Speed> * Not a l l the arguments a r e used f o r a l l commands, but a l l must be * s p e c i f i e d anyways. See t h i s program l i s t i n g f o r a l l o w e d commands. ************************************************************************ DIM L$(17), P$(14), U$(14), D%(14), U(14), D$(3) COMMON SHARED D%() COMMON SHARED U() DECLARE SUB DECLARE DECLARE DECLARE DECLARE DECLARE DECLARE M.A.Sc. Thesis  QBMSTEP (MD%, BYVAL DUMMY%, STP&, FLAG%) SUB EmergencyStop (D%(), STP&, FLAG%) SUB E r r o r H a n d l e r (FLAG%) SUB S e l e c t C h a n n e l (D%()) SUB I n i t i a l i z e P a r a m e t e r s (D%(), STP&, FLAG%, U()) SUB D i s a b l e l n t e r r u p t (D%(), STP&, FLAG%) SUB MoveRelative (D%(), STP&, FLAG%, Speed%) Isaac Jing Hemg Leung  06/07/96  133  Appendices DECLARE SUB MoveLimit (D%(), STP&, FLAG%, Speed%) DECLARE SUB MoveHome (D%(), STP&, FLAG%, Speed%) DECLARE SUB ReadStatus (D%(), STP&, FLAG%) CLS PRINT " ****************" PRINT "* Move I t V0.6 *" PRINT " **************** " '  Declare arrays  'Default parameters f o r i n i t i a l i z i n g c o n t r o l l e r s S t a r t r a t e d i v i d e r : " : U ( l ) = 125'slowest p$(l) = " High speed run r a t e d i v i d e r : " : U(2) = 2 0 'medium P$(2) = " A c c e l e r a t i o n / d e c e l e r a t i o n s t e p s : " : U(3) = 200'200 steps P$(3) = " Motor type: " : U(4) = 2 '4 phase P$(4) = " E x c i t a t i o n : " : U(5) = 1 ' h a l f s t e p P$(5) = " L o g i c p o l a r i t y : " : U(6) = 1 ' i n v e r t e d P$(6) = " C l o c k source: " : U(7) = 0 ' i n t e r n a l P$(7) = " S w i t c h i n g a t s t a n d s t i l l : " : U(8) = 1 ' on P$(8) = " ON time f o r power s w i t c h f r e q : " : U(9) = 16'time on P$(9) = " OFF time f o r power s w i t c h f r e q : ": U(10) = 32'time o f f P$(10) = " P $ ( l l ) = "Port A d i r e c t i o n , 0=input, l=output : ": U ( l l )= 1'output P$(12) = "Port B d i r e c t i o n , 0=input, l=output : ": U(12) = 1'output A u x i l i a r y b i t , l=high, 0=low : ": U(13) = 0'low P$(13) = Base I/O address: ": U(14) = &H310 P$(14) = " D e c l a r e other CALL v a r i a b l e s FLAG% = 0 STP& = 0  'call error flag variable 'step count (must be double p r e c i s i o n )  REM REM  Command% = 0 Distances: = 4000 Slow% = 200 Medium% = 100 F a s t % = 20 REM D i r e c t i o n & = 1 CALL S e l e c t C h a n n e l ( D % ( ) ) CALL I n i t i a l i z e P a r a m e t e r s (D% () , STP&:, FLAG%, U()) OPEN "MOTION.CMD" FOR INPUT AS  #1  INPUT #1, Command% SELECT CASE Command% CASE IS > 7 PRINT " I n v a l i d Command" CASE 6 'What's the s t a t u s ? CALL ReadStatus(D%(), STPS, FLAG%)  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  134  Appendices CASE 5 'Move i t home INPUT #1, D i r e c t i o n s INPUT #1, StepSpeed% CALL MoveHome(D%(), D i r e c t i o n s , FLAG%, StepSpeed%) CASE 4 'Move i t t o the l i m i t s INPUT #1, D i r e c t i o n s INPUT #1, StepSpeed% CALL MoveLimit(D%(), D i r e c t i o n s , FLAG%, StepSpeed%) CASE 3  'Move the darn t h i n g a b i t 'Note t h a t i t c u r r e n t l y uses a c c e l e r a t i o n / d e c e l e r a t i o n 'and t h a t i n t h i s mode, SPEED i s n ' t used. I t ' s always h i g h INPUT #1, D i s t a n c e s INPUT #1, StepSpeed% CALL M o v e R e l a t i v e ( D % ( ) , D i s t a n c e s , FLAG%, StepSpeed%) CASE 2 'Turn o f f the I n t e r r u p t s CALL D i s a b l e l n t e r r u p t ( D % ( ) ,  STPS,  FLAG%)  CASE 1 ' I n i t i a l i z e a l l parameters IF Command* = 1 THEN CALL I n i t i a l i z e P a r a m e t e r s ( D % ( ) ,  STPS,  FLAG%, U()) CASE 0 ' I n i t i a l i z e Channel A CALL S e l e c t C h a n n e l ( D % ( ) ) CASE -1 'Emergency Stop CALL EmergencyStop(D%(), STPS, END  FLAG%)  SELECT  CLOSE  #1  END SUB D i s a b l e l n t e r r u p t ' REM  (D%(), STPS,  FLAG%)  MODE 14: E n a b l e / d i s a b l e i n t e r r u p t  * We're g o i n g to j u s t d i s a b l e to i n t e r r u p t . MD% = 14 INTLEV% = 5 D%{2) = 0 D%(3) = INTLEV% PRINT "MSTEP-3 => D i s a b l e I n t e r r u p t " PRINT " I n t e r r u p t L e v e l = "; INTLEV%  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  135  CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) IF FLAG% <> 0 THEN CALL ErrorHandler(FLAG%) END SUB SUB EmergencyStop (D%(), STP&, FLAG%) MODE 0: Emergency stop MD% = 0 PRINT "MSTEP-3 => Emergency Stop" 1  CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) IF FLAG% <> 0 THEN CALL ErrorHandler(FLAG%) END SUB SUB E r r o r H a n d l e r  (FLAG%)  4120  ' E r r o r code r o u t i n e PRINT "MSTEP-3 => E r r o r Handler" PRINT : PRINT " D r i v e r has r e t u r n e d e r r o r code FLAG% PRINT : PRINT "This was caused by:-": PRINT IF FLAG% = 1 THEN PRINT Motor busy e x e c u t i n g a command" IF FLAG% = 2 THEN PRINT D r i v e r n o t i n i t i a l i z e d on Channel A" IF FLAG% 3 THEN PRINT D r i v e r n o t i n i t i a l i z e d on Channel B" IF FLAG% 4 THEN PRINT D r i v e r n o t i n i t i a l i z e d on Channel C" IF FLAG% 5 THEN PRINT " Mode number <0 o r >12" IF FLAG% A hardware e r r o r e.g. 6 THEN PRINT " Wrong I/O MSTEP-3 board not i n computer": PRINT " address, PPMC c o n t r o l l e r f a i l u r e " Step count <-16,777,215 IF FLAG% = 7 THEN PRINT " or >+16,777,215" Motor a l r e a d y a t IF FLAG% = 8 THEN PRINT " s t a n d s t i l l . Command cannot be executed" Error IF FLAG% >= 10 AND FLAG% <= 2 4 THEN PRINT " i n range o f d a t a v a r i a b l e D%("; FLAG% - 10; " ) " PRINT INPUT "Press <ENTER> t o c o n t i n u e . . . ", DUMMY$ END SUB SUB I n i t i a l i z e P a r a m e t e r s '  MODE 15:  (D%(), STP&, FLAG%, U())  Initialize  MD% = 15 PRINT "MSTEP-3 => I n i t i a l i z e c o n t r o l l e r c a r d " PRINT " Base I/O Address = 784" PRINT " H a l f Step Mode" FOR 1% = 1 TO 14 IF U(I%) > 65535! OR U(I%) < -32768! THEN D%(I%) = -1: GOTO 3550 IF U(I%) > 32767 THEN D%(I%) = U(I%) - 65536! ELSE D%(I%) = U(I%) 3 550 NEXT 15 M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  136  Appendices  CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) REM * T h i s i s J u s t error- checking, I t h i n k . IF FLAG% <> 0 THEN CALL ErrorHandler(FLAG%) END SUB SUB MoveHome (D%(), STP&, FLAG%, Speed%) '  MODE 7: Constant speed t o home p o i n t  MD% = 7 PRINT "MSTEP-3 => Move t o home p o i n t " PRINT " (No a c c l e r a t i o n ) " D%(1) = Speed% CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) IF FLAG% <> 0 THEN CALL ErrorHandler(FLAG%) END SUB SUB MoveLimit '  (D%(), STP&, FLAG%,.Speed%)  MODE 5: Constant speed t o l i m i t  MD% = 5 PRINT "MSTEP-3 => Move t o l i m i t " PRINT " (No a c c e l e r a t i o n ) " D%(1) = Speed% CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) IF FLAG% <> 0 THEN CALL ErrorHandler(FLAG%) END SUB SUB M o v e R e l a t i v e '  (D%(), STP&, FLAG%, Speed%)  MODE 4: Constant speed  'MD% = 4 ' MODE 3: MD% = 3  Accelerate/Decelerate  PRINT "MSTEP-3 => Move R e l a t i v e " PRINT " D i s t a n c e = "; STP& PRINT " Speed = "; Speed% D%(1) = Speed% 1338 CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) IF FLAG% <> 0 THEN CALL ErrorHandler(FLAG%) END SUB SUB ReadStatus 1  (D%(), STP&, FLAG%)  MODE 8: Read s t a t u s MD% = 8  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  Appendices  137  PRINT "MSTEP-3 => Read S t a t u s " PRINT "" CALL QBMSTEP(MD%, VARPTR(D%(0)), STP&, FLAG%) IF FLAG%<> 0 THEN CALL ErrorHandler(FLAG%) PRINT "STATUS DATA RETURNED: HEX$(D%(2)) hex" PRINT " F i n i s h status = HEX$(D%(3)) PRINT " Input s t a t u s hex" HEX$(D%(4)) PRINT " Output s t a t u s = hex" STP& PRINT " Remaining steps = PRINT PRINT "From t h i s s t a t u s data, the f o l l o w i n g i n d i v i d u a l data can be e x t r a c t e d : - " •„ PRINT "From FINISH STATUS" PRINT "Last motion command was mode "; (D%(2) AND &H7) IF (D%(2) AND &H8) = &H8 THEN PRINT "Motor performed d e c e l e r a t i n g stop at h i g h speed l i m i t L3 o r L4" IF (D%(2) AND &H10) = &H10 THEN PRINT "Motor performed d e c e l e r a t i n g stop a t l i m i t L I or L2" IF (D%(2) AND &H20) = &H20 THEN PRINT "Motor enable c o n t r o l MC i s disabled" IF (D%(2) AND &H40) = &H40 THEN PRINT "Motor was stopped by a stop command and d i d not complete p u l s e count" IF (D%(2) AND &H78) = 0 THEN PRINT "Command completed n o r m a l l y " ELSE PRINT "Command aborted b e f o r e t r a v e l l i n g s e t number of s t e p s " IF (D%(2) AND &H80) = &H80 THEN PRINT "Last command i n t e r r u p t b i t s e t " ELSE PRINT "Last command i n t e r r u p t b i t c l e a r e d " PRINT : PRINT "From INPUT STATUS" IF (D%(3) AND &H1) = 0 THEN PRINT " L i m i t i n p u t L4 a s s e r t e d " IF (D%(3) AND &H2) = 0 THEN PRINT " L i m i t i n p u t L3 a s s e r t e d " IF (D%(3) AND &H4) = 0 THEN PRINT " L i m i t i n p u t L2 a s s e r t e d " IF (D%(3) AND &H8) = 0 THEN PRINT " L i m i t i n p u t L I a s s e r t e d " IF (D%(3) AND &H40) = 0 THEN PRINT "Motor on s i g n a l MC i s d i s a b l i n g controller" IF (D%(3) AND &H80) = 0 THEN PRINT "Motor i s a t base p o i n t r e f e r e n c e " IF (D%(3) AND &HCF) = &HCF-THEN PRINT " A l l l i m i t i n p u t s a r e h i g h (not asserted)" PRINT : PRINT "From OUTPUT STATUS" PRINT "Phase outputs S1-S5 a r e a t l o g i c l e v e l s "; FOR 1% = 7 TO 3 STEP -1 IF (D%(4) AND 2 1%) = 2 ^ 1 % THEN PRINT "1 "; ELSE PRINT "0 NEXT 1% A  INPUT "Press  <ENTER> t o c o n t i n u e . . . " ,  DUMMY&  J  END SUB SUB S e l e c t C h a n n e l '  (D%())  Pseudo mode 16: Get channel A, B or C on MD%=16 and p l a c e i n  D%(0) PRINT "MSTEP-3 => S e l e c t Channel A" 'This s e t s the Channel t o A D%(0) = 0 END SUB  M.A.Sc. Thesis  Isaac Jing Herng Leung  06/07/96  

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.831.1-0064841/manifest

Comment

Related Items