image tracing laser system - rpicats-fs.rpi.edu/~wenj/ecse446s06/team4progressreport.pdf · this...

38
IMAGE TRACING LASER SYSTEM ECSE-4460 Control Systems Design Progress Report Jason Duarte Azmat Latif Stephen Sundell Tim Weidner March 29, 2006 Rensselaer Polytechnic Institute

Upload: others

Post on 01-May-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

IMAGE TRACING LASER SYSTEM ECSE-4460 Control Systems Design

Progress Report

Jason Duarte Azmat Latif

Stephen Sundell Tim Weidner

March 29, 2006

Rensselaer Polytechnic Institute

Page 2: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

ii

Executive Summary This report describes the progress made in building an image tracing laser system using two degrees of freedom for pan and tilt motion. The design model parameters are obtained through MatLab, SolidWorks, and LabView. The system is divided into three major components: image analysis, trajectory planning, and control design. The image analysis is used to identify an image to be traced. The trajectory planning returns the joint trajectories to follow a desired path. Finally the control design positions the links to the desired locations. So far, much progress has been made in obtaining key system parameters. The nonlinear model has been developed, linearized, and some preliminary control work has been done. The use of different controllers is being explored. The model can be made more accurate, and by doing so, the control design becomes more feasible. Trajectory generation is also being modeled. Considering the use of LabView to implement the full system, significant progress has been made in the area of trajectory generation. Progress still needs to be seen in the areas of image processing and controller implementation. As the camera and image setup is finalized, many more parameters, including inverse kinematics, will fall into place. Compared to the initial task breakdown, the areas of trajectory generation and control are right on schedule. The third area, image processing, has been simplified to allow for project completion by the end of the semester. Several delays in the schedule have occurred. These are mainly due to equipment malfunction. These issues are currently being resolved.

Page 3: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

iii

Table of Contents

1.0 Introduction...............................................................................................................1 2.0 Preliminary Results ...................................................................................................2

2.1 Friction Identification ............................................................................................2 2.2 Velocity Estimation ...............................................................................................5 2.3 Nonlinear Model....................................................................................................5 2.4 Linear Model .........................................................................................................7 2.5 Controller Design ..................................................................................................8 2.6 Trajectory Generation ..........................................................................................10

2.6.1 S-Curve and Trapezoidal Method..................................................................11 2.6.2 Desired Angle vs. Output Angle....................................................................12 2.6.3 LabView Simulation .....................................................................................13

2.7 Image Processing.................................................................................................15 2.8 Laser Control.......................................................................................................20

3.0 Summary of Progress...............................................................................................21

3.1 Plan .....................................................................................................................21 3.2 Schedule ..............................................................................................................21 3.3 Cost .....................................................................................................................22 3.4 Unanticipated Challenges ....................................................................................23 3.5 Forecast ...............................................................................................................23

4.0 Bibliography............................................................................................................24 Appendix A: LabView code .........................................................................................25 Appendix B: MATLAB code .......................................................................................27 Appendix C: Simulink..................................................................................................33 Statement of Contribution .............................................................................................34

Page 4: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

iv

List of Figures Figure 1: LabView Friction Test Program.......................................................................2 Figure 2: Velocity vs. Time Graphs ................................................................................3 Figure 3: Pan Axis Friction Identification .......................................................................4 Figure 4: Tilt Axis Friction Identification .......................................................................4 Figure 5: Pan-Tilt Nonlinear Simulation.........................................................................5 Figure 6: Pan-Tilt System Dynamics. .............................................................................6 Figure 7: Friction Subsystem. .........................................................................................7 Figure 8: Preliminary Pan Root Locus ............................................................................8 Figure 9: Preliminary Pan Bode Plot and Step Response.................................................9 Figure 10: Preliminary Tilt Root Locus ..........................................................................9 Figure 11: Preliminary Tilt Bode Plot and Step Response.............................................10 Figure 12: Position, Velocity, and Acceleration Profiles using S-Curve Method ...........11 Figure 13: Position, Velocity, and Acceleration Profiles using Trapeziod Method........11 Figure 14: Desired vs. Actual Pan Angle using Trapezoid Method................................12 Figure 15: Desired vs. Actual Tilt Angle using Trapezoid Method................................12 Figure 16: Desired vs. Actual Pan Angle for Circular Trajectory ..................................13 Figure 17: Desired vs. Actual Tilt Angle for Circular Trajectory...................................13 Figure 18: Position Profile using S-Curve.....................................................................14 Figure 19: Position Profile using Trapezoidal Profile....................................................14 Figure 20: Position Profile using S-curve Method.........................................................14 Figure 21: Position Profile using Trapezoidal Method ..................................................15 Figure 22: Vertical Image Calibration...........................................................................16 Figure 23: Horizontal Image Calibration.......................................................................17 Figure 24: Main Function for Path Finding...................................................................17 Figure 25: Image Subfunction 1....................................................................................18 Figure 26: Image Subfunction 3....................................................................................19 Figure 27: Image Subfunction 5....................................................................................19

List of Tables

Table 1: Pan Axis Friction Parameters............................................................................4 Table 2: Tilt Axis Friction Parameters ............................................................................5 Table 3: Schedule for Remaining Five Weeks ..............................................................22 Table 4: Cost of Labor..................................................................................................22 Table 5: Cost of Additional Items. ................................................................................22

Page 5: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

1

1.0 Introduction The goal of this project is to create a shape-tracing laser system capable of tracing patterns consisting of curves and polygons. There are similar designs used in the industry today. Predominant applications are robots used for spray-painting, arc welding, and laser cutting. One clear advantage of using robotics manipulators is that the required task can typically be completed more quickly and efficiently. The combination of minimal fixturing and high execution speed can also be economically beneficial for companies. In addition, several applications of robots may also save lives. For example, a worker can develop respiratory irritation and metabolic toxicity from inhaling paint components and spray drift. Therefore, it is desirable to use a robot to create a safer work environment. Most industry applications’ robots use CAD drawings which use a color coded scheme to highlight the curves to be cut and etched. Our design will use a webcam to identify the image to be traced. We will then perform several image analysis functions to determine the robot’s trajectory. One similar design is Team 5 of 2004’s Signature machine. Their project used a sharpie black marker to write down words and trace out basic shapes such as a circles and squares on a seven by seven inch area. However, our design uses a laser pointer which will not be in contact with the surface. We intend to place the laser perpendicular to an initially vertical plate that tilts on two axes in order to control the direction of the laser. Each tilting axis will be operated on by an electric motor. Each motor will be controlled using software with position and image feedback for control. By using two forms of feedback, we intend for our design to have high accuracy and repeatability with every image. The design objectives are to traverse an image at a rate of 1 ft/sec with 0% overshoot and no steady state errors. Using LabView we were able to vary the torque and obtain the corresponding angular velocity. The torque was plotted against the angular velocity to obtain the Coulomb and viscous friction terms for each axis. The friction terms were then added in our nonlinear Simulink model. Since our system will be required to track a trajectory, the input to the model is an array of angles for each axis. The array of angles was calculated using Professor Wen’s trajectory generation m-file. Using LabView, position, velocity and acceleration profiles were created for each axis.

Page 6: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

2

2.0 Preliminary Results

2.1 Friction Identification Friction parameters have been identified by comparing the system’s angular velocity with an input of a constant torque. A Labview program was created, as shown in figure 1, to gather data needed for each pan and tilt test. Constant voltages ranging from -1V to 1V were sent to the system in 0.05V increments. A 1V pulse was sent to the system for 1 second before each voltage test to overcome stiction. Each incremental voltage was then applied for 30 seconds and the velocity of the system was calculated throughout this duration. Thirty second tests would ensure steady state velocities at each voltage.

Figure 1: LabView Friction Test Program

After all voltages were tested, the program generated an Angular Velocity by Time graph for all voltages, shown for tilt and pan axes in figure 2.

Page 7: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

3

Figure 2: Velocity vs. Time Graphs

An array was also created containing the final velocities of the system at each given voltage. These values were exported to Excel, and voltage was converted to torque using the equation:

atm KKNV ×××=τ , 1.0432.3.6)869./47.2( ×××= Vmτ ,

Vm 077389.0=τ .

It must be noted that prior to this testing, the amplifiers were tested and calibrated to verify that they indeed supplied .1A per volt. In the case of the pan axis, a back EMF was induced by the pan motor, and therefore a reading of .08A per volt was measured. This value was used in the torque equation for the pan axis to ensure as accurate friction values as possible. Torque vs. Velocity plots were then created to identify friction terms as shown in figures 3 and 4. Linear regression was performed in each plot, and slopes were found to determine viscous friction. Coulomb friction was determined as the value at which the best fit lines intersect the torque axis. Tables 1 and 2 display all calculated friction values.

Page 8: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

4

Pan Axis Friction Identification

y = 0.0009x - 0.0385

y = 0.0009x + 0.0406

-0.06

-0.04

-0.02

0

0.02

0.04

0.06

-15 -10 -5 0 5 10 15

Steady State Load Angular Velocity (rad/sec)

App

lied

Torq

ue (N

-m)

Figure 3: Pan Axis Friction Identification

Tilt Axis Friction Identification

y = 0.0019x + 0.0584

y = 0.0017x - 0.0569

-0.1

-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

0.06

0.08

0.1

-15 -10 -5 0 5 10 15

Steady State Load Angular Velocity (rad/sec)

App

lied

Torq

ue (N

-m)

Figure 4: Tilt Axis Friction Identification

Table 1: Pan Axis Friction Parameters

Positive Negative Viscous

(N*m*s/rad) 0.0009 0.0009

Coulomb (N*m)

0.0406 -0.0385

Page 9: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

5

Table 2: Tilt Axis Friction Parameters Positive Negative

Viscous (N*m*s/rad)

0.0019 0.0017

Coulomb (N*m)

0.0584 -0.0569

2.2 Velocity Estimation Often the motor constraints such as maximum velocity and acceleration are used in applications involving trajectories. These parameters are needed for trapezoidal, s-curve, sine, and sigmoid velocity profiles. Therefore, to further develop the model with these key system parameters, maximum velocity and acceleration values must be obtained. This is done by implementing velocity estimation on the FPGA as shown in Appendix A. National Instruments provides help for velocity estimation on their website [1]. They discuss a basic method for counting the number of quadrature encoder pulses in a fixed time interval to estimate the velocity and acceleration of the encoder. This method is appropriate for high speed applications, although it is important to select an appropriate sampling period. Very small time periods can result in erratic changes in velocity and acceleration readings. Implementation of velocity and acceleration readings on the FPGA allows these values to be returned to the host in real time. Calculations on the host are then used to convert to engineering units.

2.3 Nonlinear Model In order to test and validate our actual design, a full nonlinear simulation is used. As shown in figure 5, the simulation consists of desired input angles, PID controllers for pan and tilt axes, the pan-tilt dynamics, actual output angles, and a quantizer in the feedback path.

Pan Tilt Nonlinear Simulation

muxdemux

y error scope y Scope

y

outputZero-OrderHold

Quantizer

tau theta

Pan-tilt dynamicsIn1 Out1

PID 2

In1 Out1

PID 1[t angle1 angle2]

FromWorkspace

Demux

Figure 5: Pan-Tilt Nonlinear Simulation

Page 10: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

6

Through the use of this detailed model and accurate system parameters, one can test different controller configurations with relative ease. At this point most of the system parameters have been identified such as mass, inertia, and Coriolis forces. One term that has been added is the quantizer. The quantization interval has been set to match the encoder resolution of 2*Pi/4096. Additionally, friction is being considered as a disturbance and is being accounted for with the other pan-tilt dynamics as shown in figure 6.

1thetaddot

theta M inverse

mass matrix inverse

MatrixMultiply

M inv *(tau-G-C-F)theta G(theta)

Gravity Load

thetadot Out1

Friction

thetathetadotC thdot

Coriolis/Centrifugal3

thetadot

2theta

1tau

Figure 6: Pan-Tilt System Dynamics.

The friction dynamics have been determined experimentally, and are modeled according to the equation:

y = sign(x) * (Fv * abs(x) + Fc), where Fv represents the viscous friction and Fc represents the Coulomb friction. Since the combination of viscous and coulomb friction is discontinuous, the simulation configuration parameters were modified to disable zero crossing control. The resulting subsystem, shown in figure 7, allows friction to be cancelled for both pan and tilt axes.

Page 11: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

7

Demux

Mux

1Out1

Sign1

Sign

fv2

Gain3

fc2

Gain2

fv1

Gain1

fc1

Gain

Demux

Add1

Add1

thetadot

Figure 7: Friction Subsystem.

2.4 Linear Model Creating a linear system is useful in order to develop an optimal controller for the system. Linearization simplifies the pan-tilt model by focusing on each angle ),( tiltpan θθ independently, while effects on each other are treated as disturbances. In order to linearize the system about a point, numerical values for panθ and tiltθ are used. Because the pan angle has no gravity loading, an angle of zero can be used. For the tilt axis, half of the range of motion ( °5.26 ) is used. These desired angles, along with our system parameters calculated previously are entered and loaded into MATLAB via script pantiltmodel.m (Appendix B). The MATLAB script, pantilt_lin.m (Appendix B), found from 2003’s ECSE 4962 course website [2], creates the matrices in the state space equation below:

DBAsICsG +−= −1)()( .

Open loop transfer functions are also determined in this script. However, since the system is linear, transfer functions from pan-to-tilt and tilt-to-pan are ignored. Open loop transfer functions 11G (pan) and 22G (tilt) are given as:

11G : 13.16 s^2 + 1.754 s + 10.29

------------------------------------------------- s^4 + 0.2649 s^3 + 0.7997 s^2 + 0.1029 s,

22G : 13.33

---------------------------- s^2 + 0.1333 s + 0.7822.

Page 12: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

8

2.5 Controller Design Preliminary work on the design of pan and tilt compensators has been started using rltool in MATLAB. This root shaping method gives us an alternative to using PID control. Preliminary compensators are shown as:

11K : 281 (s + 32.9) (s + 97.8)

---------------------------------------- (s + 250) (s + 177)

22K : 144 (s + 31.5) (s + 33.4)

----------------------- (s + 194) (s + 83.5)

The resulting root locus, step responses, and bode plots are shown in figures 8 through 11.

Figure 8: Preliminary Pan Root Locus

Page 13: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

9

Figure 9: Preliminary Pan Bode Plot and Step Response

Figure 10: Preliminary Tilt Root Locus

Page 14: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

10

Figure 11: Preliminary Tilt Bode Plot and Step Response

Upcoming steps include comparing linearization results with the nonlinear model, which can be done by viewing step responses, and fine tuning a PID controller. Other control methods will also be tested using both linear and nonlinear models.

2.6 Trajectory Generation The goal of trajectory generation is to obtain a set of coordinates as a function of time that will trace out a desired path. This section compares the position, velocity, and acceleration profiles using the s-curve and trapezoidal trajectory generation method, shown in Appendix B. Next, the desired pan-tilt angles are compared to the actual pan-tilt angles output from our simulation. In order for our system to track a path, the coordinates must be obtained from trajectory generation to an inverse kinematics function. The inverse kinematics would then provide the corresponding joint angles to position the laser pointer. However, the process of finalizing the inverse kinematics function needs to be completed. Therefore, a random set of angles was used to test the system response. This will provide some initial insight to tune the controller so that error can be minimized.

Page 15: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

11

2.6.1 S-Curve and Trapezoidal Method Figures 12 and 13 display the position, velocity and acceleration profiles using the trapezoidal and s-curve methods to reach a final position xf=pi. Using the trapezoidal and s-curve methods for trajectory generation, we also specified the maximum angular velocity, maximum angular acceleration and deceleration that the motors could provide to follow the trajectory. For our simulation we provided 24 rad/sec as our maximum angular velocity and 100 rad/sec^2 as the maximum angular acceleration and deceleration.

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.40

5

10

15

20v

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4-100

-50

0

50

100a

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.40

1

2

3

4s-curve

Figure 12: Position, Velocity, and Acceleration Profiles using S-Curve Method

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.40

1

2

3

4trapezoid

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.40

5

10

15

20v

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4-100

-50

0

50

100a

Figure 13: Position, Velocity, and Acceleration Profiles using Trapeziod Method

Page 16: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

12

Comparing the velocity and acceleration profiles the s-curve method shows a gradual increase in its acceleration and velocity. The trapezoidal method indicates a quick move to its maximum acceleration, where it abruptly stops and quickly decelerates. The result is that final destination is achieved slightly quicker using the trapezoidal method than the s-curve method.

2.6.2 Desired Angle vs. Output Angle The graphs shown in figures 14 and 15 compare the desired angle versus the actual angle output by our simulation using the trapezoidal method (Appendix B). The desired pan angle is from zero to Pi and the desired tilt angle is from 0 to Pi/2.

0 1000 2000 3000 4000 5000 6000 7000-0.5

0

0.5

1

1.5

2

2.5

3

3.5

Time (ms)

Ang

le (r

adia

ns)

Pan Angle

Desired AngleActual Angle

Figure 14: Desired vs. Actual Pan Angle using Trapezoid Method

0 1000 2000 3000 4000 5000 6000 70000

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

Time (ms)

Ang

le (r

adia

ns)

Tilt Angle

Desired AngleActual Angle

Figure 15: Desired vs. Actual Tilt Angle using Trapezoid Method

Page 17: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

13

Figures 16 and 17 display the response of our simulation when following a circular trajectory.

100 200 300 400 500 600 700 800

0

0.2

0.4

0.6

0.8

1

Time (ms)

Ang

le (r

adia

ns)

Pan Angle

Desired AngleActual Angle

Figure 16: Desired vs. Actual Pan Angle for Circular Trajectory

50 100 150 200 250 300 350 400 450 500 550

-1

-0.5

0

0.5

1

Time (ms)

Ang

le (r

adia

ns)

Tilt Angle

Desired AngelActual Angel

Figure 17: Desired vs. Actual Tilt Angle for Circular Trajectory

Figures 14 through 17 represent the response of our system with a PD controller after some preliminary tuning. As can be seen from the figures both pan and tilt axes exhibit an overshoot in the beginning and a constant tracking error. The goal of the control design will be to provide a thorough analysis of how to reduce the overshoot and minimize the tracking error.

2.6.3 LabView Simulation In this section trajectory generation simulations are presented using the LabView Motion Assistant. The code used is shown in Appendix B. The maximum angular velocity, maximum angular acceleration and deceleration values are the same as those used for the Matlab

Page 18: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

14

simulation. Figures 18 and 19 display the position for a circular movement using the s-curve and trapezoidal methods. The desired angle is 90 degrees.

Figure 18: Position Profile using S-Curve

Figure 19: Position Profile using Trapezoidal Profile

Figures 20 and 21 display the position for a straight line trajectory using the trapezoidal and s-curve methods.

Figure 20: Position Profile using S-curve Method

Page 19: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

15

Figure 21: Position Profile using Trapezoidal Method

Using the encoder position profile, straight line and curved path trajectories will be followed. The encoder position profile will be fed into Labview, to operate the motors according to the desired positions. Figures 20 and 21 show the trapezoidal method results in a faster time for curved path than the s-curve method. For straight line motion the amount of time to arrive at the desired location is nearly identical. Encoder positions will be read using both the s-curve and trapezoidal methods. This will facilitate a comparison of trajectory generation methods, and will help in determining which is more efficient.

2.7 Image Processing This project requires that a figure be recognizable to the system. For this purpose a webcam is needed to acquire an image and process it. The image needs to be read into the system; then the points which the laser will follow must be extracted. Having not had any image processing background, it has been difficult to create the necessary program to do this. The first approach taken to find the points for tracing was to use a function that searched for lines, traveling from one side of the image to the other. In order to make sure only the image needed was being processed, a threshold would need to be used in order to eliminate shadows. The original image would be in black and white, a white background with a black image. Once each line was found an equation would be returned. Using this equation the endpoints of the line would be found and points along the line would be stored. This method, however, has been put aside for something better. Searching for lines is difficult when there are multiple lines parallel to each other and arcs in tangent to them. In order to find a different line, each line needs to be removed from the image once found. Doing this affects the shapes of lines in the vicinity of that being removed. Also, arcs interfere with the detected trajectory of the lines they are connected to and can be, in some cases, detected as lines themselves. These problems were not easily solved, so a new method was thought up. A threshold will still be used to remove any unwanted information in the beginning. Once the image is only what is needed, it will be searched through for a white pixel (threshold will cause the image to be inverted). After finding the first white pixel the pixels at a certain radius from the one found will be checked iteratively until the next white pixel is found. Assuming that there

Page 20: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

16

is a line, the next search will begin in the same direction that the first two pixels were pointing. If a white pixel is not found in this direction, the search will sweep in a clockwise direction until found. Since the image will have no breaks in it and no lines will cross each other, the search algorithm will traverse the whole perimeter and return to the beginning. Recording all the points along the way will yield the trajectory that must be followed by the laser. In order to make sure that each image has enough of a contrast between the background and the drawing a histogram will be used. After an image is taken, it will be passed through a histogram function and analyzed. If the image is found unworthy, it will be discarded. Another image will be taken and similarly processed. Once a final picture is approved it will be sent to the aforementioned function. This will cut down on certain noise problems with the camera and lighting. Once all the coordinates have been recorded these need to be converted into real world coordinates. The data stored on the program will be in pixel coordinates. In order to convert these to real world, the conversion from pixel to distance needs to be known. To find this out a ruler was placed at the distance predetermined to be the distance of the image from the camera. Two pieces of tape were placed on the ruler 4 inches apart. An image was then taken with the ruler in a vertical orientation, and one with the ruler in a horizontal orientation. The two images shown in figures 22 and 23 were used to then find how many pixels represented an inch at three feet away.

Figure 22: Vertical Image Calibration

Page 21: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

17

Figure 23: Horizontal Image Calibration

The two images captured are show here. The first image shows the ruler vertical, the second horizontal. The pieces of tape were found to be 48 pixels apart in each image. Dividing this number by 4 inches gives the conversion of 12 pixels per inch. With this information it is now possible to convert points in the image to points in the real world relative to the camera. With a resolution of 320 X 240 the figure size is limited further than anticipated. The figure can only extend 2’4” in the horizontal direction and 1’8” in the vertical direction. This is much smaller than the 3’ by 3’ figure proposed earlier.

Figure 24: Main Function for Path Finding

The main function to get all the points along the perimeter of the drawing is shown in Figure 24. This function takes a snap of a picture, gotten by the function labeled 1 in Figure 25, and sends it to the histogram function. Once through the histogram, the image is put through the threshold function which will get rid of random data. The image is then sent to function 3 which finds the starting point for the search; function 3 is shown in Figure 26. After the first coordinate is found

Page 22: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

18

the function searches for each next point until it returns to the beginning. The function for finding the next point is function 5 and is shown in Figure 27. After all coordinates are found they are output through a two dimensional array.

Figure 25: Image Subfunction 1

Function 1 takes care of getting an image from the USB camera. Looking at Figure 25, the first thing it does is create an image. It then initiates the camera, takes a picture, and closes the camera. The picture is placed in the image that was created earlier. Since, the camera takes a color picture, the image is then converted to black and white. This image is output to the main function.

Page 23: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

19

Figure 26: Image Subfunction 3

Function 3, shown in Figure 26, is used to find the first pixel that contains the figure. It searches linearly, left to right, top to bottom, until it comes to the first white pixel. Once this pixel is found, the coordinates are returned to the main function.

Figure 27: Image Subfunction 5

Page 24: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

20

Figure 27 shows function 5, which checks a pixel at a certain radius and angle from a given point. In the main function this is run in a while loop given various angles. Function 5 takes the angles and converts them into x and y distances. These are then multiplied by the radius, 5 in this version, and added to the coordinates of the center pixel. The pixel which is referenced by the new coordinate is checked for color. If the pixel is white a true value is returned to the main function; if it is black a false value is returned. When the main function receives a true value it knows to move on to the next point and save the coordinates of the point it just found.

2.8 Laser Control Because this machine is emulating a laser cutter, the laser must be able to turn on and off, to account for disturbances. If something were to push the laser off course, it would need to turn off or it would cut in the wrong place. A digital output is used to control the laser. One problem that occurred was the laser requires more amperage than the digital port can supply. To get around this, a relay was used. Power is taken from a 5V, 0.2A supply located in the bottom left of the control box. It is then wired through the relay to the laser. The relay is controlled by the digital out port. When a high signal is sent to the relay it connects the power to the laser, and when a low signal is sent it disconnects the power. In this way the laser can be easily turned on and off. The laser used is developed by Beam of Light Technologies; it is the ACC – 5 model. It uses a 4.5V power source at about 50mA. It is 26mm in length and 9mm in diameter. Its wavelength is 650nm. The digital port can output at most 2mA. This is why a relay is needed. The relay is made by NTE Electronics, Inc. and is model R40-11D2-5. This model takes a 5V input that activates two solenoids. Each solenoid activates a switch. When the solenoid is not activated its switch connects an input to one output. When activated it connects the input to another output. Each switch is capable of handling 2A, which is more than capable of dealing with the laser amperage.

Page 25: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

21

3.0 Summary of Progress

3.1 Plan The basic project plan remains the same for the controller design and trajectory generation, but has been modified for image processing. When the project was proposed, the level of difficulty involved in image processing was unforeseen, so that subsystem has been simplified to its core components of image acquisition and system calibration. Furthermore, the simulation of the system capability to follow trajectories has undergone a lot of progress. Next, an appropriate controller will be determined. And finally, implementation of the simulated trajectories and controllers will be done in LabView. With this plan in mind, the image tracing laser system should be ready for demonstration in four weeks.

3.2 Schedule The schedule up to this point has been fairly accurate, with the exception of image processing and the task of designing a physical setup. The initial thought of using the previous setup was promising, but most parts ended up being replaced. Now it is important to have a setup that can is more permanent and allows for repeatability. The work that still needs to be done with image processing is calibration. It is important to have good image quality so as to create an accurate trajectory. This will be done using the threshold functions to capture the outline of each image. This will also be important for zeroing the system. The use of a camera should greatly simplify this process. Becoming familiar with LabView and implementing our design on the system has gone according to plan. There is still the challenge of integrating all components of the design. As for trajectory generation, research and simulation of different trajectories is on schedule and nearly complete. See table 3 for a week by week schedule of the remaining tasks.

Page 26: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

22

Table 3: Schedule for Remaining Five Weeks Week/Month Tasks 4/3-4/7 Determine image processing

calibration to feed trajectory generation.

Build physical system i.e. mount laser, camera, drawing plane.

4/10-4/14 Finalize controller choice and fine tune parameters.

Implement trajectory, controller, and kinematics equations in LabView.

4/17-4/21

Finalize integration of calibration, trajectory, controller, and kinematics

Write demo script.

4/24-4/28 Demonstration (use of demo script) 4/25/2006

Write final report.

5/1-5/3 Final Report, Final Presentation and Lab Notebook due 5/3/2006

Prepare final presentation.

3.3 Cost The cost for developing the system has changed slightly since originally planned. This is in part to the ability of using the same laser and camera mount as Team 4 of 2005. A laser pointer and camera have been purchased along with miscellaneous electronic parts used for debugging and measuring voltage readings to the motors. The associated costs are shown in tables 4 and 5.

Table 4: Cost of Labor Team Hours Cost Total

Duarte, Jason (engineer) 250 $30/hr $7,500 Latif, Azmat (engineer) 250 $30/hr $7,500

Sundell, Stephen (engineer) 250 $30/hr $7,500 Weidner, Tim (engineer) 250 $30/hr $7,500

Total 1000 $30,000

Table 5: Cost of Additional Items. Additional Items Qty Cost Total Source

Laser pointer 1 $14.45 $14.45 Ebay USB camera 1 $18.98 $18.98 Ebay

Misc. electronics/parts $10.78 $10.78

Trojan Electronics

Total $44.21

Page 27: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

23

3.4 Unanticipated Challenges Several unanticipated challenges have come up during the testing and implementation of our system. One concern that came up was that the amps were not calibrated. This was then done by the group, and it was found difficult to obtain a correct Volt to Amperage conversion for the pan axis due to back EMF. This was remedied by removing the motor connection and then measuring the conversion factor. Another challenge related to the lab equipment is that the most frequently used system this design is being tested on appears to have a major glitch. The encoder readings are not functioning correctly. It is still undetermined whether this is an FPGA problem, an interference problem, or something else. Troubleshooting this problem will have to be tackled immediately. Also, the pan axis appears to have insufficient traction with the encoder. This too will take precedence with the aforementioned challenge. Additionally, since a lab-time schedule has been implemented, the difficulties with reserving lab space have yet to be determined. This will probably require meeting outside of class more often and having a more detailed plan of attack for each time in the lab. This is actually beneficial in itself, but coupled with one system out of commission might lead to less lab time for everyone. In the area of image processing, the initialization has proven more difficult than anticipated. This means that we will not be using the image as feedback in addition to encoder position and velocity. Since preliminary image processing work has been done, it is clear that we may have to adjust the distance to screen and image size specifications. Another challenge is the velocity estimation problem. After identifying the friction components, velocity estimation was implemented on the FPGA. An ideal sampling time will have to be determined in order to attain accurate velocity and acceleration feedback. If this proves too difficult, a washout filter is one option that may be implemented.

3.5 Forecast Considering the final weeks remaining of the semester, it is reasonable to assume the image tracing system will be completed on schedule. Solid progress on all fronts has been accomplished and mainly only the integration of the components of the design, along with controller testing and tuning remain. There will surely be other unexpected obstacles ahead, but the team is confident in reaching its objectives.

Page 28: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

24

4.0 Bibliography 1. NI Developer Zone, LabVIEW FPGA Module, ”Quadrature encoder velocity and acceleration estimation with CompactRIO and LabVIEW FPGA,” March 2006, http://zone.ni.com/devzone/conceptd.nsf/webmain/492D39D15D27C5DF86256F3B004B9C1D. 2. ECSE 4962 Control Systems Design, Meeting Slides, “Linearization script,” Spring 2003, http://www.cats.rpi.edu/%7Ewenj/ECSE4962S03/pantiltmodel.m.

Page 29: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

25

Appendix A: LabView code Velocity Estimation on FPGA

Page 30: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

26

Appendix A: LabView code Curved Path Simulation

Open Arc Move Handle

XY GraphX InputY Input

XY Graph

Instance 6 9Clipboard

Start Point

Move Constraints

Profile TypeProfile Calculation Constraint

3

3

Arc Move Properties

Straight Line Path Simulation

Open Straight Line Move Handle

X InputY Input

XY Graph

Instance 12

Start Point

Move Constraints

Profile TypeProfile Calculation Constraint

3

3

Straight Line Move Properties

Page 31: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

27

Appendix B: MATLAB code pantiltmodel.m % % Pan-Tilt Parameters % % body A (pan) IA11=0.001162; IA12=-5.938e-5; IA13=-7.951e-5; IA22=0.0007658; IA23=-0.0001269; IA33=0.0007469; IA=[IA11 IA12 IA13;IA12 IA22 IA23;IA13 IA23 IA33]; lcA1 = -0.0122;lcA2 = 0.0066;lcA3 = 0.0549; l1=-.1048; pA=[lcA1,lcA2,lcA3-l1]; mA=0.5507; % body B (tilt) IB11=.0003;IB12=-0.000;IB13=0.0;IB22=6.957e-5; IB23=-6.931e-6;IB33=0.0003041; IB=[IB11 IB12 IB13;IB12 IB22 IB23;IB13 IB23 IB33]; lcB1=0.0750;lcB2=0.0151;lcB3=0.0046; pB=[lcB1,lcB2,lcB3]; mB=0.2035; % assumed motor parameters Im1=2.3e-4; N1=6.3*2.8435; Im2=2.3e-4; N2=6.3*2.8435;

Page 32: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

28

Appendix B: MATLAB code pantilt_lin.m % % linearized pan-tilt system about theta=0 thetadot =26.565deg % % setup pan-tilt parameters pantiltmodel; % gravity g = 9.807; % get the linearized mass matrix theta1d=26.565*pi/180;theta2d=26.565*pi/180; M = massmatrix(mA,IA,pA,Im1,N1,mB,IB,pB,Im2,N2,theta1d,theta2d); % assume no friction for now d1=0.01; % viscuous friction for pan d2=0.01; % viscuous friction for tilt D = diag([d1 d2]); % get the linearized gravity term gradG=gravitylin(mA,IA,pA,Im1,N1,mB,IB,pB,Im2,N2,theta1d,theta2d); % define state space matrices A = [zeros(2,2) eye(2,2); -inv(M)*gradG -inv(M)*D]; B = [zeros(2,2) ; inv(M)]; C = [eye(2,2), zeros(2,2)]; D = zeros(2,2); G = ss(A,B,C,D); %disp('*** G ***'); %disp(['Open loop transfer function linearized about (',... % num2str([theta1d theta2d]),')']); %tf(G) G11=minreal(tf(G(1,1))) G22=minreal(tf(G(2,2)))

Page 33: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

29

Appendix B: MATLAB code S-Curve Method % Initialization file for Pan-Tilt Mechanism xf=pi;xo=0;vo=0;vf=0; vmax=24;amax=100;dmax=100; %vmax=5;amax=4;dmax=1; pa1=.20;pa2=.20; pb1=.15;pb2=.15; t=0; [x,v,a,ta,tb,tf]=scurvegen(xo,xf,vo,vf,vmax,amax,dmax,... pa1,pa2,pb1,pb2,t); %disp(['tf = ',num2str(tf)]); N=100; t=(0:tf/N:tf); for i=1:length(t) [x(i),v(i),a(i),ta,tb,tf]=scurvegen(xo,xf,vo,vf,vmax,amax,dmax,... pa1,pa2,pb1,pb2,t(i)); end title('s-curve'); subplot(3,1,1);plot(t,x);title('x'); title('s-curve'); subplot(3,1,2);plot(t,v);title('v'); subplot(3,1,3);plot(t,a);title('a'); t=t'; angle1=(x)'; angle2=(x/2)'; ts = 0.001; Kmtr = 0.01447; torque_sat = 500; theta1_start = 0.0; theta2_start = 0.0; thdot1_start = 0.0; thdot2_start = 0.0; % Define gravity constant g = 9.807; % acceleration due to gravity in m /(s^2) % Define Joint 1 Parameters N1 = 2.8435*6.3; % gear ratio Im1 = 2.3e-4; % inertia of joint in KG*m^2 as seen by encoder fv1 = 0.0009; % viscous friction for joint in NmS/Rad as seen by encoder fc1 = 0.0406; % coulomb friction for joint in Nm as seen by encoder

Page 34: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

30

% Define Joint 2 Parameters N2 = 2.8435*6.3; % gear ratio Im2 = 2.3e-4; % inertia of joint in KG*m^2 as seen by encoder fv2 = 0.00019; % viscous friction for joint in NmS/Rad as seen by encoder fc2 = 0.0584; % coulomb friction for joint in Nm as seen by encoder % Define Link A parameters mA = 0.5603; % mass of link A in Kg lcA1 = -0.0126; lcA2 = -0.0228; lcA3 = -0.0003; IA11 = 0.0012; IA12 = 0.0; IA13 = -0.0001; IA22 = 0.0007; IA23 = -0.0001; IA33 = 0.0008; % inertia of link 1 about CG in Kg*m^2 IA21=IA12;IA31=IA13;IA32=IA23; % Define Link B parameters mB = 0.3611; % mass of link B in Kg lcB1 = 0.0750; lcB2 = 0.0151; lcB3 = 0.0046; IB11 = 0.0003; IB12 = -0.0001; IB13 = 0.0; IB22 = 0.0006; IB23 = 0.0; IB33 = 0.0007; % inertia of link 1 about CG in Kg*m^2 IB21=IB12;IB31=IB13;IB32=IB23; % PID gains kp1 = 2.0; kd1 = 10; kp2 = 2; kd2 = 5; ki1 = 0; ki2 = 0; p=50;

Page 35: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

31

Appendix B: MATLAB code Trapezoidal Method % Initialization file for Pan-Tilt Mechanism %trapezoid xf=pi;xo=0;vo=0;vf=0; vmax=24;amax=100;dmax=100; [x,v,a,ta,tb,tf]=trapgen(xo,xf,vo,vf,vmax,amax,dmax,0); %disp(['tf = ',num2str(tf)]); N=600; t=(0:tf/N:tf); for i=1:length(t); [x(i),v(i),a(i),ta,tb,tf]=trapgen(xo,xf,vo,vf,vmax,amax,dmax,t(i)); end subplot(3,1,1);plot(t,x);title('x'); title('trapezoid'); subplot(3,1,2);plot(t,v);title('v'); subplot(3,1,3);plot(t,a);title('a'); t=t'; angle1=(x)'; angle2=(x/2)'; ts = 0.001; Kmtr = 0.01447; torque_sat = 500; theta1_start = 0.0; theta2_start = 0.0; thdot1_start = 0.0; thdot2_start = 0.0; % Define gravity constant g = 9.807; % acceleration due to gravity in m /(s^2) % Define Joint 1 Parameters N1 = 2.8435*6.3; % gear ratio Im1 = 2.3e-4; % inertia of joint in KG*m^2 as seen by encoder fv1 = 0.0009; % viscous friction for joint in NmS/Rad as seen by encoder fc1 = 0.0406; % coulomb friction for joint in Nm as seen by encoder % Define Joint 2 Parameters N2 = 2.8435*6.3; % gear ratio Im2 = 2.3e-4; % inertia of joint in KG*m^2 as seen by encoder fv2 = 0.00019; % viscous friction for joint in NmS/Rad as seen by encoder fc2 = 0.0584; % coulomb friction for joint in Nm as seen by encoder % Define Link A parameters mA = 0.5603; % mass of link A in Kg lcA1 = -0.0126;

Page 36: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

32

lcA2 = -0.0228; lcA3 = -0.0003; IA11 = 0.0012; IA12 = 0.0; IA13 = -0.0001; IA22 = 0.0007; IA23 = -0.0001; IA33 = 0.0008; % inertia of link 1 about CG in Kg*m^2 IA21=IA12;IA31=IA13;IA32=IA23; % Define Link B parameters mB = 0.3611; % mass of link B in Kg lcB1 = 0.0750; lcB2 = 0.0151; lcB3 = 0.0046; IB11 = 0.0003; IB12 = -0.0001; IB13 = 0.0; IB22 = 0.0006; IB23 = 0.0; IB33 = 0.0007; % inertia of link 1 about CG in Kg*m^2 IB21=IB12;IB31=IB13;IB32=IB23; % PID gains kp1 = 2.0; kd1 = 10; kp2 = 2; kd2 = 5; ki1 = 0; ki2 = 0; p=50;

Page 37: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

33

Appendix C: Simulink Model to test trajectory/controller desired vs. actual

Pan Tilt Nonlinear Simulation

muxdemux

angle1 (desired)angle1(output)

angle2(output)

angle2(desired)

y error scope

y

output

angle2

angle1

Zero-OrderHold

simout1

To Workspace1

simout

To Workspace

Quantizer

tau theta

Pan-tilt dynamicsIn1 Out1

PID 2

In1 Out1

PID 1[t angle1 angle2]

FromWorkspace

Demux

Page 38: IMAGE TRACING LASER SYSTEM - RPIcats-fs.rpi.edu/~wenj/ECSE446S06/team4progressreport.pdf · This report describes the progress made in building an image tracing laser system using

34

Statement of Contribution While specific subsections were written individually as shown below, all team members contributed equally in the completion of this report. Jason Duarte _____________________________________ - Friction Identification - Linear Model - Controller Design - Cost - Forecast Azmat Latif ______________________________________ - Introduction - Trajectory Generation - Matlab - LabView Stephen Sundell ___________________________________ - Image Processing - Laser Control - Trajectory Generation (LabView) Tim Weidner ______________________________________ - Executive Summary - Nonlinear Model - Velocity Estimation - Plan - Schedule - Unanticipated Challenges - Report Organization