UBC Undergraduate Research

High-accuracy position feedback system Kimura, Kyle; Mah, Brian; Chu, Yin-Chi Jan 10, 2011

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

Item Metadata

Download

Media
52966-Kimura_Kyle_et_al_APSC_479_2011.pdf [ 836.17kB ]
Metadata
JSON: 52966-1.0074453.json
JSON-LD: 52966-1.0074453-ld.json
RDF/XML (Pretty): 52966-1.0074453-rdf.xml
RDF/JSON: 52966-1.0074453-rdf.json
Turtle: 52966-1.0074453-turtle.txt
N-Triples: 52966-1.0074453-rdf-ntriples.txt
Original Record: 52966-1.0074453-source.json
Full Text
52966-1.0074453-fulltext.txt
Citation
52966-1.0074453.ris

Full Text

     HIGH-ACCURACY POSITION FEEDBACK SYSTEM  By Kyle Kimura, Brian Mah, Yin-Chi Chu                            Applied Science 479 Engineering Physics The University of British Columbia        HIGH-ACCURACY POSITION FEEDBACK SYSTEM   Kyle Kimura Brian Mah Yin-Chi Chu   Project Sponsors: Andrew Lau, Eliza Boyce - Zaber Technologies    Date of Submission: January 10, 2011     Project Number 1057             Applied Science 479 Engineering Physics The University of British Columbia HIGH-ACCURACY POSITION FEEDBACK SYSTEM January 10, 2011   ii EXECUTIVE SUMMARY  Zaber Technologies Inc. is a Vancouver based company that manufactures linear actuators and linear slides that are used for precision motor control applications.  Some applications include camera and microscope positioning, scanning, semiconductor manufacturing and laser cutting, just to name a few.  Currently, their linear slides have positioning accuracies of around +/- 10 um with a 0.1 um resolution or better with open-loop control.  The purpose of this project was to develop an interferometer based encoder system that could be added to a linear slide to provide position feedback information and increase the resolution. The initial objectives of the project were to develop a working system that could fit in a 3 cm3 volume, have a resolution of 50nm or better and be able to measure distances up to 2 m at speeds up to 2 m/s.  Another longer term objective was to design the device so that it could be manufacturable for under $50.  The plan for the project was to first develop a large scale system that could meet the performance requirements before focusing on miniaturization to meet the size and manufacturability requirements.  A conventional Michelson interferometer was constructed, with one of the mirrors attached to the stage of a Zaber linear slide.  The movement of the stage was measured by measuring the movement of the interference fringe patterns using a 16-element photodiode array and a dsPIC33F digital signal controller.  By the end of the project, movement of the stage could be measured with a resolution of 53 nm.  However, this could only be done at speeds up to 5.56 um/s over a range of 3.2 cm with the final, large scale apparatus.  Several technical limitations and challenges faced throughout the design and development stages of the project prevented many of the original project objectives from being achieved.  The overall project goal was gradually reduced from designing the manufacturable, miniaturized system to completing the position measurement implementation on the large scale system.  The main technical limitation that prevented the system from being miniaturized was the size of available lasers with the required coherence length.  Small infrared DFB lasers are available that could potentially be used to miniaturize the system in future development.  However, these were not used for the project and instead a large, HeNe laser was used because one was readily available and it was easier to work with a visible light source.  One of the main challenges that was faced was that the signal from the interference pattern was easily disrupted from vibrations and other inherent noise.  A smoothing algorithm had to be implemented to help reduce noise.  This algorithm, along with sequential data sampling of each photodiode element (multi-channel sampling was not implemented due to time constraints) greatly reduced the maximum speed that measurements could be made.  Interferometer alignment also proved to be a major challenge for the project and would require a lot of consideration for a manufacturable design.  The interference fringe patterns could be lost or disoriented very easily from misalignment.  The interferometer had to be adjusted several times throughout the project.  The alignment also changes as the linear slide moves back and forth which became the limiting factor for the operating range of the system.  This project concluded with several opportunities for further development towards a final design. One improvement would be changing to faster data sampling hardware such as an ADC with simultaneous sampling and an FPGA.  Different signal processing techniques could also be explored to help reduce noise and improve performance.  Other provisions, such as vibration isolation or compensation techniques would also need to be considered in the future.  HIGH-ACCURACY POSITION FEEDBACK SYSTEM January 10, 2011   iii TABLE OF CONTENTS  EXECUTIVE SUMMARY ..................................................................................................ii LIST OF ILLUSTRATIONS .............................................................................................. v LIST OF ABBREVIATIONS .............................................................................................vi 1.0 INTRODUCTION ................................................................................................... 1 1.1 About Zaber Technologies Inc. .......................................................................... 1 1.2 Brief Description of Project ................................................................................. 1 1.3 Motivation ........................................................................................................... 2 1.4 Project Objectives .............................................................................................. 2 1.5 Scope ................................................................................................................. 2 1.6 Organization ....................................................................................................... 3 2.0 THEORY/TECHNICAL BACKGROUND ................................................................ 4 2.1 Interferometry Principle ...................................................................................... 4 2.2 Coherence Length .............................................................................................. 5 3.0 EXPERIMENTAL EQUIPMENT ............................................................................ 6 3.1 Interferometer ..................................................................................................... 6 3.2 Webcam ............................................................................................................. 7 3.3 5-element Phototransistor Array ......................................................................... 7 3.4 16-element Photodiode Array............................................................................. 7 4.0 METHODS AND TESTING PROTOCOL .............................................................. 9 4.1 Sampling and Measurement Method ................................................................. 9 4.2 Testing Protocol ............................................................................................... 10 4.2.1 Requirements testing ................................................................................. 10 4.2.2 Direct Comparison tests ............................................................................ 11 4.3 Alternative Methods ......................................................................................... 11 4.3.1 Webcam CCD with MATLAB Analysis ....................................................... 11 4.3.2 Implementation on an FPGA board ........................................................... 12 5.0 RESULTS ............................................................................................................ 13 5.1 Objectives ........................................................................................................ 13 5.2 Direct Comparison ........................................................................................... 14 6.0 DISCUSSION OF RESULTS ............................................................................... 15 6.1 Maximum speed ............................................................................................... 15 6.2 Alignment ......................................................................................................... 15 6.3 Resolution ........................................................................................................ 16 6.4 Direct comparison measurements .................................................................... 16 6.5 Alternate Tests ................................................................................................. 16 7.0 CONCLUSIONS .................................................................................................. 18 8.0 PROJECT DELIVERABLES ................................................................................ 19 8.1 List of Deliverables ........................................................................................... 19 8.2 Financial Summary .......................................................................................... 19 8.3 Ongoing Commitments by Team Members ...................................................... 20 9.0 RECOMMENDATIONS ....................................................................................... 21 9.1 Distributed Feedback Laser ............................................................................. 21 HIGH-ACCURACY POSITION FEEDBACK SYSTEM January 10, 2011   iv 9.2 Digital Signal Processing ................................................................................. 21 9.3 Signal processing speed .................................................................................. 22 9.4 Range of motion and speed requirements ....................................................... 22 9.5 Noise Reduction ............................................................................................... 22 REFERENCES .............................................................................................................. 24 APPENDIX A – SOFTWARE CODE ............................................................................. 25  HIGH-ACCURACY POSITION FEEDBACK SYSTEM January 10, 2011   v LIST OF ILLUSTRATIONS  FIGURES Figure 1: T-LSR Series Linear Stages manufactured by Zaber (http://www.zaber.com/products/product_group.php?group=T- LSR&name=Linear_Slide). ................................................................................................. 1 Figure 2: Diagram of a Michelson interferometer .................................................................... 4 Figure 3: The interferometer apparatus being used with the 16-element photodiode array ....................................................................................................................................... 6 Figure 4: The phototransistor array (left) and interfacing circuitry (right) ............................ 7 Figure 5: The 16-element photodiode array mounted and connected to the dsPIC33F .. 8 Figure 6: Final apparatus configuration .................................................................................... 8 Figure 7: Showing three iterations where the peak is highlighted in yellow.  a) Count is decremented; b) count remains the same ........................................................................ 9 Figure 8: Showing the tilt in the fringe pattern as the stage moves back and forth. Left: Fringes are vertical as the stage is positioned in the middle; Right: Fringes nearing horizontal as the stage is near the end of its range of motion. ................................... 11 Figure 9: Plot of measured distance travelled versus actual distance travelled (based on 500 microsteps) .................................................................................................................. 13   TABLES Table 1: Initial objects and achieved values .......................................................................... 14 Table 2: Direct comparison measurement test results ......................................................... 14 Table 3: List of project expenses ............................................................................................. 19   HIGH-ACCURACY POSITION FEEDBACK SYSTEM January 10, 2011   vi LIST OF ABBREVIATIONS   ADC Analog to digital converter CCD Charge-coupled device DAC Digital to analog converter DFB Distributed feedback FPGA Field-programmable gate array HeNe Helium-Neon LCD Liquid crystal display LED Light-emitting diode PCB Printed circuit board UBC University of British Columbia  HIGH-ACCURACY POSITION  Page 1 FEEDBACK SYSTEM January 10, 2011   1.0 INTRODUCTION 1.1 About Zaber Technologies Inc.  Zaber Technologies Inc. is a Vancouver-based company, founded in 1997, that designs and manufactures precision motor control products.  These products are used in a very wide variety of applications where precise positioning is required.  In particular, Zaber manufactures a series of linear actuators that provide linear positioning over travel ranges up to 450mm, with accuracies on the order of +/- 10 µm and resolutions on the order of 0.1 µm.   Figure 1: T-LSR Series Linear Stages manufactured by Zaber (http://www.zaber.com/products/product_group.php?group=T-LSR&name=Linear_Slide).  One of Zaber’s linear stage models, with two different travel lengths is shown Figure 1 above.  The mounting stage can slide back and forth in one direction and is attached to a power screw driven by a stepper motor.  The micro-stepping resolution of the stepper motor corresponds to the achievable resolution of linear position.  Some examples of applications where these products are used include positioning of mirrors and lenses for optics apparatuses, camera or charge-coupled device (CCD)* positioning, materials testing, surface scanning, microscope positioning, microfluidics, semiconductor manufacturing and laser cutting.  In addition to linear actuators, Zaber also manufactures rotary and tilt stages, as well as multi-axis (XY and XYZ) systems. 1.2 Brief Description of Project  Zaber is currently looking to increase the accuracy of their linear stage products by adding encoder feedback control (currently, all models use open-loop control).  They would like to have a high accuracy position feedback system that is capable of measuring distances up to 2m with a resolution of 50nm or better and the ability to track a moving stage at speeds up to 2 m/s.  The entire system also needs to be relatively small (fit within a volume of roughly a cubic inch), such that it can be fitted inside or next to the existing stepper motor and electronics module at the end of the sliding mechanism.  *  This and all subsequent abbreviations are listed in the List of Abbreviations, p. vi HIGH-ACCURACY POSITION  Page 2 FEEDBACK SYSTEM January 10, 2011   The proposed idea from Zaber is to use Michelson interferometry as the measuring principle for the encoder feedback system.  A Michelson interferometer is an apparatus that splits a beam of monochromatic (single wavelength) light into two separate paths and then recombines the beam, yielding an interference pattern, which changes based on the path length difference.  By attaching part of the apparatus to a moving stage, one of the path lengths will vary and the change in the interference pattern will correspond to the movement of the stage.  Thus, the movement of the stage can be measured by measuring the movement of the interference pattern.  Additional details about the Michelson interferometer are included in the Theory section. 1.3 Motivation  With open loop control, Zaber is already able to achieve positioning accuracy and resolution on the order of micrometers.  One way to further increase the performance of Zaber’s linear actuator products is to add position encoding feedback.  However, there are only a few suitable technologies that can improve resolution down to the nanometer range.  A number of linear optical encoder systems already exist that provide this level of performance, showing that it should be possible to build a similar system for Zaber’s products.  While it will certainly be a challenge to achieve the required performance specifications, the real challenge of the project is to miniaturize the interferometer setup and signal processing electronics such that it can be integrated into a linear actuator. The emphasis of this project was not so much about exploring a new technology, but rather to modify an existing technology for an existing product, focusing on integration and manufacturability.  1.4 Project Objectives The major objective of this project was to develop a position feedback system based on a Michelson interferometer.  The end goal would be to implement this on the linear actuators built by Zaber, in order to improve their resolution and accuracy. This project had several very specific requirements that must be eventually met with the final product, regardless of whether they were achieved over the course of this project. The prototype was to achieve a resolution of better than 50 nm, be able to measure distances up to 2 m, and be able to track a moving stage at speeds up to 2 m/s. The current open-loop driving system on the linear actuators achieves resolution of 0.1 µm or better, with +/- 10 µm accuracy over 50 mm.  Finally, the entire setup should be scalable, such that it would be able to fit inside a 3 cm3 volume. 1.5 Scope  This report will focus on the implementation and use of the current interferometer setup in order to make measurements.  It will go into detail about how the microprocessor makes the distance measurement, and discuss the results that were achieved with the prototype. HIGH-ACCURACY POSITION  Page 3 FEEDBACK SYSTEM January 10, 2011    This report will not go into great detail about the software code, other than explaining the overall functions.  The code will be provided in the appendix for additional reference. Also, this report is intended to discuss the performance of the system and how it could be improved.  It will not act as a user manual; such a document will be provided to the project sponsors separately. 1.6 Organization  This report will first discuss the theoretical aspects of the project, and how they will be applied.  It will then give a detailed description of the equipment used and constructed over the course of the project.  Following this, a relatively in-depth overview of how the measuring system works is provided, along with a description of the tests performed to characterize the performance of the system.  Finally, the report will present and discuss the results of said tests, and provide some recommendations for future work.  HIGH-ACCURACY POSITION  Page 4 FEEDBACK SYSTEM January 10, 2011   2.0 THEORY/TECHNICAL BACKGROUND 2.1 Interferometry Principle  The proposed design for the high-accuracy position sensor is to build an optical encoder based on a Michelson interferometer. By analyzing the output interference pattern, it is possible to determine the relative change in the position of the two mirrors. A diagram of a typical Michelson interferometer setup is shown below.   Figure 2: Diagram of a Michelson interferometer  The interference pattern in the recombined beam will be constructive if the difference in path length is an integer multiple of the wavelength of light used, and destructive if the difference is an integer multiple and a half wavelength.  It has been shown that the intensity distribution resembles the shape of a sinusoidal wave, and the spacing between two fringes is equal to half the wavelength of the light source [1].  The beam passes through a diffusion lens to expand the interference pattern so that the photodiode array can capture a segment of it for analysis. This pattern shifts relative to changes in the location of the moving mirror.  As it is moved back and forth, the peaks in the interference pattern also move back and forth, much like a plane wave.  It is this motion that allows one to make displacement measurements.  By placing one mirror on the moving stage (the moving mirror), the photodiode array can be used to measure the motion of the interference pattern, and thus, the motion of the stage.  Using a higher number of elements gives more resolution on the sine wave, and therefore allows one to get higher resolution on the motion.  HIGH-ACCURACY POSITION  Page 5 FEEDBACK SYSTEM January 10, 2011   2.2 Coherence Length  In the optical regime, coherence length is an important property to be considered when designing an interferometry system. Coherence length is the propagation distance from a coherent source to a point where an electromagnetic wave maintains a specified degree of coherence. The fringe visibility depends greatly on this concept, as the path difference between the two beams must not exceed this length [1]. The interference pattern will have high intensity within the coherence length of the source, but not beyond it.  In order to meet the size requirement, different types of laser diodes were chosen and compared.  However, the coherence length of small, cheaper laser diodes (e.g. from a laser pointer) generally range from ~300 nm to ~20 µm, which is not long enough to cover the desired range of measurement.  Upon consultation with UBC Professor Dr. David Jones, distributed feedback (DFB) laser diodes can have coherence lengths up to 30 m, and were considered for implementation in the prototype.  However, the major drawback of immediately working with a DFB laser is that most commercially available DFB lasers have a wavelength on the order of 1.5 µm, which is invisible to the human eye. Therefore, for this project, a Helium-Neon (HeNe) laser, which has a typical coherence length on the order of 30cm [2], was selected in order to make the initial setup and alignment much easier while the signal processing algorithm was developed.  It is expected that a DFB laser will eventually replace the HeNe laser in the final product design.  HIGH-ACCURACY POSITION  Page 6 FEEDBACK SYSTEM January 10, 2011   3.0 EXPERIMENTAL EQUIPMENT  The experimental apparatus for the project consisted of an interferometer to generate the interference fringes, and processing hardware to acquire and analyze the moving fringes to measure the displacement of the moving stage.  Throughout the term, several methods were used to acquire the fringes including a webcam, phototransistors and eventually a 16-element photodiode array.  The following sections contain photos and brief descriptions of the various equipment used throughout the development of the project.  Note that the 16-element photodiode array was the configuration used for the final setup at the conclusion of the project.  3.1 Interferometer  The interferometer apparatus constructed for the project consisted of a Helium-Neon laser, two first-surface mirrors with knob adjustments, a cube beamsplitter and a cylindrical diffusion lens.  One of the mirrors was mounted onto a Zaber T-LSM100A linear stage.  The stage was controlled on a laptop using a console program provided by Zaber.  The cube beamsplitter was mounted on top of two micrometer stages (oriented perpendicular to each other) and a Zaber rotary stage.  This was done to help make alignment easier and also to bring the cube up to the height of the laser.  The interferometer can be seen in the photo below.   Figure 3: The interferometer apparatus being used with the 16-element photodiode array  HIGH-ACCURACY POSITION  Page 7 FEEDBACK SYSTEM January 10, 2011   3.2 Webcam  A webcam CCD sensor was first used to acquire and analyze the interference fringes. An optical bandpass filter was placed in front of the webcam to help block ambient light from entering.  A program written in MATLAB and the built-in image acquisition toolbox was used to record the image from the CCD.  No fringe counting or measurement algorithms were implemented during this stage of the project.  3.3 5-element Phototransistor Array  The next set of hardware used consisted of 5 phototransistors placed evenly spaced apart using a custom machined mount.  This was made as a temporary solution while a proper and more appropriate photodiode array was being sourced and shipped so that development on the Altera DE1 field-programmable gate array (FPGA) board could begin sooner.  In order to interface the phototransistors to the FPGA board, a simple breadboard circuit was made that consisted of op-amps and comparators.  The comparator voltage was set appropriately with the gain of the op-amps to convert the voltage from the phototransistors into a digital input for the FPGA board.  Eventually, the comparators were replaced with Schmitt trigger inverters and the gain was adjusted to match the threshold voltage.  This was done because the hysteresis characteristic of the Schmitt trigger helped to reduce noise.  Photos of the phototransistor array and circuitry are below.   Figure 4: The phototransistor array (left) and interfacing circuitry (right) 3.4 16-element Photodiode Array  The 16-element photodiode array (pictured below) was the final sensor used to acquire the interference patterns.  The photodiode elements were directly connected to the dsPIC33F digital signal controller.  At the conclusion of the project, only 7 of the 16 elements were used due to a lack of available analog inputs on the dsPIC33F board. HIGH-ACCURACY POSITION  Page 8 FEEDBACK SYSTEM January 10, 2011    Figure 5: The 16-element photodiode array mounted and connected to the dsPIC33F As mentioned above, the 16-element photodiode array was used in the final configuration of the experimental apparatus.  The entire apparatus can be seen in the photo below.   Figure 6: Final apparatus configuration HIGH-ACCURACY POSITION  Page 9 FEEDBACK SYSTEM January 10, 2011   4.0 METHODS AND TESTING PROTOCOL  The photodiode array translates the intensity of light into a voltage signal which is then passed through an analog to digital converter (ADC) for measurement.  The objective is to align the Michelson interferometer and obtain a clear interference pattern with sinusoidal varying intensity.  Ideally the acquired waveform should contain a full period of the full sinusoidal waveform, with the peak significantly higher than the rest of the curve.  Therefore, as the pattern moves across the array, the peak moves the same distance between every single element.  This allows for an easy method of achieving higher resolution than a binary sensor. 4.1 Sampling and Measurement Method  While a few methods were tested, or used as a stopgap along the way, the eventual setup with the 16-element photodiode array was always considered as the end goal. The dsPIC33F board was used to sample the raw output data from the photodiode elements.  The data was then processed as follows.  Seven elements were sampled sequentially through seven analog inputs on the board, and stored into a buffer with a capacity of 32 data samples for each input.  This was done to implement a rolling average filter, since the data was quite noisy.  The element with the maximum (averaged) signal was then found, and a corresponding light-emitting diode (LED) on the board was lit.  The idea was to have the lit LED “move” across the array in the same manner that the fringes move across the photodiode array, in order to provide relevant visual feedback.  Once the peak finding was complete, a counting algorithm was developed.  For this, the middle element was chosen as the “tracking” element.  Every time the peak hit the middle element, the counter was either incremented, or decremented, depending on which direction it was moving.  The convention used was left = increment, right = decrement.  This was determined by tracking the three most recent peak locations and changing the counter when the three locations show a clear progression in one direction or the other when the tracking element is hit.  An example of this is illustrated below.    a) b) Figure 7: Showing three iterations where the peak is highlighted in yellow.  a) Count is decremented; b) count remains the same In Figure 7a, the peak is clearly moving to the right, and the tracking element was hit. Therefore, the count is decremented.  In Figure 7b, the tracking element was hit, but the peak did not fully pass over it, so the count remains the same. HIGH-ACCURACY POSITION  Page 10 FEEDBACK SYSTEM January 10, 2011    Finally, in order to achieve the required resolution, some additional functionality was added to the board.  One of the buttons was programmed to trigger the start and stop of a measurement, while another was programmed to display the number of counts on the liquid crystal display (LCD).  By logging the LED where the measurement began and ended, and taking the number of counts, it was possible to determine how far the stage moved in the process. 4.2 Testing Protocol  Tests were performed to characterize the capabilities of the system, in order to determine whether it meets the requirements.  These included a maximum speed test and range of distance test.  Direct comparison tests were also performed, which compared the measured displacement to the actual displacement†.   For all tests, the T- LSM100A linear stage model was used, which has a microstep size of 0.0238125 µm [2]. 4.2.1 Requirements testing  The procedure for the maximum speed test was as follows.  A target speed of 1 on the Zaber console was chosen‡.  The counter on the controller was started, and allowed to stabilize, since pressing the button creates some vibrations on the table.  The linear stage was then moved a specified number of microsteps (usually a multiple of 500) using the Zaber console.  Upon completion of the motion, the stop button was pressed, and the number of counts was displayed and logged.  For all tests, this was compared to the number of microsteps moved by converting both to distance in µm.  This test was then repeated at increasing speeds, with a few iterations at each speed, until the measured and expected distances began to differ by a significant amount.  For the range of distance test, the T-LSM100A stage was initially set to be roughly in the middle of its range, and the mirrors in the interferometer were oriented to yield vertical fringes at this location.  Due to slight misalignments in the whole interferometer setup, as the stage moves further to one extreme, the fringes begin to tilt in one direction.  This is shown in the figure below.   †  Actual displacement refers to the number of microsteps set in the Zaber console, but this is not 100% accurate, as the motion of the stages does have some error as well. ‡  Speeds on the Zaber console are converted to µm with the following formula:  HIGH-ACCURACY POSITION  Page 11 FEEDBACK SYSTEM January 10, 2011    Figure 8: Showing the tilt in the fringe pattern as the stage moves back and forth. Left: Fringes are vertical as the stage is positioned in the middle; Right: Fringes nearing horizontal as the stage is near the end of its range of motion. The edge of the range of motion was considered to be where the microcontroller had troubles tracking the motion of the fringes.  This coincided with the motion of the fringes becoming more vertical than horizontal.  However, this is not a particularly well-defined location since the progression is very gradual.  It gives a fairly rough estimate, in order to compare with the initial objective. 4.2.2 Direct Comparison tests  The procedure for these tests was similar to the maximum speed tests.  A speed of 15 was chosen, since the dsPIC33F could reliably track the stage moving at that speed. The counter on the dsPIC33F was started, and the setup was allowed to stabilize.  The starting LED was then logged.  After this, the stage was programmed to move a distance of either 0.5 mm or 2 mm.  Upon completion of the motion, the number of counts was displayed and logged, as well as the ending LED.  By knowing the number of counts, the distance is known to within 316 nm.  The starting and ending LED give the fractional distance between the final two counts, down to 53 nm resolution. 4.3 Alternative Methods  After the construction of the interferometer was completed, a number of methods were used to attempt to measure the displacement of a linear stage.  This section describes two alternate methods; one using a webcam CCD with MATLAB analysis that was initially explored but eventually abandoned due to performance limitations, and one using an FPGA board for analysis that was considered but was not fully pursued due to time and other constraints. 4.3.1 Webcam CCD with MATLAB Analysis  Part of the initial progression plan for the project included using a computer to analyze the interference fringes before moving on to a board implementation.  The most appropriate type of sensor to start with using a computer was a CCD sensor, because a HIGH-ACCURACY POSITION  Page 12 FEEDBACK SYSTEM January 10, 2011   webcam could quickly be used with existing software and cabling.  However, the frame rate used with the webcam software was far too inadequate for the initial performance goals of the project.  Further, even after using built-in image acquisition software in MATLAB, the CCD would saturate when the laser was shone directly on the sensor, making it very hard to distinguish the lower varying intensity levels from the moving fringes.  This method was then abandoned and the next method was soon sought after. 4.3.2 Implementation on an FPGA board  Another method that was considered but not implemented was the possibility of using the Altera DE1 FPGA board (or any other FPGA) with the 16-element photodiode array instead of the dsPIC33F.  An FPGA would have likely been able to provide much faster performance than what was eventually obtained with the dsPIC33F.  A small amount of development work was done on the Altera DE1 board before the 16-element photodiode array arrived.  While waiting, a makeshift array was quickly made using 5 discrete phototransistors.  One constraint of an FPGA is that it can only take digital inputs, so signal conditioning circuitry was required to interface the array to the board.  However, a large amount of noise was observed in the digital signal, due to constant fluctuations from varying light intensities on the array.  Of course, this problem still existed on the dsPIC33F except that analog signals could be directly fed into the board and signal averaging and smoothing techniques could be implemented in software much easier. This was one reason why the dsPIC33F was eventually chosen.  Another main reason why the dsPIC33F was used was because the Altera DE1 board would not be available for the Project Sponsors' use after the conclusion of the project. Also at the time this decision was made, the scope of the project was changing from a final product to more of a proof-of-concept design due to the limited amount of time remaining in the term.  It was also clear by this time that the initial performance goals for the project would not be met.  The best option was to use the dsPIC33F board and develop a working "demo" that could be kept by the Project Sponsors in the end and possibly develop further.  HIGH-ACCURACY POSITION  Page 13 FEEDBACK SYSTEM January 10, 2011   5.0 RESULTS  The final prototype did not achieve all of the goals set at the beginning of the project, although based on what was learned over the course of the semester, this was to be expected.  In the end, of the many available analog inputs, only seven were found to be untouched by other functions built into the board, and in the end only six of the seven elements were working properly. 5.1 Objectives  The maximum attainable speed before losing any information was found to be a speed of 25 on the Zaber console, which translates to 5.56 µm/s.  At speeds of 30 and 35, the microcontroller began to miss counts, and while it could sometimes measure the correct distance, it could not do so in a repeatable manner.  These results are shown below in the figure.  The initial goal was 2 m/s, although no stage currently manufactured by Zaber can attain this speed.   Figure 9: Plot of measured distance travelled versus actual distance travelled (based on 500 microsteps)  The resolution was measured based on the distance between two peaks in the interference pattern.  The pattern was tuned such that one full wavelength covered the six elements in use.  Therefore, given that the distance between two peaks was 316.4 nm and given that there were six discrete locations at which it could lie, the prototype was able to achieve a resolution of 53 nm.  The range of distance that could be reached was found to be 3.2 cm, which includes motion in both directions.  The original goal was 2 m, although to date, no stage manufactured by Zaber has that large of a range of motion.  Also, as expected, the setup is much larger than 3 cm3. 0 2 4 6 8 10 12 14 0 2 4 6 8 10 D is ta n ce  ( u m ) Speed (um/s) 500 microsteps; logged distance versus speed Measured distance Actual Distance HIGH-ACCURACY POSITION  Page 14 FEEDBACK SYSTEM January 10, 2011   Tabulated below are the initial objectives and the values for each that were achieved in this project.  Table 1: Initial objects and achieved values Property Initial Goal Achieved value Speed 2 m/s 5.56 µm/s Distance 2 m 3.2 cm Resolution 50 nm 53 nm  5.2 Direct Comparison  These tests did not follow the procedure outlined in the previous section exactly.  This is due largely due to the amount of noise.  The system is extremely sensitive to any type of vibration, which can result from people walking by, or from physically pressing the start and stop button on the microcontroller, which rests on the same table as the interferometer.  This affects measurements enough that it is likely that they would not be valid down to the desired resolution.  As such, the results in this section are only measured down to 316 nm resolution.  Due to time constraints, few tests were taken.  Two tests were performed for 0.5 mm, while only one test for 2 mm was performed.  The results are shown in the table below.  Table 2: Direct comparison measurement test results Nominal Distance Measured Distance 20997 microsteps 499.99 μm 1580 counts 499.91 μm 20997 microsteps 499.99 μm 1587 counts 502.13 μm 83990 microsteps 2000.01 μm 6313 counts 1997.43 μm   HIGH-ACCURACY POSITION  Page 15 FEEDBACK SYSTEM January 10, 2011   6.0 DISCUSSION OF RESULTS  Although the results that have been achieved so far have proven the concept is functional, they are not sufficient to prove the reliability of the system.  Since Zaber may wish to perform tests on their stages and characterize the motion with this apparatus, it needs to be reliable enough that its results can be trusted to have less error than Zaber's linear stages.  A significant problem that was found in this project is the sensitivity to external noise. Pressing a button on the dsPIC33F board, talking, or walking nearby can easily affect measurements.  In systems where this level of precision would be required, remote control of the microcontroller, and vibration isolation would be critical.  Furthermore, the workspace for this project was a regular office room, and disturbances from ambient light may have also had some effect on the response. 6.1 Maximum speed  Being able to track a moving stage is a good start; however, 5.56 μm/s is several orders of magnitude below the desired speed.  Part of the reason for this was being unable to implement simultaneous sampling for the ADC, and so sequential sampling was used. However, the biggest problem was simply that the ADC was too slow.  Each sample and conversion required at least 11 μs (~1 μs for sampling, ~10 μs for conversion). This, combined with the rolling average filter, made the effective sampling frequency quite low, which resulted in a low maximum speed.  Since this was discovered relatively late in the semester, the sponsors simply asked for a proof of concept at lower speeds.  Implementing simultaneous sampling would increase the speed by a reasonable amount.  However, most of the issue could be solved with a faster ADC.  With a faster ADC, noise would have less of an effect on the tendency to double-count or miss counts altogether.  However, 2 m/s would require an ADC that can sample and convert up to sixteen simultaneous signals at roughly 30 MHz.  It would be difficult and costly to find (or design) such an ADC, and so it would be practical to lower the desired maximum speed, especially since no Zaber stage is currently capable of exceeding 550 mm/s. 6.2 Alignment  There were many difficulties in aligning the setup properly, which was the primary factor that led to the very short range of motion.  If the various components were not properly aligned, and the mirrors were oriented to simply fit the alignment, so to speak, moving one mirror would result in one beam of light shifting relative to the other, which slowly changes the orientation of the interference pattern (as seen in section 4.2.1).  The problem is that tiny angular deviations in the beam paths have a very large effect on the interference pattern, and these are very difficult to detect.  The amount of accuracy that would be required to ensure a 2 m range of motion may not be feasible to HIGH-ACCURACY POSITION  Page 16 FEEDBACK SYSTEM January 10, 2011   achieve.  For example, a mirror deviation of one arcminute (1/60 of a degree) would mean that after 2 m, the beams would be separated by 0.6 mm, which is enough to significantly affect the interference pattern.  However, it is likely that it would be possible to achieve far better than the 3 cm achieved in this project. 6.3 Resolution  The resolution calculation is made under the assumption that the 316.4 nm wavelength of the interference pattern is perfectly spread across the six elements in use.  If a smaller portion of the waveform is spread across it, then there would be some delay around the edges, as the peak in the light intensity would spend more time at the two edges as the pattern moves through.  Although it is possible to make it fairly uniform by eye, it is very likely that there is some error from element to element.  On average, however, the resolution would be 53 nm.  Since only six elements were used, it would be possible to increase the resolution by simply adding more elements.  The issue in this project was that the seventh element appeared to have a weaker signal than the rest, and other elements were found that did not have identical voltages for on/off, despite having roughly the same voltage difference.  It would be best to normalize these outputs so that slight differences in the voltage levels do not have an effect on the performance of the overall system. 6.4 Direct comparison measurements  As mentioned, the tests that were performed did not follow the proper procedure due to time constraints.  Furthermore, these tests were very susceptible to any external noise, because of their length.  A speed of 15 translates to 3.35 µm/s, which means that it would require nearly ten minutes to move 2 mm, and two and a half minutes to move 0.5 mm.  It is difficult to come to any meaningful conclusions about the motion of the Zaber stages based on these results, because it is not clear how much error comes from the stage, and how much error comes from the measurement system itself.  More tests and an increased reliability of the system would give these measurements more merit, and therefore allow the engineers at Zaber to properly characterize the motion of their stages. 6.5 Alternate Tests  Due to the level of external noise that was present in the working area of the project, it was difficult to take measurements down to the desired resolution.  In order to truly make direct comparison measurements, this noise must be eliminated.  This would include vibration isolation, remote control of the microcontroller, and working in a darkroom.  Given that they did not fully follow the outlined protocol, more direct measurement testing should be performed, ideally with additional care taken to eliminate as much noise as possible.  This would better characterize the capabilities of the system. HIGH-ACCURACY POSITION  Page 17 FEEDBACK SYSTEM January 10, 2011    It would be advantageous to see whether electrical noise in the power supply had an effect.  Powering the HeNe laser with a very stable power supply, and performing a direct comparison to the regular power supply would help characterize any electrical noise in the system, if any.  Once a faster ADC is procured, one test that must be performed is a measurement test with vibrations present.  The hypothesis is that with a fast enough sampling system, external noise would be recognized using the direction tracking algorithm, and would have no effect on the end measurement.  For example, if an external vibration moved the peak past the tracking element in one direction, and then back, the algorithm should recognize this as first an increment, then a decrement (or vice versa).  The issue with the current system is that these are high frequency vibrations which are too fast to track.  As soon as the prototype becomes reliable enough to make a proper measurement, it can be used to characterize the motion of the various stages manufactured by Zaber. HIGH-ACCURACY POSITION  Page 18 FEEDBACK SYSTEM January 10, 2011   7.0 CONCLUSIONS  Zaber is currently capable of achieving quite high accuracy and resolution using only open loop control of their stages.  However, they hope to improve upon this by adding position feedback control.  The purpose of this project was to develop a system that could perform such a task at a resolution of 50 nm, which could potentially be miniaturized to act as an encoder.  The measurement principle was based on tracking the motion of light fringes in the output of a Michelson interferometer.  After four months of development, the prototype was not able to meet all of the initial requirements; however, it acted as a proof of concept.  By diffusing the output interference pattern to spread it across a photodiode array, it was possible to track motion by sampling six elements using a dsPIC33F microcontroller.  This yielded a resolution of 53 nm, which is very close to the initial requirement of 50 nm.  This could very easily be improved upon.  The prototype is, as expected, much larger than the 3 cm3 volume that is desired in the long run.  However, methods for making the system much smaller have been researched, and while 3 cm3 may be a bit ambitious, miniaturization may still a possibility in the future.  But for now, the project sponsors will be using this prototype primarily for in-house characterization and testing of their own stages.  A major issue that came up late in the term was that the dsPIC33F ADC is far too slow to track motion at 2 m/s.  This was compounded by the need for a rolling average filter, and the inability to simultaneously sample and convert.  Therefore, the maximum achievable speed was several orders of magnitude lower at 5.56 μm/s.  Another major difficulty that was recurring throughout the term was alignment.  This resulted in a much smaller range of motion than hoped, since misalignments in the interferometer would result in one beam of light shifting relative to the other when the stage holding the mirror is moved.  This changes the orientation of the interference pattern, which ultimately ends up limiting the range of motion.  Therefore, a range of motion of 3.3 cm was achieved, while the initial goal was 2 m.  Tests were also performed to directly compare the measured distance to the Zaber stage moving a known distance.  These, however, did not follow the specific procedures for higher resolution measurements, and therefore, only had a resolution of 316.4 nm. Furthermore, an insufficient number of tests were performed to come to any reasonable conclusion with regards to the performance of the stage.  Due to the sensitivity of the interference pattern, external noise from people walking, talking or potentially from the laser’s power supply all had a significant effect on measurements.  Ambient light in the room may have also had an effect.  Many of these issues are addressed in the recommendations, where some suggestions for future work are provided. HIGH-ACCURACY POSITION  Page 19 FEEDBACK SYSTEM January 10, 2011   8.0 PROJECT DELIVERABLES  This section contains the final project deliverables, financial details and ongoing commitments of the team members after the completion of the course.  Much of the content in this section will also be contained in the Project Completion Report document, the formal document that will be reviewed and signed by all stakeholders at the time of the project handoff. 8.1 List of Deliverables  The following list contains the components that were constructed or developed throughout the term and will be handed off to the project sponsors at Zaber.  Comments describing the state of each item are included.  1) Interferometer apparatus.  The complete interferometer apparatus including the HeNe laser, mirrors with knob adjustments, cube beamsplitter and diffusion lens.  All mounting pieces (some provided by Zaber and some machined at UBC) will also remain with the apparatus at Zaber.  2) Photodiode arrays.  This includes the printed circuit board (PCB) that was made to mount the photodiode array to a standard optical mounting post with a C-clamp.  The C- clamp however remains property of UBC and will eventually need to be returned.  3) All source code developed for the dsPIC33F board.  All of the code that was developed was for the implementation of the positioning measurement functionality. The structure of the entire program was based on an existing sample program, and a number of files were added and modified. 8.2 Financial Summary  This section contains a table summarizing all the expenses that were incurred throughout the project.  Table 3: List of project expenses # Description Qty. Vendor Cost Purchased by To be funded by 1 Cube beamsplitter 1 Edmund Optics $115 Project lab Zaber 2 Retro reflective mirrors 2 Edmund Optics $350 Project lab Zaber 3 Diffusion lens 1 Edmund Optics $39 Project lab Zaber 4 Optical band pass filter 1 Edmund Optics $50 Project lab Zaber 5 16-element photodiode 3 OSI Optoelectronics $135 Project lab Zaber 6 Mounted mirrors w/knob 2 Edmund Optics $138 Project lab Zaber Total Cost: $827 + shipping costs + taxes  HIGH-ACCURACY POSITION  Page 20 FEEDBACK SYSTEM January 10, 2011   A number of hardware components that were used in the experimental apparatus did not need to be purchased because they were already available.  Most notably, the HeNe laser was donated to Zaber from the UBC Department of Physics for this project. Also, the Altera DE1 FPGA board belongs to the project team and the dsPIC33F board belongs to the Project Sponsors. 8.3 Ongoing Commitments by Team Members  The project team has already agreed to return to Zaber a number of times during the current semester to make additional modifications in preparation for the Project Fair which will take place in early March, 2011.  Since most of the project development took place at Zaber and most of the experimental equipment will remain there, it will not be too difficult to continue working on the project.  The following list contains the specific items that require attention, with the target end-date being the date of the Project Fair.  1) Move all interferometer components onto a single optical breadboard.  Currently, the apparatus is spread over two breadboards and the photodiode array sits freely on the table.  Relocating as many components as possible on a single breadboard will make future alignment procedures easier and make the entire apparatus easier to transport to the Project Fair.  2) Complete and submit a "user manual" document which contains instructions on how to use the dsPIC33F board (button functions, pin assignments, etc.) to make measurements, as well as instructions for aligning the interferometer and how to adjust the mirror knobs.  3) Either extend the wiring for the photodiode array so that the dsPIC33F board can be located further from the interferometer, or make new buttons with long wires.  This will be necessary to demonstrate a position measurement without inducing disturbances by pressing the board which sits on same table as the interferometer.  4) If time permits, construct a more permanent means of mounting the photodiode array PCB to the optical mounting post.  As already mentioned, the C-clamp that is currently being used for this will eventually need to be returned to UBC.  HIGH-ACCURACY POSITION  Page 21 FEEDBACK SYSTEM January 10, 2011   9.0 RECOMMENDATIONS 9.1 Distributed Feedback Laser Although the HeNe laser was used in this prototype, DFB laser diodes should be adopted for future development, if miniaturization is desired.  DFB laser diodes are much smaller, while maintaining a long coherence length, which provides a size advantage while still covering the entire range of motion of the linear actuator.  Since most commercially available DFB lasers are invisible to human eyes, adopting this technology would increase the difficulty of optical alignment.  Additional equipment (e.g. night vision goggles, fluorescent paper) would be required to properly align the mirrors to setup the interference pattern. 9.2 Digital Signal Processing  The current sampling method with the DSP is functional, but improvements should be made to increase the resolution. The current algorithm simply digitizes the voltage readings from the photodiode array and finds the peak by reading the maximum value in the data set. However, the only way to increase the resolution is to add more elements. Therefore, more effort should be made to use the cross-correlation function in the DSP.  In signal processing, cross-correlation is a measure of two coherent waveforms as a function of a time-lag applied to one of them. In this application, an 'initial' signal, denoted function f, is taken when the target mirror is at its resting position and a 'resulting' signal, denoted function g, is taken when the target mirror is shifted along its axis of motion by an unknown amount. By applying the cross-correlation property, the distance that g must be shifted to make it identical to f can be calculated.  For a discrete function, the cross-correlation is defined as:       The two functions match when the value of       is maximized, which means the phase shift between them is exactly π (i.e. half of the laser beam wavelength). As a result, a high resolution position measurement system can be created by relating the phase shift to the relative position of the target mirror.  Firstly, rather than sampling six elements sequentially, they should be sampled simultaneously.  If there are any changes in the intensity of the laser light over time, this would prevent that from becoming an issue (i.e. if the intensity of the laser light were to fluctuate in between two sequential samples, this would affect the output).  Furthermore, any noise created by random sudden voltage spikes in the system could be greatly reduced. HIGH-ACCURACY POSITION  Page 22 FEEDBACK SYSTEM January 10, 2011   After all the signals are recorded, a cross-correlation would be performed to pick out the peak position. This means the resolution would no longer be directly controlled by the number of elements.  This would also eliminate the issue outlined in section 6.3, where the resolution calculation is only perfect if exactly one full wavelength of the interference pattern is spread across the elements.  Therefore, if viable, this would be considered the ideal sampling algorithm. 9.3 Signal processing speed  A faster ADC should be investigated in the future for cost-effectiveness.  The ADC conversion rate should ideally be at least 30 MHz to avoid aliasing and to be able to track a moving stage at speeds up to 2m/s.  Furthermore, in order to measure the displacement of a faster moving stage, an FPGA could be integrated into the prototype instead of the dsPIC33F board to reduce the signal processing time. 9.4 Range of motion and speed requirements  It is recommended that the speed and range of motion requirements be lowered, for practicality reasons.  For speed, if the requirement were to remain at 2 m/s, as mentioned, an ADC would need a conversion rate of roughly 30 MHz.  However, it would also need to be able to simultaneously sample at least six channels (potentially up to sixteen).  While there are ADCs on the market that are capable of doing one or the other, it is not common to find one that does both, and therefore, it could be quite costly. Since the maximum speed of any Zaber stage is 550 mm/s, it is more practical to lower the requirement to this speed since nothing faster can be tested.  For range of motion, alignment issues make it quite difficult to achieve 2 m.  Tiny angular misalignments become exacerbated as the displacement increases, and these are very difficult to detect.  As stated in section 6.2, a mirror deviation of one arcminute (1/60 of a degree) would result in a beam separation of 0.6 mm after 2 m, which is enough to significantly affect the interference pattern.  Therefore, the amount of accuracy required not just difficult to achieve, it is likely not feasible. 9.5 Noise Reduction  The current setup is very vulnerable to external noise.  In order for the system to reliably measure at a high level of precision, several improvements need to be made in both the electrical and mechanical design.   Add vibration mounts  Control the system remotely, or locate the electronics further away from the interferometer  Reduce the amount of ambient light by isolating the photodiode array, or use an optical bandpass filter HIGH-ACCURACY POSITION  Page 23 FEEDBACK SYSTEM January 10, 2011    Normalize the outputs from the photodiode array to eliminate any problems with differences in the sensitivity and offset of the voltage signal of each photodiode element  Conduct more direct measurement testing to obtain more data for comparison and further development  Once the modifications are made and the system can be used to obtain proper measurements, then it can be used to characterize the motion of the Zaber stages.  HIGH-ACCURACY POSITION  Page 24 FEEDBACK SYSTEM January 10, 2011   REFERENCES  [1] - http://www.phy.davidson.edu/stuhome/cabell_f/diffractionfinal/pages/Michelson.htm  [2] - http://members.misty.com/don/laserhen.htm#hentoo4  [3] - http://www.zaber.com/products/product_group.php?group=T- LSM&tab=Series%20Specs#tabs HIGH-ACCURACY POSITION  Page 25 FEEDBACK SYSTEM January 10, 2011   APPENDIX A – SOFTWARE CODE  Header files and linker scripts, as well as functions for initializing and controlling the LCD screen were provided as example code by Microchip Technologies, and as such, are not included in this section.  This section contains the code written by the authors.  Main code:  #include "p33FJ256GP710.h" #include "lcd.h" #include "common.h"  _FOSCSEL(FNOSC_PRIPLL); _FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_XT); _FWDT(FWDTEN_OFF);  const char mytext[] =  " Goodbye World "; const char mytext1[] = "Press S4 to cont";  const char adc_msg1[] ="Count=          "; const char adc_msg2[] ="Dist=           "; const unsigned int channels[] = {11,10,9,8,3,2,0}; unsigned int start = 0; unsigned int maximum; unsigned int previous1, previous2 = 0; unsigned int maxchannel = 0; unsigned int sum_array[NUM_ELEMENTS] = {0}; unsigned int sum( unsigned int array[][NUM_SAMPLES], int column ); unsigned int counter = 0;  // Using internal FRC oscillator at 8MHz // Fosc = Fin * (DIVISOR<8:0> + 2 / ((PRESCLR<4:0> +2) * (PLLPOST<1:0> +1) ) // DIVISOR<8:0> bits located in PLLFBF SFR ---> (PLL Multiplier) // PLLPOST<1:0> bits located in CLKDIV SFR ---> (PLL VCO output divide) // PRESCLR<4:0> bits located in CLKDIV SFR ---> (PLL Phase Detector input divide)  int main ( void ) {  /* Initialize some general use variables */  int i;  x = 0;  y = 0;          //The settings below set up the oscillator and PLL for 16 MIPS as         //follows:         //            Crystal Frequency  * (DIVISOR+2)         // Fcy =     ---------------------------------         //              PLLPOST * (PRESCLR+2) * 4         PLLFBD = 0x00A0;         CLKDIV = 0x0048;   /* set LEDs (D3-D10/RA0-RA7) drive state low */  LATA = 0xFF00;  /* set LED pins (D3-D10/RA0-RA7) as outputs */  TRISA = 0xFF00;   /* set buttons as inputs */  TRISDbits.TRISD6 = 1;  TRISDbits.TRISD7 = 1;   /* Initialize LCD Display */  Init_LCD();   /* Welcome message */ HIGH-ACCURACY POSITION  Page 26 FEEDBACK SYSTEM January 10, 2011    home_clr();  puts_lcd( (char*) &mytext[0], sizeof(mytext) -1 );  line_2();  puts_lcd( (char*) &mytext1[0], sizeof(mytext1) -1 );   /* wait here until switch S5 is pressed */  while ( PORTDbits.RD13 );   home_clr();  puts_lcd( (char*) &adc_msg1[0], sizeof(adc_msg1) -1 );   line_2();  puts_lcd( (char*) &adc_msg2[0], sizeof(adc_msg2) -1 );      /* Initialize ADC  */  Init_ADC2();   /* Initialize Change Notification */  Init_CN();      /* Infinite Loop */     while ( 1 )     {    if ( lcd_update )   {    home_it();    cursor_right();    cursor_right();    cursor_right();    cursor_right();    cursor_right();    cursor_right();    lcdcounts( counter );    lcd_data( tenthous);       lcd_data( thous);    lcd_data( hunds);    lcd_data( tens);    lcd_data( ones);       lcd_update = 0;   }        /* check if time to update LCD with ADC data */    if (measurement)   {    if (start)    {     start = 0;     AD1CON1bits.ADON = 0;     IFS0bits.AD1IF = 0;        // reset ADC interrupt flag     IEC0bits.AD1IE = 0;     adc_update = 0;    }     else    {     start = 1;     IFS0bits.AD1IF = 0;        // reset ADC interrupt flag     IEC0bits.AD1IE = 1;     AD1CON1bits.ADON = 1;     counter = 32767;    }    measurement = 0;   }      if ( adc_update )       {    x++;    if (x==NUM_ELEMENTS) {     x = 0; HIGH-ACCURACY POSITION  Page 27 FEEDBACK SYSTEM January 10, 2011      }     AD1CON1bits.ADON = 0;    AD1CHS0bits.CH0SA = channels[(x%NUM_ELEMENTS)];     if ((x%NUM_ELEMENTS) == 0)    {      for(i=0; i < NUM_ELEMENTS; i++)     {      sum_array[i] = sum(temp1, i);     }       maximum = sum_array[0];      previous2 = previous1;     previous1 = maxchannel;     maxchannel = 0x0001;      if (sum_array[1] > maximum) {     maximum = sum_array[1];     maxchannel = 0x0002;     }      if (sum_array[2] > maximum) {     maximum = sum_array[2];     maxchannel = 0x0004;     }      if (sum_array[3] > maximum) {     maximum = sum_array[3];     maxchannel = 0x0008;     }      if (sum_array[4] > maximum) {     maximum = sum_array[4];     maxchannel = 0x0010;     }      if (sum_array[5] > maximum) {     maximum = sum_array[5];     maxchannel = 0x0020;     }      if (sum_array[6] > maximum) {     maximum = sum_array[6];     maxchannel = 0x0040;     }      LATA = maxchannel;     y++;     if(y == NUM_SAMPLES) {     y = 0;     }       if(previous1 == 0x0008)     {      // Current sample is also middle      if(maxchannel == 0x0008) {       previous1 = previous2;      }      // Stage moving forward      else if( (maxchannel > previous1) && (previous2 < previous1) ) {       counter++;      }      // Stage moving backward      else if( (maxchannel < previous1) && (previous2 > previous1) ) {       counter--; HIGH-ACCURACY POSITION  Page 28 FEEDBACK SYSTEM January 10, 2011        }     }     }     AD1CON1bits.ADON = 1;       adc_update = 0;     }   } }  unsigned int sum( unsigned int array[][NUM_SAMPLES], int column ) {   unsigned int temp=0;  int j;   for( j = 0; j<NUM_SAMPLES; j++)  {   temp += array[column][j];  }   return temp; }   ADC Initialization: #include "p33FJ256GP710.h"  void Init_ADC2( void ) {  TRISBbits.TRISB0 = 1;  TRISBbits.TRISB2 = 1;  TRISBbits.TRISB3 = 1;  TRISBbits.TRISB8 = 1;  TRISBbits.TRISB9 = 1;  TRISBbits.TRISB10 = 1;  TRISBbits.TRISB11 = 1;          //Port B is input   AD1CON1 = 0;    //Initialize AD1CON1  AD1CON1bits.ADSIDL = 0;  //Stop in Idle Mode  AD1CON1bits.ADDMABM = 0; //Something about DMA -- not needed  AD1CON1bits.AD12B = 1;  //1 = 12-bit, one channel, 0 = 10-bit, 4 channel  AD1CON1bits.FORM = 0b00; //Integer form  AD1CON1bits.SSRC = 0b111; //Auto-convert  AD1CON1bits.SIMSAM = 0;  //Unimplemented when AD12B = 1  AD1CON1bits.ASAM = 1;  //SAMP bit is auto-set  AD1CON1bits.SAMP = 1;  //Sample enable bit  AD1CON1bits.DONE = 0;  //Clear DONE status   AD1CON2 = 0;    //Initialize AD1CON2  AD1CON2bits.VCFG = 0b000; //Converter voltage  AD1CON2bits.CSCNA = 0;  //Do not scan  AD1CON2bits.CHPS = 0b00; //Converts Channel 0 only  AD1CON2bits.SMPI = 0b0001; //ADC interrupt every sample  AD1CON2bits.BUFM = 0;  //Fill buffer from start address  AD1CON2bits.ALTS = 0;  //Only use one MUX   AD1CON3 = 0;    //Initialize AD1CON3  AD1CON3bits.ADRC = 0;  //ADC clock derived from system clock  AD1CON3bits.SAMC = 3;  //Auto sample time bits  AD1CON3bits.ADCS = 22;  //ADC Conversion clock   AD1CSSL = 0;                //No scan   AD1PCFGLbits.PCFG0 = 0;     //0th channel is sampled and converted    AD1PCFGLbits.PCFG2 = 0;  //2nd channel is sampled and converted HIGH-ACCURACY POSITION  Page 29 FEEDBACK SYSTEM January 10, 2011    AD1PCFGLbits.PCFG3 = 0;  //3rd channel is sampled and converted  AD1PCFGLbits.PCFG8 = 0;  //8th channel is sampled and converted    AD1PCFGLbits.PCFG9 = 0;  //9th channel is sampled and converted  AD1PCFGLbits.PCFG10 = 0; //10th channel is sampled and converted  AD1PCFGLbits.PCFG11 = 0; //11th channel is sampled and converted   AD1CHS0bits.CH0SA = 11;      //Connect RB0 on AN0 as CH0 input    AD1CHS0bits.CH0NA = 0;   //AD1CHS123 = 0x0000;     //Connect RB0-RB2 on AN0-AN2 as CH1-CH3 inputs     //IFS0bits.AD1IF = 0;        // reset ADC interrupt flag  //IEC0bits.AD1IE = 1;        // enable ADC interrupts, disable this interrupt if the DMA is enabled    //AD1CON1bits.ADON = 1;      //ADC on  }  ADC Interrupt service routine:  #include "p33FJ256GP710.h" #include "common.h"  volatile unsigned int temp1[NUM_ELEMENTS][NUM_SAMPLES]={0}; volatile unsigned int x; volatile unsigned int y; volatile unsigned char adc_update;  void __attribute__((__interrupt__)) _ADC1Interrupt( void ) {   temp1[(x%NUM_ELEMENTS)][(y%NUM_SAMPLES)] = ADC1BUF0;   /* set flag to update LCD */  adc_update = 1;   /* reset ADC interrupt flag */  IFS0bits.AD1IF = 0; }  Change notification initialization:  #include "p33FJ256GP710.h" #include "common.h"  volatile unsigned char lcd_update; volatile unsigned char measurement;  void __attribute__((__interrupt__)) _CNInterrupt( void ) {  if( !PORTDbits.RD6 )  {   lcd_update = 1;  }   if( !PORTDbits.RD7 )  {   measurement = 1;  }   IFS1bits.CNIF = 0;  //Reset CN interrupt }  Change notification interrupt service routine:  #include "p33FJ256GP710.h" HIGH-ACCURACY POSITION  Page 30 FEEDBACK SYSTEM January 10, 2011   #include "common.h"  volatile unsigned char lcd_update; volatile unsigned char measurement;  void __attribute__((__interrupt__)) _CNInterrupt( void ) {  if( !PORTDbits.RD6 )  {   lcd_update = 1;  }   if( !PORTDbits.RD7 )  {   measurement = 1;  }   IFS1bits.CNIF = 0;  //Reset CN interrupt }  Preparing counter variable for printing onto LCD:  volatile unsigned char ones; volatile unsigned char tens; volatile unsigned char hunds; volatile unsigned char thous; volatile unsigned char tenthous;   void lcdcounts( unsigned int lcd_conv_data ) {  ones = 0;        // reset values  tens = 0;  hunds = 0;  thous = 0;  tenthous = 0;   while ( lcd_conv_data > 0 )  {  if( lcd_conv_data > 9999 )  {   tenthous++;   lcd_conv_data -= 10000;  }   else if( lcd_conv_data > 999 )  {   thous++;   lcd_conv_data -= 1000;  }   else if( lcd_conv_data > 99 )  {   hunds++;   //increment hundreths   lcd_conv_data -= 100;  }   else if ( lcd_conv_data > 9 )  {   tens++;   lcd_conv_data -= 10;  }  else  {   ones++;   lcd_conv_data--;  }  } HIGH-ACCURACY POSITION  Page 31 FEEDBACK SYSTEM January 10, 2011    ones += 0x30;  tens += 0x30;  hunds += 0x30;  thous += 0x30;  tenthous += 0x30;  }  

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:
https://iiif.library.ubc.ca/presentation/dsp.52966.1-0074453/manifest

Comment

Related Items