Introduction
This program is used to control the two axes (tip and tilt) of a MEMS micromirror in a laser-beam steering system in such a way as to deflect the laser beam in a desired angle or direction. For laser beams that are terminated on a flat screen or a wall, this system will create "drawings" which can be static or animated. The general operation of the program is to take inputs from a user in terms of the desired pattern that the laser beam is supposed to follow, the refresh rate which determines the speed at which the laser will trace that pattern and many other inputs. Then the program computes the necessary voltage signals for each axis to achieve that result and sends them to the user's desired output port of the computer. For example, the output device could be the user's National Instruments DAQ card that is plugged into the computer, the Mirrorcle Technologies USB-based development box, or the computer's audio output port.
The program has a number of different modes which can be selected using the drop-down list at the top left corner of the GUI. The different functions and settings available in these modes are explained in the following sections.

General Settings:
The voltage level sets the signal level that is output by the soundcard or DAQ card. The maximum range of the soundcard is normally ~[-1.5V,1.5V] and is queried when the analog output channels are established. In the case of the DAQ card, the voltage is typically [-10V,10V] but could vary depending on the card used. The analog output source can be selected from the menu and switching sources will automatically reset the voltage ranges and rescale them. However, it is preferable not to change sources while a stream is running since this could harm the device. It is safest to stop the current stream using the Stop button and then change the AO source.
It is also possible to change the sampling rate of the output. Most sound cards support at least 44100 sps on 2 channels and possibly more. The SoundBlaster Audigy can support up to 96000 sps or 192000 sps sampling rates, but a maximum of 96000 sps is usable in Matlab for audio ports. The 6062E NI PCMCIA card can support rates up to 250,000 sps per channel. Because this is a real data acquisition (DAQ) card, Matlab allows full use of its sampling rates up to the maximum. The modulation frequency is the frequency used to modulate all the sketches and curve plotting waveforms. Choose this as high as possible in order to minimize mixing effects with the actual drawing signal. Frequencies in the 20-25 kHz range give sharp drawings without too much loss in signal amplitude that occurs for frequencies beyond about 35 kHz (SB Audigy). For the DAQ case, it is possible to use much higher modulation frequencies and this is not an issue.
Filter and System Settings
A set of filters is used to process the raw drawing signals in order to prevent resonant excitation of the mirror. There are 4 types of filters available: Butterworth, Bessel, Inverse System , Custom. The user can choose the passband and number of poles for the Butterworth and Bessel filters. Alternatively, the user can load a custom filter from a mat file. Arbitrary filters can be designed using tools such as the Filter Design Tool (fdatool), which requires the Signal Processing Toolbox (fdatool can be launched using the button on the left bottom of the GUI. The [b,a] coefficients for the filter must be saved into a mat file under the variable names [Num,Den] and can then be loaded into the program by choosing the custom filter option.
The Inverse System filter uses knowledge about the device dynamics (natural frequency and Q) in order to notch out the resonant frequency components in the signal. This results in a much larger available bandwidth and results in much faster settling times and translates into sharper images and corners. This is a simple open-loop scheme that does not require any feedback system but does rely on prior knowledge of the natural frequency. This can be found easily by switching the program to Function Generator mode and using sine waves of different frequencies to locate the device resonance. These values can be entered into the system parameters and are used by the program to calculate the Inverse System Filter.
To switch between filter and system parameter mode, use the radio toggle controls. It is also possible to load an external system from a mat file and as for the filter case, the [b,a] coefficients must be saved as [Num,Den] to load correctly.
Program Modes
Sketch Mode:
There are 3 separate sketching programs in this mode:
- Freehand: You can draw a shape by clicking the left mouse button and dragging to trace out the curve. Releasing the mouse button terminates the curve. To clear the screen, press the reset button. The pattern is displayed on the screen by the mirror and the stream can be stopped or restarted using the start/stop button.

- Polyline: This mode can be used to draw polygons that are open or closed. Clicking with the left mouse button adds points to the existing polygon. Keeping the left mouse button pressed and moving the mouse can be used to dynamically see the new curve. Releasing the left button confirms the addition of the point. In order to close a polygon, click the right mouse button, which joins the first and last points. It is also possible to modify the existing polygon. Click the left mouse button in the vicinity of the point you want to move and drag the mouse to move the point to its new location. Right clicking in the vicinity of the point will delete the point. Deleting the first/last points of a closed polygon results in opening of the polygon.

- Spline: This mode is available only if you have the Spline Toolbox. The control polygon of the B-Spline can be drawn in the same way as in the polyline mode. It is possible to add/delete/move points and also to close the polygon. The order of the B-spline can be chosen by using the slider on the right. Remember that the order of the spline must be greater than the number of points in the control polygon. It is also possible to have two kinds of splines: approximating and interpolating that can be chosen using the popup menu. Note that in the approximating mode, closing the polygon does not give rise to a closed curve.


Clock Mode:
This mode displays an analog clock. The clock can be started or stopped using the Start/ Stop button. Note that the clock may take a few seconds to stop depending on the speed of your computer. The size of the clock can be changed using the amplitude slider.

Oscilloscope Mode:
This mode uses the microphone audio channel on the computer for analog input and the mirror displays the signal traces on the screen. The scope must be started by pressing the Start / Stop button. The time base of the scope can be modified using the Samples slider. The actual time scale is displayed on the graph at the button right corner. The scale slider can be used to control the size of the graph display and the autoscale check button can be used to automatically readjust the display. The oscilloscope also has a software trigger, which can be activated by clicking the trigger check button. The trigger voltage can be set using the trigger slider and the scope will activate on the rising edge of the trigger. You can experiment by connecting the output of a signal generator to the audio input and try out different types of waveforms and time scales.

Curve Plotter Mode:
This mode demonstrates different types of mathematical curves, animations and some sample vector text. There are five curve types that can be selected from the list on the right top:
- Waveforms: This function is used to draw simple waveforms such as sine, triangle and square. The user can choose the number of cycles displayed and the amplitude of the waveform. For the sawtooth and square waveforms, the duty cycle can also be adjusted. A useful exercise in this mode is to check the step response of the device and the effect of various filter parameters. In order to do this, select the square waveform with a single cycle and choose between the Butterworth, Bessel, and Inverse Square filters and check out the response of the device. Finally, there is also a spiral option, which traces out a right-angled spiral with variable number of loops and is useful for checking the fidelity of the filters in tracing sharp corners. These figures can be rotated by choosing the rotate option in the animation menu at the bottom. The animation time slider can be used to fix the total time for one cycle of the animation. Normally an animation time of 1-2 sec gives visually pleasing results. Increasing the animation time slows the rotations but takes longer to compute. Once the animation frames are computed, the program loops the animation infinitely.


 
 
- Spirographs: These patterns are formed by tracing the paths of points on a circle as it revolves around another circle. Depending on the relative radii of the circles and the position of the point, different curves are obtained. The program allows the user to choose between epitrochoids, hypotrochoids, epicycloids, and hypocycloids. The user can specify the parameters A, B, C that determine the shape of the curves and the size of the drawing. In this mode it is possible to have two main types of animations: in the first case, the entire curve is rotated at the rate specified by the animation time slider. The second animation option allows the user to cycle through different values of A, B, or C giving rise to a sequence of curves. The program calculates sweeps the chosen parameter (A/B/C) from the current setting through 6 values. Another curve is the rose family, which generates a set of roses with n-petals. The curve family can be generated by varying two parameters A & B. For B=1, a rose with n=A petals is obtained for odd A and 2A petals for even A. Changing B gives rise to more intricate and complicated patterns. The user can also obtain rotating animations by choosing the rotate animation option. Some sample screenshots and suggested parameter values are shown below.
 

 
 

Family of Roses: The curves are defined in terms of the A/B ratio as described above.

Family of Epitrochoids
- Lissajous: Lissajous patterns are generated by using a set of basis waveforms (sinusoidal / sawtooth) on the X and Y axes and are commonly seen on oscilloscopes. Changing the relative frequencies on either axis gives rise to a whole array of patterns. In addition to the frequency, it is also possible to change the phase and amplitude of the signal on either axis. A more complicated set of patterns is obtained by allowing modulation of the waveform on either or both axes. The user can select amplitude or frequency modulation for each axis and also the type of waveform used for modulation. The modulation index, which is a measure of the strength of frequency modulation, can be chosen by the user. As the modulation index is increased, the curve starts to get more complicated and deviates from its non modulated version. The user can choose to animate rotation of the entire curve as in previous modes or animate the X-Y phase lag. The phase lag animation sweeps the phase through 360o, resulting in an appearance of rotation of the curve about its long axis. Similarly, the modulation phase, which is the phase angle between the base and modulation signals can be swept to generate another type of animation. Finally, the modulation ratio can also be swept in order to see the effect of increasing modulation strengths on the base signal.

 

- Import ILDA / Text Files: The International Laser Display Association (ILDA) has a standard file format for laser graphics that is used in many laser show design softwares. More information about the format and various available softwares can be obtained at the ILDA site, LaserFx, and Pangolin. The ild file format is a binary format and can contain multiple frames that are part of an animation sequence. A number of sample ild frames are included with the program. To load a new ild file, press the import file button and choose the file from the file dialog box. The program parses the file to extract all the frame information and displays the total number of frames. The user can display a single static frame by using the frame number slider control. Alternatively, it is possible to run all the frames as part of an animation by setting the animation type to Slideshow. As in previos modes, it is possible to create a rotation animation of a single frame by choosing the Rotate mode as the animation type. The animation time determines the time to display all the frames. If the time is too short, each frame will have few points resulting in loss of detail or smoothing applied by the filters. The other factor in displaying animations is the refresh rate. Too high refresh rates again decrease the number of points available per frame leading to loss of details. Hence it is important to keep a sufficiently large animation time and low enough refresh rate for best results. Finally, each frame can be rotated in 3D by choosing the camera theta (angle with +X axis) and phi (angle from XY plane). This can lead to cool effects in viewing frames containing 3D objects. A good starting file is cangoose.ild. Load the file and select Slideshow animation and set animation time to 2 sec. To make the bird fly faster, decrease animation time to 1s, 0.25 sec in steps. Another option is to import a text file with XY coordinates. The user can read in any custom stream of coordinates using this option - all coordinates are scaled from 0-1 inside the program. Furthermore, the user can export the current displayed curve or frame using the export button at the top right. This saves the XY coordinates of the current drawing and the filtered version in separate text files in the program directory.
 
 
 
- Text: This mode allows the user to enter a text string and uses a vector font description in order to display the text. We use the Hershey font set and the user can choose between a set of two fonts. It is useful to try different types of filter parameters in order to get the optimal display since this depends on the exact sequence of letters. Finally the user can change the size of the displayed string.
 
Function Generator:
This mode uses the sound card as an analog output to directly send synthesized waveforms to the mirror. Unlike in the curve plotter mode, there is no modulation scheme used to transmit the signal to the mirror. Hence this mode must be used carefully since it is possible to excite the resonant frequencies of the device and damage it.
- Waveforms: This mode can be used to send a set of signal waveforms on either or both channels. The user can choose between sinusoidal, sawtooth, or noise waveforms. For the sinusoidal and sawtooth waveforms, the user can choose the frequency and this can be used to find the resonant frequency of the device. This is simply done by choosing sine waves of different frequencies and observing the mirrors deflection peak at the resonant frequency, which should be visibly obvious. It is safest to keep the voltage level low since the devices have high Q and can be damaged by exciting them resonantly with excess voltage. The resonant frequency can then be used to refine the system parameters used to calculate the Inverse Square filter. Q values from 10-100 are reasonable. Another point to note is that the actual resonant frequency is twice the value on the slider since the mirror responds to the square of the voltage waveform. The noise waveform is useful for checking if the devices are functional and can occasionally be used to revive devices that may be stuck or crashed.

- Lissajous 2D: This is similar to the function in the curve plotter mode but there is no modulation used in this case. The user can directly chose the base and modulation frequencies on both axes and the types of waveforms desired. Here, it is relatively simple to obtain animations by offsetting one of the X/Y frequencies by 1-2 Hz (e.g. 201/400 Hz). Another interesting set of animations is obtained near resonance. Make both X, Y base frequencies near resonance so that a large mirror amplitude is obtained. Now change the modulation frequencies to greater than 30-35 Hz so that persistence of vision gives rise to an intricate set of animations. Changing the modulation frequency to a non-integer number slows the animation and also gives more aesthetic patterns. It is possible to get a virtually limitless set of patterns using the four sets of frequency parameters.

- Lissajous 3D: This is similar to the 2D function except that base waves are used on 3 axes to get a three-dimensional Lissajous figure. This curve is then projected onto an arbitrary plane in space, which is specified by choosing values for the camera theta and camera phi values. The angle theta is the rotation of the camera about the Z axis in the XY plane and phi is the angle of the camera with the positive Z axis (X-Y plane is theta=0, phi=90). Hence the user has an added dimension of flexibility in choosing the viewpoint in space and this enhances the range of possible curves and animations that can be obtained. As in the 3D case, it is possible to do modulation and also operate the mirror at resonance to get larger and more intricate images.

(Back to Top) |