+ All Categories
Home > Documents > The Monitoring of a Laser Beam, By Ingemar Eriksson

The Monitoring of a Laser Beam, By Ingemar Eriksson

Date post: 14-Apr-2018
Category:
Upload: princedotty
View: 214 times
Download: 0 times
Share this document with a friend

of 43

Transcript
  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    1/43

    The monitoring of a laser beamIngemar Eriksson

    Department of Information Technology and Media (ITM)Mid Sweden University

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    2/43

    AbstractThe origin of this project involved the problems associated with variations of the laser

    beam in material processing using a laser. The main problem is that a change in the

    laser beam profile does not become obvious until the end result begins to fail. Tomonitor the beam, the suggestion was to mount a camera in front of the laser, and acomputer would then use the camera images to monitor the beam properties.

    The most important property of a laser beam is the width. However, afterimplementation of the method in the ISO 11146 standard, the conclusion drawn wasthat the method was not suitable for noisy images and investigations were conductedinto alternative methods to calculate the beam width.

    The implementations with regards to the monitoring was in terms of max and minlimits for a Kalman-filter that smoothes out the measured values before testingwhether or not the value is acceptable. This combination is capable of detectingchanges within a noisy measurement.

    The final result of the entire project was a Labview program that measures andmonitors a laser beam profile.

    SammanfattningUrsprunget till detta examensarbete var problemen med varierande laserstrlar vid

    material bearbetning med laser. Problemet r att en frndring av laserstrlen intemrks frrn slutresultatet blir mrkbart frsmrat. Fr att vervaka laser strlen fre-slogs att en kamera monterades framfr lasern, och en dator som anvnder bildernafr att vervaka strlens egenskaper.

    Den viktigaste parametern hos laserstrlen r bredden. Nr ISO 11146 standardensmetod implementerades, konstaterades snart att denna metod inte var lmplig fr

    brusiga bilder. Drfr undersktes alternativa berkningsmetoder fr att erhllastrlbredden utifrn bilder tagna av en kamera.

    Fr sjlva frndringsdetekteringen implementerades ett Kalman-filter. Denna

    kombination visade sig vara mycket effektiv fr att detektera frndringar hos enbrusig mtning.

    Hela projektet resulterade i ett Labview program som mter och vervakar enlaserstrles utseende.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    3/43

    Preface

    This master thesis is the final step towards my Master Degree in ElectricalEngineering. The work was performed over a 20-week period of full time studies at

    Mid Sweden University. The majority of the time was spent in the Laser-laboratory instersund where I had access to the high power lasers.

    The idea for the project comes from Laser Nova AB in stersund, and I had a greatdeal of assistance from my supervisor at the company Rickard Olsson.

    Mid Sweden University 2005

    Ingemar Eriksson

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    4/43

    1

    Table of contents1 Introduction .................................................................................................... 2

    1.1 Background............................................................................................. 21.2 Problem description ................................................................................ 2

    1.3 Goal of the project .................................................................................. 21.4 Report structure ...................................................................................... 2

    2 Theory............................................................................................................ 32.1 What is a laser beam?.............................................................................. 32.2 Measurement methods ............................................................................ 52.3 Calculation methods................................................................................ 82.4 Detection of change ...............................................................................132.5 Visualization..........................................................................................15

    3 Method and realization ..................................................................................163.1 Experimental setup.................................................................................163.2 Simulation .............................................................................................173.3 Measurement program ...........................................................................183.4 Monitoring and supervision of the Laser beam.......................................18

    4 Results...........................................................................................................194.1 How well does the calculation methods work.........................................194.2 Possible improvement of the four-sigma method....................................254.3 Kalman filter..........................................................................................274.4 Simulated beam vs. Real beam...............................................................294.5 Labview program...................................................................................30

    5 Conclusions and discussion ...........................................................................31Abbreviations........................................................................................................33

    Bibliography .........................................................................................................34

    Appendix

    A Camera requirements

    B Matlab code

    C Equipment

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    5/43

    2

    1 IntroductionIt is probable that the reader will require some knowledge about Laser-technology

    and Adaptive-filtering to fully comprehend the report although those readers with

    mathematical knowledge will understand most of the report.1.1 BackgroundLaser Nova is a company offering almost everything within the area of micromachining with lasers, e.g. welding, cutting, drilling, annealing, scribing andmarking which is performed using Nd:YAG- and CO2- lasers. In laser material

    processing the quality and shape of the laser beam is fundamental to the end resultand Laser Nova would like to monitor the laser beam continuously in order to gain

    better control over the process and thus achieve a better quality end product.

    The purpose of the project was to develop and investigate methods to be able to

    monitor a laser beam. The system should be able to warn the operator when thebeam properties change.

    1.2 Problem descriptionA high power laser can change the beam profile in numerous ways, e.g. when thereis a temperature change in the active medium, thermal lensing in a Nd:YAG-rod,unstable resonators etc. Also the shape of laser beam varies due to mirror positionsand pumping power from the light amplifier. The laser mode can change abruptly,which can cause a dramatic impact on the end result of the product. In real

    production it is difficult to see when the changes occur. However it is crucial toobtain greater control of this parameter in order to avoid situations where productsmust be discarded or sent back from the end customer.

    1.3 Goal of the projectThe goal of the project is to investigate and evaluate methods involved in themonitoring of Nd:YAG lasers, primarily the beam width, power, astigmatism andlaser mode. Change detectors will also be implemented to give a warning whenthere is a parameter change.

    One side effect of the monitoring, involves an image of the beam being possiblyused as a tool to make easier adjustments to the laser beam, by visualizing the beam

    profile to the operator.

    1.4 Report structureThe report starts with a theory section, which explains different ways of measuringa laser beam and some methods of calculating the beam width from an intensityimage. This section also includes a brief explanation of the Kalman filter and theCUSUM algorithm. A description of the setup and methods used to evaluate thecalculation methods then follows. The final part of the report contains the resultsand conclusions of the project.

    References are marked by square brackets [ ]. References to the appendices aremarked using the letter of the appendix. i.e. [B] is a reference to Appendix B. Ifthere is a number between the brackets then it is a reference to the bibliography.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    6/43

    3

    2 Theory2.1 What is a laser beam?A brief description of laser technology and some of the vocabulary used is given

    below. It is not intended as a textbook chapter on laser technology, but merely as abrief introduction to those unfamiliar with lasers.

    Laser is an abbreviation ofLight Amplification by Stimulated Emission of Radiation,and is a means of creating high power coherent light. The light is amplified bycopying photons in an amplifier. By putting a mirror on each side of the amplifierthe light is multiplied several times thus creating very high light intensity. One ofthe mirrors (front mirror) is semitransparent and thus a ray of light will emerge anda laser beam will be coupled out of the laser cavity (see Figure 1)

    Figure 1 A laser cavity

    Between the mirrors inside the laser cavity the light will interfere with it self andcreate different laser modes. These transversal electromagnetic modes (TEM) can

    be categorized according to the number of minima along the X and Y direction (seeexamples in Figure 2). These modes can be calculated using 2D-Hermite poly-

    nomials.[12] Other types of modes can appear but the TEM modes are those mostcommonly found in the literature.

    Figure 2 TEM00 TEM01 TEM21

    The TEM00 beam is essentially a 2D Gaussian bell curve, the width of the beam iswhere the curve exceeds 1/e2 (=13,5%) of the maximum value. More complex

    beams can appear when several modes are combined, e.g. if a TEM00 and TEM01

    are combined correctly, an elliptical beam can appear.

    A perfect TEM00 laser beam is difficult to accomplish. Often the power in the laseris decreased when generating a TEM00 beam, as all other modes must be removed.Some lasers are unable to generate a true TEM00 beam due to the mirrorconfiguration.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    7/43

    4

    By combining several modes, complex beam profiles are created (see Figure 3) andthe total power is the sum of the powers in the modes. In real life the use of an ugly

    beam is often sufficient for the required job.

    Figure 3 Examples of different laser beam profiles

    As the Gaussian profile (TEM00) provides the smallest focus point, this is thepreferred shape for e.g. cutting applications, whereas a flattop beam profile ispreferable for welding, annealing etc.

    Laser beams are by nature divergent and the beam will always increase in widthover distance. The least divergent beam is the TEM00 beam. The beam propagationfactor M2, is a parameter which describes how much faster a real beam diverges incomparison to a TEM00 beam. A beam with an M2=3.1 will diverge 3.1 times asfast as a TEM00 beam. The M2 parameter is an important property of the laser beamas it describes how easy it is to focus the beam on a surface. The M 2 is usuallycalculated by measuring the beam width at several distances from a lens. However,no standardized method for measuring the M2 parameter exists.

    One of the most common lasers in the industry is the CO2-laser with 10.6mwavelength. This is a gas laser using CO2 as the active medium in the amplifier.

    Another common laser type is Nd:YAG with 1,064m wavelength and this is acrystal laser using a Neodymium doped YttriumAluminumGarnet rod as the activemedium in the amplifier. Both of these laser types can be manufactured to give aoutput power from a few Watts up to several Kilowatts, making them ideal formaterial processing. CO2 lasers often produce the laser light continuously, so calledcontinuous-wave (CW). Nd:YAG lasers can be operated in pulsed mode, the lampdriving the amplifier is more efficient in pulsed mode, thus increasing the efficiencyof the laser. These produce milliseconds long pulses of laser light. Alternately the

    Nd:YAG laser can be operated in Q-switched mode[9] where nanosecond longpulses produce high peak power with a low power laser. A peak power of severalMegawatts can be produced with an average power of a few hundred Watts.

    The longer wavelength of CO2 makes it possible to obtain light absorption in mate-rials transparent to visible light e.g. glass and acrylic.

    The shorter wavelengths of Nd:YAG laser have a better absorption in metal. Glassis transparent to the light from Nd:YAG lasers thus making it possible to use anoptical fiber delivery system thus enabling the laser source to be in a different

    position to that of the processing point.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    8/43

    5

    2.2 Measurement methodsThe need for measuring methods means that several, more or less accurate methodshave evolved. Often a method is used merely because it is simple and the alternativeis too complicated or expensive[11].

    2.2.1 Laser powerThe power of a laser is usually measured by a photodiode, or using calorimetricmethods. The measured power is usually the total power in the beam. If some kindof imaging measurement is made instead, the power distribution inside the beamcan be observed, making it easier to tune the laser to the desired beam shape.

    2.2.2 Laser beam widthIf the laser is operating within the visible wavelength region, the simplestmeasurement is to project the beam onto a screen, possibly with the use of a beamexpander to enlarge the beam. The image on the screen then enables observation ofthe beam width. This method is easy, quick and intuitive. One drawback, however,is that the human eye has a logarithmic response to light making it difficult for aqualitative judgment of the beam profile to be made. It is difficult to perceive thedetails in the high power areas of the beam. As this measurement is subjective it isalso hard to repeat the measurement and to compare laser beams.

    2.2.2.1 Fluorescent material

    For invisible laser beams close to visible wavelengths e.g. Nd:YAG, a fluorescentmaterial can be used to convert the laser light into visible light. In this way laserswith invisible light can be monitored as if they were emitting light in the visible

    area.

    One problem with this method is that the fluorescent material may be nonlinear.Logarithmic or derivative effects can cause even more complications whenattempting to produce a good measurement.

    2.2.2.2 Burned spots

    One way to examine the beam profile with high power lasers is to allow the laser toburn a hole in a paper. The shape of the hole represents the shape of the laser beam.The result is dependent on the length of time for which the paper is burnt and only afew power levels can be observed within the beam. (Not burnt, burnt and ash.)

    The advantages of the method are its simplicity and the possibility to save and com-pare laser beam profiles. The shortcomings of the method are the bad resolution inpower levels, its slowness and the high power required.

    The method is the same even if materials other than paper are being burnt. Wood,steel and acrylic plastics can be used in order to burn spots, with similar result.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    9/43

    6

    2.2.2.3 Moving Knife-edge

    To increase the accuracy in the width measurement, better methods have beendeveloped. The moving knife-edge method uses a large area power detector. A

    moving knife-edge is used to cut off part of the laser beam, see Figure 4. By re-cording the power reaching the detector as a function of the knife-edge position, it is

    possible to monitor the beam profile in the cutting direction. According to ISO11146 [7] the width of the beam is calculated by measuring the positions where16% and 84% of the beam power are transmitted, but other power levels are alsoused. The distance between these positions is the uncorrected beam width anddenoted by dk. This width is later corrected to give the same width as the secondorder moments width (see section 2.3.2). The correction is individual for differentlasers, modes and M2 values.

    Figure 4 The moving knife-edge method is using a knife to block part of the laser beam

    Several knives cutting the beam in different directions can be used, and with com-puter aided tomography, details in the beam can be recreated. This way a completeintensity image can be achieved

    An advantage of the moving knife-edge method is that it is capable of measuringsmall beams (< 1m) and high power beams can be measured with little or noattenuation.

    The method does, however, possess some drawbacks. If the beam is elliptical theknife should move along the major and minor axes of the ellipse, the scanningsystem must be rotated. Because it is a mechanical scanning system it is alsodifficult to measure pulsed laser beams, especially if the beam profile changes from

    pulse to pulse.

    There are several measuring methods using similar techniques, all sharing the samepros and cons, for example the Moving Slit and the Variable Aperture methods.

    2.2.2.4 CCD-camera

    A better means of observing details in the beam, in comparison to the movingknife approach, is by making an array of detectors. For wavelengths in the visibleand near-infrared area a standard CCD-camera can be utilized as a sensor array.Pyroelectric arrays have bean developed for lasers which operate outside the areawhere CCD-cameras are sensitive (400nm-1100nm).Because standard camera sensors are very sensitive to light, the laser light requires

    attenuation before it reaches the sensor. This can be performed via the use ofsemitransparent mirrors, which allow a small part of the laser power to passthrough. Neutral Density filters can also be used to attenuate the light. If several

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    10/43

    7

    filters/mirrors are stacked, it is important to align them in order to minimizeinterference phenomena that can distort the image of the beam. Dust on thefilters/mirrors can also seriously distort the image of the laser beam.

    With the CCD-camera a complete image of the laser beam is taken at once. This

    makes it possible to measure single pulses of lamp pulsed and Q-switched lasers.

    After the image is acquired, a computer calculates the width of the beam. There areseveral calculation methods available to perform this, some of which are describedin section 2.3.

    To perform the measurement of the laser beam in this project, the camera methodwas chosen. The main reason for this was that a complete 2D beam profile isachieved and fast measurements are possible. With some machine vision camerassingle laser pulses can be separated and measured. Also there are cameras availablein reasonable price classes for the intended use.

    For this project available cameras and a frame grabber to convert analog camerasignals to digital were used. The cameras proved to be insufficient for measuring

    pulsed lasers, as no external trigger was available on the cameras. A shortevaluation of different cameras and their characteristics can be found in appendix A.

    It is only possible for a camera to provide an intensity image of the beam. Thisimage is then processed and the width, power and laser mode are then extracted.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    11/43

    8

    2.3 Calculation methodsThe goal of the project was to monitor the beam and give a warning if changesoccur. If the laser mode is changed then this will cause the beam width to alsochange. This leads to the conclusion that it is best to focus on measuring and

    monitoring the beam width, as this will also indirectly monitor the beam mode. Thetotal power of the beam is proportional to the sum of the intensity in all pixels. It isdifficult to measure the absolute power; all the attenuators need to be calibrated. It is

    better to measure the absolute power by other means and only measure the relativepower with the camera, and warn the operator when the power changes.

    Looking at Figure 3 it is easy to realize the problem to correctly measure the width.As Mike Sasnett remark[6]on a beam similar to the industrial profile: trying to de-

    fine a unique width for an irregular beam profile like this is something like trying to

    measure the width a ball of cotton wool using a calipers. This offers an insight into

    the complexity of the problem.

    None of the calculation methods proposed by anyone so far has been successful incalculating the width for all laser beams. The one coming closest is the ISO 11146standard which entails a second order moment calculations. The second order mo-ment of the beam is the 2D-variance. The width of the beam is defined as four timesthe standard deviation of the beam.Other ways to define the width of the beam are;

    The full width at half of the maximum intensity (FWHM) The diameter containing 86% of the total power.

    The width at 1/e intensity points The width at 1/e2 intensity points The width of the best fit Gaussian beam The width of the best fit flattop beam The Knife-edge width of 16%-84% power points The Knife-edge width of 10%-90% power points The Knife-edge width of 5%-95% power points

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    12/43

    9

    2.3.1 Center of gravityThe equations and figures in section 2.3.1 and 2.3.2 are copied directly from ISO11146

    During automated laser processing the position of the beam is an important prop-erty.[11] The center of gravity is the best way to represent the center of the beam asthere is an equal amount of power in all directions from the center of gravity. Thecenter of gravity of a laser beam is the same as the average value of the projectionon the X and Y axes of the image. This is not necessarily the same point as themaximum power in the beam.

    E(x,y) is the beam irradiance (intensity) in the pixel (x,y)P is the total intensity (power) in the beam, and is the position for the cen-ter of gravity. All integrals are done over the entire image.

    To calculate the center of gravity the following three equations are used:

    2.3.2 VarianceThe ISO 11146 standard [7] defines the width of the beam as four times thestandard deviation, this leads to the expression four-sigma width sometimes calledthe second moment width. If the beam is circular or if it is elliptical and aligned tothe X and Y axes, the beam can be projected on the X and Y axes and the width ofthe beam can be calculated from the projections. This will simplify the calculation

    but will give a false width if the beam is rotated. To obtain the correct width thecovariance between X and Y is utilized and the width is calculated along the ellipseaxis. If an elliptical beam is aligned to the axes then the covariance becomes zero.The variances of the projection on the axes are denoted and and the

    covariance of the beam is . These are calculated via the following threeequations

    .)(),((1

    and

    ))((),((1

    ,)(),((1

    22

    22

    dxdyyyyxEP

    y

    dxdyyyxxyxEP

    xy

    dxdyxxyxEP

    x

    The beam width closest to the X-axis is calculated using,

    dxdy .

    yyxEP

    y

    dxdy,xyxEP

    x

    dxdyyxEP

    )),((1

    )),((1

    ),(

    and

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    13/43

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    14/43

    11

    Figure 6 Profile of a beam from an image.

    2.3.3 Software Moving Knife-EdgeA software version of the moving knife-edge measurement can be made by setting

    pixel intensities to zero when the knife-edge is moving across the image. The poweris measured by summing the intensity of all the pixels. The simple calculations ofthis method and as it is less sensitive to noise than the variance based four-sigmacalculations have made the software calculations popular in existing beam profiling

    programs. The fact that the hardware (section 2.2.2.3) version is approved in theISO 11146 standard is clamed as proof that the software version also is an approvedstandard. However the software version is never mentioned in the standard.

    Advantages over the hardware version are that the CCD-camera can be used onpulsed beams, and that the direction of the knife can rotate in software making itfollow an ellipticbeams major axis.

    2.3.4

    ThresholdAn easy method to separate the beam from the background is to threshold the imageat a specific level. All pixel values above the level is set to one (illuminated), all

    pixel values below the level are set to zero. By counting the number of illuminatedpixels along a line intersecting the center of the beam, the width of the beam isfound. If the threshold level is set to 50% of the maximum intensity, the FWHM(Full Width Half Max) is received. If the beam is a TEM00, a level of 13.5%(=1/e2) will give the same width as the four-sigma method. Other threshold levelscan also be used for example 1/e, depending on the beam profile.

    As in the moving knife calculation it is necessary for the width to be calculated

    along the principal axis of an elliptical beam and these directions can be found bynumerous methods. One method is to place the coordinates for the pixels above thelevel in a matrix A. Then calculate the principal components of the illuminated area

    by calculating the eigenvectors of A*AT. The eigenvectors will be pointing in thedirection of maximum and minimum variance showing the directions of the axes ofthe ellipse. If the matrix A is big, the calculation of A*AT will be time consumingmaking this algorithm less suitable for online calculations.

    It might be faster to calculate the beam width along several directions and find theaxes of the ellipse by trial and error. There will be a small error in the angle, but for

    bigger beam sizes the calculation is a great deal faster than the eigenvector method.For circular beams higher precision is achieved by taking an average of the diameterin several directions.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    15/43

    12

    2.3.5 OffsetImages from a camera always contain noise. The noise can be divided into two

    parts; a high frequency random noise originating from electrical noise in the sensor

    array and a constant offset level originating from ambient background light. Thehigh frequency part is difficult to deal with in a single image. However, an averageof several images can reduce the high frequency noise but this makes it difficult todetect sudden changes. The offset can be subtracted from the image as a correction;the problem is to find the correct offset to subtract from the image. The four-sigmamethod is very sensitive to offset errors.

    The ISO standard carefully describes methods to reduce the offset error. The firstthing to do is to check if the offset is uniform, which is performed as follows. Blockthe laser beam and take an average of a minimum of 10 images, which willminimize the effect of high frequency noise. The average image is the background

    map and should be subtracted from images before calculating the beam width. If thevariance in the background map is less than the high frequency noise variance thenit is sufficient to subtract a constant offset level from all pixels.

    It might be sufficient to utilise an average image background map. However, if lightfrom the pumping lamps in the laser amplifier or stray laser light reaches the camerathe offset will increase when the laser is on. This means that it might be necessaryto calculate the background map while the laser is on. To do this, it is necessary tocalculate an offset level from those pixels not illuminated by laser light.

    The background offset is divided in to the mean value E(offset) and the standarddeviation offset. In the ISO standard all pixels satisfying E(x,y)> E(offset)+n* offsetare illuminated. (the n value is between 2 and 4) The rest of the pixels should beincluded in the calculation of a new offset level.

    The values E(offset) and offset can be calculated by using non-illuminated areasfrom the corners of the image. To overcome the error from the quantization of theimage intensity, a moving average of the image is calculated (A 2D-convolutionmap of ones divided by the size of the convolution map). When a blurred image isused to determine whether or not a pixel is illuminated, the threshold level can beset to parts of a greyscale value.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    16/43

    13

    2.4 Detection of changeTo detect and give an automatic warning is not a problem specific to this project; itis required in many surveillance systems. A change can be either an abrupt changeto a new level, or a slow gradual change.

    2.4.1 Max-Min limits.This method is basically to check whether the measured value is within a predefinedinterval. If any of the measured parameters is outside the desired interval an alarmwarns the operator. To reduce the false alarms caused by noisy measurements theMax-Min test is preformed on the filtered values from the Kalman filter

    2.4.2 Kalman filtering and CUSUMThe Kalman filter was first derived by R.E. Kalman in 1960 [1]. The filter is the

    optimal filter for the estimation of a random signal distorted by white noise.

    The filter is based on a state X that is changed by a transition matrix A. The state isalso assumed to vary with a normally distributed process noise with variance Q as

    X(t)=A*X(t-1) + N(Q).

    A measured quantity Y can be derived from the state X via a state transition matrixC. The measurement is disturbed by measurement noise with variance R. This can

    be written as

    Y=C*X + N(R).

    In the Kalman filter, a state X is estimated first. Then the covariance P for theestimate is calculated and at a later stage, a correction is made to the estimated stateto provide a better fit with the actual measured value Y. The Kalman amplificationfactor K decides how much correction is made.

    Figure 7 The Kalman-filter is basically five equations

    X (t|) : Estimate of the state at the time t, given the measurement up to time Y() : Measurement at the time

    P : Covariace of the estimation error .

    K : Kalman amplification factor.

    Using Kalman filtering means relatively few calculations when the transition matri-ces are known. Also if the variance of the measurement noise R and process noise Q

    are constant, then K and P are constant and can be calculated in advance thus reduc-ing the number of calculations.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    17/43

    14

    If the state is constant (for example a direct current) A=1 and measured directlyC=1 then the Kalman filter will converge to a one tap IIR filter. The problemassociated with Kalman filters in general is to find the correct variance of R and Q,once this is done the Kalman filter is the optimal filter for the task.

    The difference between estimated value and measured value is the so-called residual

    (t) = Y(t)-C*X (t|t-1).

    If the estimate is correct the residual is white noise with zero mean. When the esti-mate differs from the true state the residual mean is non-zero.

    The CUSUM algorithm adds the residuals over time, and the sum is written as

    g(t) = max[0,(g(t-1)+ ((t)-))],

    where is a drift factor. When the sum g(t) exceeds a value h a change is detected.

    g(t)>h Alarm

    By setting the cumulated sum g(t) to zero while the residual is smaller than, theCUSUM alarm time is shortened.

    To detect changes when the true state decreases the sign of the residual is changed,i.e.

    (t) = C*X (t|t-1) - Y(t).

    The values of and h decides how sensitive the CUSUM is and how fast the alarmreacts on changes, and are design parameters.

    When a change is detected either a warning to the operator is sent out or the Kalmangain K is changed so that the Kalman filter will have a faster response.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    18/43

    15

    2.5 VisualizationThe visualization of the beam is a simple task to perform when an image is acquiredto a computer. A black and white image is basically the same as looking directly at

    the beam, by representing different intensity levels as colors the operator can moreeasily distinguish the levels. An even better way of visualizing the beam is to plot a3D graph and combine this with colors, see Figure 8.

    Figure 8 3D visualization of a TEM00 beam

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    19/43

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    20/43

    17

    support for standard industrial cameras in LabView, thus making it possible tochange the camera without changing the software.

    3.2 SimulationTo verify and examine the calculation methods, simulations were carried out inMATLAB, which enabled it to be possible to have total control over the beamwidth, ellipsity, noise and offset. To simplify the evaluation of the calculationmethods, the width calculations were made in MATLAB, so no conversion toLabView were necessary.

    The four-sigma method and threshold method were implemented in MATLAB. Thethreshold method was implemented in two versions, eigenvector and trial and errormethod to calculate the angle of an elliptical beam. The methods gave the sameresults for circular beams, but the eigenvector method was slower so most of theresults are based on the trial and error method.As the four-sigma method was very noisy an improvement to the method wasimplemented at the end of the project, see section 4.2.

    The reason for simulating laser beam images was to examine the problems withinthe two width calculations methods, mainly focusing on the noise and offset in theimages.

    3.2.1 Simulation of laser beamPerfect Gaussian (TEM00) laser beams were mostly used because of their optimal

    beam shape. But algorithms for elliptical beams, and arbitrary TEMxy beam based

    on Hermite polynomials were also developed for evaluation. The width in the X andY direction, possible rotations and the center of the beam were used as inputparameters.

    Figure 10 Test image size 240x320, with a simulated 100 pixel wide TEM00 laser beam. Equal

    to 41% of the image height and 31% of the image width. The maximum intensity of the beam

    was 60% white (153 of 255). An offset of 20 was added to the image. This was the starting point

    for most tests.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    21/43

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    22/43

    19

    4 Results4.1 How well does the calculation methods workTo test the calculations methods, simulations of laser beams were used for the four-sigma and threshold methods. Unless otherwise stated, the image in Figure 10 wasused in the simulation.

    4.1.1 Offset levelTo test the effects of subtracting a faulty offset level, the subtracted offset was set toa fixed value and introduced to the calculation models.

    When applying a positive error to the offset level, a systematic error of the widthappears in the four-sigma method. All pixel values higher than zero make a

    contribution to the beam width, and when the whole image is higher than zero thecalculated width is increased. The four-sigma calculations have a systematic errorof 55% in the X-direction with the introduction of an offset error of one grayscalelevel to Figure 10.

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1100

    110

    120

    130

    140

    150

    160

    Offset error(Grayscale levels)

    Calculatedwidt

    hinpixels

    X-Direction

    Y-Direction

    Figure 11 An error is produced by an offset error in the four-sigma calculations. The simulatedbeam size was 100 pixels

    The systematic error is larger if the beam size is small in comparison to the image.This is the reason for the error in the X-direction being larger (beam size 31% ofimage) than in the Y-direction (beam size 41% of image), see Figure 10.

    Figure 12 shows the error of the width calculation in images with an offset error of0.1 grayscale levels, the beam width in this simulation is altered to test the effects ofdifferent sizes. The figure shows an exponential behavior in the error showing that itis important to attempt to have a large beam size in comparison to the image size.

    This is particularly true if the background light is fluctuating thus not enabling theoffset level to be averaged to the correct value.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    23/43

    20

    15 20 25 30 35 40 45 500

    20

    40

    60

    80

    100

    Beam width in percentage of image size.

    Percentageerrorincalculatedbeamw

    idth

    Figure 12 Error in width calculation with 0.1 grayscales error in offset

    The threshold method is less sensitive to error in the offset. If the zero level ismoved, the cutoff level is also moved, giving a systematic error insensitive to the

    beam/image size ratio. The effect is not as dramatic as in the four-sigma method,less than an 8% systematic error in width occurs with an offset error of 5 grayscalelevels in a 100 pixel wide beam. An error of 5 grayscale levels in the zero level willchange the offset level from 13.53% (1/e2) to 10.3% when the maximum intensity is183 levels and the true offset is 20 levels. If the beam profile has steeper edges thana Gaussian beam, the reduction in the width error will be even greater than for thethreshold method.

    4.1.2 Beam sizeWhen the laser beam is large, a significant amount of energy falls outside the sensorarray and the calculated width is smaller than the actual beam size. The four-sigmamethod begins to fail when the beam size is bigger than 60% of the image size, seeFigure 13. This shows that there is a limit to the size of the beam in comparison tothe image.

    0 20 40 60 80 100 120 140-25

    -20

    -15

    -10

    -5

    0

    5

    Beam width in percentage of image size

    Percentageerrorincalc

    ulatedbeamw

    idth.

    Figure 13 Four-sigma calculation error on big beams

    The threshold method produces a correct width to the point where the beam is thesame size as the image. Larger beams are set to the image size.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    24/43

    21

    For small beams the influence quantization of pixels becomes clear in the thresholdmethod, see Figure 14. If an average width in several directions is used, then theeffect of quantization is decreased. This simulation was free from noise and the cor-rect offset level was used in the four-sigma calculations.

    0 5 10 15 20 25 300

    5

    10

    15

    20

    25

    30

    Beam width (pixels)

    Calcu

    latedbeamw

    idth(Pixels)

    Four sigma

    Threshold

    Figure 14 Small beam size

    4.1.3 Light intensityIf the intensity of the laser beam exceeds the saturation level of the camera, the cal-culated beam width will increase in both methods. With an overexposure of 50% the

    four-sigma method shows a 3% error and the threshold method a 10% error. Whenoverexposing by 400% the errors increase to 18% and 30%, respectively.

    4.1.4 NoiseTo test the noise robustness a 500-frame movie was simulated. Every frame wascomposed of the image Figure 10 with Gaussian noise added. The standarddeviation of the noise was equal to the frame number divided by 100. This gave theerror in calculation of the methods as a function of the noise in the image. All cal-culations in section 4.1.4 were performed using the same movie.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    25/43

    22

    Figure 15 Four-sigma calculations

    Figure 15 shows the results of the four-sigma method when subtracting the correctoffset value. The errors are produced by the noise in the image.

    The same movie was used with threshold calculations, the width in several direc-tions was calculated and the maximum, minimum and mean widths are displayed inFigure 16. It should be noted that there was no guarantee that the max and minwidths were perpendicular.

    Figure 16 Threshold calculations

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    26/43

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    27/43

    24

    4.1.5 OffsetAs seen in section 4.1.1 the four-sigma method is sensitive to errors in the offset.The calculated offset is affected by noise as seen in Figure 19. This calculation uses

    n=2 for the threshold determining whether or not a pixel is illuminated. If a largervalue is chosen forn, then illuminated pixels will be included in the calculation ofthe offset. This will increase the calculated offset level, and a systematic error willappear in the calculated width.

    Figure 19 Calculated offset level

    The same calculations as in Figure 15 but using the calculated offset from the cornerpixels instead of the fixed and true value shown in Figure 20 (Note the scale). This

    demonstrates the consequence of unstable offset level.

    Figure 20. Four-sigma calculated with calculated offset.

    To obtain a better estimate of the offset in real images, one method is to include allthe non-illuminated pixels in the offset. However a problem is if illuminated pixelsare included or positive noise excluded, as this introduces a systematic error into thewidth calculations, thus the threshold level (n=2-4) must be chosen with care! Anaveraging filter or Kalman filter can remove frame to frame noise from both the

    offset level and the calculated width. An averaging 2D-filtering (blurring) of theimage can assist in decreasing the high frequency noise, but the problem of findingthe correct offset level still remains.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    28/43

    25

    4.1.6 AngleThe ISO standard four sigma calculation gives the angle of an elliptical beam. If theeigenvectors of the threshold image are calculated the same angle is received as

    long as the major axis of the ellipse is closest to the X-axis. The four sigma methodcalculates the angle to the axis closest to the X-axis, while the eigenvectors give theangle between the major axis of the ellipse and the X-axis.

    If the eigenvectors of a circular beam 100 pixels wide are calculated, the coordinatevector A is almost 8000 elements long. Thus the calculation of A*AT is slow. Asan alternative method, the width of the beam along every 5 degrees is calculated andthe longest width is set as the major axis of the ellipse. This trial and error methodwill quantize the angle, but the calculations are faster for large beams.

    To test the angle calculation methods an elliptical beam was rotated in different an-

    gles. The major width of the ellipse was twice as long as the minor width. Thesimulated angle was compared with the calculated angle from the different methods,see Figure 21. The four-sigma method displays the angle to the minor-axis when theangle to the major-axis exceeds 45 degrees.

    Figure 21 Angle calculation

    4.2 Possible improvement of the four-sigma methodThe major problem concerning the four-sigma method is the offset sensitivity.

    Noisy calculations of the offset produce massive noise in the width calculations. Asseen in Figure 12 the error in the width calculations is dependent upon the extent towhich the beam fills the image. Carlos B. Roundy[8] suggests that the beam width

    be measured initially using a software-knife edge and subsequently apply a softwareaperture around the beam. An aperture twice as large as the beam size will reducethe noise in the four-sigma calculations.

    As an alternative to this method I suggest that the pixels determined to be non-illuminated in the offset calculations are set to zero after the offset level has been

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    29/43

    26

    subtracted from the image. By this means, it is the noise level in the image thatdetermines how much of the beam is cut off, not the beam width. In Figure 22 noiseof 5 gray levels in standard deviation was added to Figure 10. The light green areaswere deemed to be non-illuminated when n was set to 2. thus giving an approximate2X aperture to the image. However, the calculation has already been completed

    during the calculation of the offset level.

    Figure 22 Non-illuminated pixels as Green

    The same simulation as in Figure 20 (with a different noise seed) but calculatedafter setting the non-illuminated pixels to zero gives the result in Figure 23

    Figure 23 Improved four-sigma calculations

    The improvement is clear and is easier to implement the method suggested byCarlos B. Roundy. One problem occurring with the method is the choice of thecorrect value forn. A value of 4 will result in including illuminated pixels in theoffset level and setting them to zero. This will introduce a systematic error into thecalculated width.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    30/43

    27

    4.3 Kalman filterThe following examples shown here are simulated values. The first example showsa constant level of 5 distorted by measurement noise before the filter. As seen inFigure 24 the Kalman filter follows the measurement from the beginning, theKalman constant K is reduced as the filter adapts and places more and more trust inthe estimated value.

    Figure 24 Constant level

    Given the correct variance for measurement noise Q and the process noise R, theKalman filter is the optimal filter for separating signal from noise. See Figure 25.The problem is to find the noise variance in an unknown system.

    Figure 25 Noisy value corrupted with measurement noise

    When a sudden change occurs, the Kalman filter will slowly adjust to the newvalue. In Figure 26 it is clear that the Kalman filter is too slow to follow the abrupt

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    31/43

    28

    change of value. One standard approach to obtain a more rapid response from theKalman is to temporarily increase the estimation covariance P by orders ofmagnitude.It is also apparent that the residual or the error in estimated value and measuredvalue is non-zero mean noise.

    Figure 26 Abrupt change and slow Kalman filter

    The fact that the residual have a non-zero mean makes the CUSUM change detec-tion effective. In Figure 27 the alarm multiplies the estimate error P by 1000. Thismakes the filter fast after the alarm and gradually slower as the filter adapts. Large

    changes will trigger the alarm faster, and if the change is small or slow it may passundetected.

    Figure 27 Abrupt change, slow Kalman filter and CUSUM change detection

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    32/43

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    33/43

    30

    4.5 Labview programThe end results of the project become a Labview program capable of measuring andmonitoring a laser beam. Several versions of this program were developed and the

    version in Figure 29 used a pre-recorded movie of a laser beam. The reason for thiswas that the frame grabber used for the project was not compatible with Labview.However, a version capable of real-time surveillance utilizing a USB web camerawas also programmed.

    Figure 29 Monitoring program in Labview.

    The program calculates the width of the beam either by the threshold method or thesecond moments calculation from the ISO standard. The center of gravity and thewidth are then plotted in a graph so that the operator can observe the developmentover time. The program is also able to warn the operator if something changes.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    34/43

    31

    5 Conclusions and discussionAn obvious conclusion is that the four-sigma calculation method described inISO11146 is more sensitive to noise than the threshold method. The ability to detect

    changes decreases with the amount of noise, thus for the efficient detection ofchanges, low noise measurements are preferred. The threshold calculation method isless sensitive to noise and offset error and produces a smother width calculation.However, the width is not necessarily the true width of the laser beam.

    The ISO 11146 standard can have systematic errors if the offset is not correct. Whenthe offset level is calculated from non-illuminated pixels the noise in the offset levelis reduced. However, if illuminated pixels are included, an error in the offset willintroduce a systematic error, which also occurs if positive noise is assumed to beilluminated pixels. This offset error will decrease if all non-illuminated pixels areset to zero.

    The size of the measured beam should be well adapted to the image size and smalland big beams will introduce a systematic error if the four-sigma method is usedand the offset is not perfect. An alternative is to cut the image to a smaller size. Thisreduces the image resolution but the sensitivity for imperfect offset levels isreduced. The average offset can be used instead of the momentous offset; the offsetshould not change when the width changes so no error is introduced. Thus a betteroffset value is achieved if the values are filtered frame by frame.

    By setting the pixels marked as non-illuminated to zero the size of the image isautomatically cropped to a smaller size thus reducing the impact of the noise. Also

    this method sets pixels to zero based on how noisy the image is and not based on thebeam size as in the method used by Carlos B. Roundy [8].

    Kalman filtering can estimate the true value from noisy measurement and by usingCUSUM, changes can be efficiently detected. The problem is to set the parametersin the Kalman filter and the CUSUM test correctly. The CUSUM cannot detect slowchanges because the residuals from a Kalman filter will remain at zero mean as thefilter adapts, therefore a max and min limit are required to obtain an alarm for slowchanges. If these limits are set after the Kalman filter, then measurement noise willnot produce false alarms.

    To achieve good result several methods should be used. To monitor the beam forabrupt changes, the threshold method gives low noise measurements which areeasily monitored for changes. However if a more scientific measurement is made,an average of several images will reduce the noise before calculations, and the four-sigma method can be used.

    The goal of the project was to develop a system to monitor a laser beam. However,this was not completely fulfilled, mainly because of the need for a better camera.The camera should preferably be digital with external control over the shutter. Thiswould make it possible to control the camera via software and adjust the camerafrom the same computer program monitoring the beam width. The Labview

    program described in section 4.5 was only tested in the experimental set up in

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    35/43

    32

    section 3.1, so the program probably requires a great deal of additional work toensure that it will work in a real-life application.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    36/43

    33

    Abbreviations

    CCD Charge Coupled Device (sensor array found in high-grade cameras)

    CMOS Complementary Metal Oxide Semiconductor

    CO2 Carbon dioxide (Gas used in a type of laser)

    CUSUM CUmulative SUMmation (Method to detect changes)

    FWHM Full Width Half Max (A way to measure the width of a laser beam)

    LASER Light Amplification by Stimulated Emission of Radiation

    Nd:YAG Neodymium doped Yttrium Aluminium Garnet crystal(Used in a type of laser)

    PIXEL Picture element (A element in a 2D matrix)

    TEM Transversal electromagnetic mode

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    37/43

    34

    BibliographyBooks

    [1] Signalbehandling,F.Gustafsson, L. Ljung & M. MillnertISBN:91-44-01709-X

    [2] Optoelectronics an introduction,J.Wilson, J HawkesISBN:0-13-103961-X

    [3] Digital Image Processing, Second edition,R. Gonzalez & R. WoodsISBN:0-201-18075-8

    [4] Adaptive Filtering and Change Detection,F. GustafssonISBN:0-471-49287-6

    Technical reports[5] CCD vs. CMOS:Facts and Fiction, Dave Litwiller

    January 2001 issue ofPHOTONICS SPECTRA Laurin Publishing Co. Inc.

    [6] How to (Maybe) Measure Laser Beam Quality,A. E. SiegmanTutorial presentation at the Optical Society of America Annual Meeting Long Beach,California, October 1997

    [7] SIS-ISO/TR 11146-3:2004, Provningsmetoder fr laserstrlens bredd,divergensvinkel och strlpropagationsfaktor. (ISO 11146-3)

    [8] Current technology of laser beam profile measurements,Carlos B.Roundy

    Internet

    [9] Hemsida fr laserteknik, LTH 2005-04-07http://kurslab.fysik.lth.se/FElaserteknik/

    [10] National Instrumentshttp://www.ni.com 2005-03-07

    [11] Spiriconhttp://www.spiricon.com 2005-03-15

    [12] Laser Spatial Modes 2005-05-24http://www.mathcad.com/Library/LibraryContent/MathML/laser.htm

    [13]

    http://www.mathcad.com/Library/LibraryContent/MathML/laser.htmhttp://www.spiricon.com/http://www.ni.com/http://www.mathcad.com/Library/LibraryContent/MathML/laser.htmhttp://www.spiricon.com/http://www.ni.com/http://kurslab.fysik.lth.se/FElaserteknik/
  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    38/43

    1

    Appendix

    Appendix A: Camera requirements

    Here follows a brief description of CCD-cameras and some recommendations

    regarding the type of camera usable as a laser beam measurement instrument.

    CCD (Charge Coupled Device) is the technology used to read out information fromthe pixels in the camera. Light is integrated as charges in each pixel during theexposure time, then the charges are transported through the CCD-array to anamplifier, and possibly to an A/D converter if it is a digital camera.

    There are several different techniques for performing the readout in CCD-cameras.One technique is to read out line by line (field transfer) and amplify immediately.Alternatively, the CCD-array is made twice as big, but only half is exposed to light.Then the whole image is transferred to the storage area and read out at a later stage(frame transfer).

    According to Carlos B.Roundy[8] a ghost image is created in the field transfercameras when used with Nd:YAG laser with the wavelength 1064nm. The light

    penetrates deeply into the electronics in the CCD-array and the ghost image appearswhen a pulsed laser is used and charges linger in the complex interline electronics of afield transfer camera. This project had no access to a fast pulsed Nd:YAG laser andthis phenomenon has not been observed. Lately progressive scan cameras have

    become available but the response of these cameras has not been investigated.

    The fact that the four-sigma method is sensitive to noise and fluctuating offset meansthat it is essential to use high quality cameras in order to achieve goodmeasurements. There are cooled CCD-cameras available, these cameras have lowerdark current noise.

    To be able to measure pulsed lasers it is necessary to control the exposure of the cam-era. This is easier in digital cameras that do not need to be synchronized to a monitor.Also it is practical to be able to control the exposure time so that single laser pulsedcan be measured. As the laser pulses are very short it is necessary that the wholeimage is exposed instantaneously, i.e. a global shutter is required. It is important tocontrol this as most modern cameras have a rolling shutter, that only exposes a part of

    the image at any given time..

    Not long ago CMOS (Complementary Metal Oxide Semiconductor) technology was acheap and noisy way to produce web cameras. However, recently CMOS cameraswith high quality have become available. An advantage of these cameras is that the

    pixel values can be read out individually, this makes it possible to read out only theinteresting part of the image, and at a higher frame rate. For the same reason as

    previously, it has not been possible to investigate the effect of 1064nm light onCMOS technology, but probably noise will increase due to light interference deepinside the detector. Digital CMOS cameras are available with an IEEE 1394(Firewire) interface standard called IIDC used by digital machine vision cameras.

    This makes it easer to develop computer programs for the calculations of the acquiredimage.

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    39/43

    2

    Appendix B: Matlab codeAll MATLAB-code is written with Swedish comments.

    Function that generates a noisy film of a TEM00 laser beam that can be made ellipticand rotated.

    function ut=laser_sim2()

    %===KONSTANTER==============================frames=90; %Antalet bildrutorstorlek=100; %Bildens stolek i x och y ledX=50; %Centum fr strlenY=50;DiaX=40; %Diametern fr strlenDiaY=10;vinkel=45/(2*pi); %Vinkeln mot x-axelnintensitet=0.6; %maximum fr strlen utan brusoffset=20/256; %20 bitars offsetnoise=(3/256)^2; %Vitbrus med 3 bitars standardavvikelse.

    %===========================================

    radieX=DiaX/4;radieY=DiaY/4;A1=sqrt((2*pi*radieX*radieY)^-1);

    %Stega igenom alla bildrutor.for a=1:frames

    %Stegar igenom alla bildpunkterfor x1=1:storlek

    for y1=1:storlek

    %Rotera kordinatsystemetx=(x1-X)*sin(vinkel)-(y1-Y)*cos(vinkel);y=(x1-X)*cos(vinkel)+(y1-Y)*sin(vinkel);

    %Berkna intensiteten fr aktuell bildpunktA(x1,y1)=A1*exp(-0.5*((x/radieX)^2+(y/radieY)^2));

    endend

    %Skala om s maxvrdet = intensitetskala=intensitet/max(max(A));B=A*skala;

    %lgg p brusC = imnoise(B,'gaussian',offset,noise);

    %Klippbort 1C=max(C,0);C=min(C,1);

    %Kvantisera till 8bitC=round(C*256)/256;

    %Spara undan aktuell bildrutaut(:,:,a)=C;

    end

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    40/43

    3

    Function that calculates the FWHM along the eigen vectors of the bam

    function ut=threshold(infilm)[a,b,c]=size(infilm);

    %Stegar igenom filmen bild fr bild

    for frame=1:c%Extraherar aktuell bildrutaprofil=infilm(:,:,frame);

    %Gr threshold av aktuell bild vid 50% av amplitudenmaximum=max(max(profil));minimum=min(min(profil));bw=im2bw(profil,((maximum-minimum)*0.5+minimum));

    vektorer = [0 0]';n=1;

    %gr en vektor med koordinaterna fr "upplysta" pixlarfor x=1:a

    for y=1:bif bw(x,y)

    vektorer(:,n)=[x -y];n=n+1;

    endend

    end

    [e1,e2]=size(vektorer);

    %medelpunkten av ljusa bildpunktermedel=sum(vektorer')/e2;

    %Justera koordinaterna s att de r centrerade runt noll

    vektorer=vektorer-(medel'*ones(1,e2));%Berknar egenvektorernaC=(vektorer*vektorer');[V D]=eig(C);

    %Rkna antalet pixlar frn centrum ut till kantan p strlen%Stegar lngs egenvektorerna/principalaxlarna t fyra hllfor temp=1:4

    x=round(medel(1));y=round(-medel(2));langd(temp)=0;while bw(x,y)==1

    %gr framt/bakt ett steg

    langd(temp)=langd(temp)+temp-round(temp/2)*4+1;x=round(medel(1)+V(round(temp/2),2)*langd(temp));y=round(-medel(2)+V(round(temp/2),1)*langd(temp));

    endend

    vinkel(frame)=atan(V(2,1)/V(2,2));dx(frame)=langd(1)+langd(2);dy(frame)=langd(3)+langd(4);

    end

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    41/43

    4

    Function that calculates the beam width using the four-sigma method found in ISO11146. Also the function calculates the offsetlevel.

    function ut=andra_moment(infilm)if nargin == 0

    error 'Inga indata. Du mste skicka in en strlfilm s att

    funktionen har ngot att arbeta med.';

    end[a,b,c]=size(infilm);

    X =zeros(1,c-1);Y=X;dx=X;dy=X;vinkel=X;offset=X ;bildstd=X;pixlar=X;

    offset2=X;total=X;

    for frame=1:c-1%Ls in aktuell bildrutaprofil=infilm(:,:,frame);

    %Skapa ett medelvrdes filter och filtrera bildenh = ones(7,7) / (7*7);profil2 = imfilter(profil,h,'replicate');

    %gr en mask fr de fyra hrnenmask=zeros(a,b);

    da=round(a/20);db=round(b/20);mask(1:da,1:db)=1;mask(a-da:a-1,1:db)=1;mask(1:da,b-db:b-1)=1;mask(a-da:a-1,b-db:b-1)=1;

    %offset level av vrdet i hrnenoffset(frame)=sum(sum(profil.*mask))/(4*(da*db));

    %Plocka ut vrdena i hrnen till en vektortemp=1;for y=1:a

    for x=1:bif mask(y,x)==1

    varde(temp)=profil(y,x);temp=temp+1;

    endend

    end%och berkna standardavvikelsen fr vektornbildstd(frame)=std(varde);

    %Kontrollerar om pixlar r upplysta E(x,y)

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    42/43

    5

    if pixlar(frame)>10offset2(frame)=sum(sum(profil.*mask2))/pixlar(frame);

    elseoffset2(frame)=offset(frame);

    end

    %Kommentera fram nskad metod fr att erhlla offset level%offset3=offset(frame); %Vrdena i hrnen%offset3=offset2(frame); %Oupplysta pixlaroffset3=30/256; %Fast vrde

    profil=profil-offset3;total(frame)=sum(sum(profil));

    %=============================================%Tyngdpunkteny=(1:a)'*ones(1,b);x=(b-(1:b)'*ones(1,a))';

    X(frame) = sum(sum(x.*profil))/total(frame);Y(frame) = sum(sum(y.*profil))/total(frame);

    X2= sum(sum(((x-X(frame)).^2).*profil))/total(frame);Y2= sum(sum(((y-Y(frame)).^2).*profil))/total(frame);

    XY= sum(sum(((x-X(frame)).*(y-Y(frame))).*profil))/total(frame);

    g=sign(X2-Y2);

    dx(frame)=2*sqrt(2)*sqrt((X2+Y2)+g*sqrt((X2-Y2)^2+4*(XY)^2));dy(frame)=2*sqrt(2)*sqrt((X2+Y2)-g*sqrt((X2-Y2)^2+4*(XY)^2));

    if X2 == Y2vinkel(frame)=sign(XY)*pi/4;

    elsevinkel(frame)=0.5*atan(2*XY/(X2-Y2));

    end

    end%Vljer vad som skall retureras frn berkningarna.ut =dy

  • 7/27/2019 The Monitoring of a Laser Beam, By Ingemar Eriksson

    43/43

    Appendix C: Equipment NdYAG-laser, ~25 W CW SIEMENS Silamatic [D1] PC [D2] Matlab 7 (Software for calculations) [D3]

    National Instrumento Labview 7.0 [D4]o IMAQ Vision (Image processing module) [D5]

    Cameraso Fujitsu TCZ-200E (B&W CCD field transfer) [D6]o Philips NC8925 (B&W CCD frame transfer) [D7]o PULNIX OESI 71533 (B&W CCD field transfer) [D8]

    Web Camera. (color CMOS) [D9]

    Adaptec AVC-2000 (Frame grabber unit) [D10]

    Various laser mirrors [D11]


Recommended