Synthesis of a Lamp Mechanism - Daniel...

16
1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms and Mechanical Systems Spring 2011 Daniel Nguyen Instructor: S. Jain University of California, Los Angeles Henry Samueli School of Engineering and Applied Science May 31, 2011

Transcript of Synthesis of a Lamp Mechanism - Daniel...

Page 1: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

1

Synthesis of a Lamp Mechanism

MAE 162A – Introduction to Mechanisms and Mechanical Systems

Spring 2011

Daniel Nguyen

Instructor: S. Jain

University of California, Los Angeles

Henry Samueli School of Engineering and Applied Science

May 31, 2011

Page 2: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

Daniel Nguyen May 31, 2011

2

Abstract

The purpose of this project was to design a lamp mechanism as shown in figure 1 so that point A

moves as follows: (1) it has to travel at least 600 mm horizontally, (2) it cannot displace more

than 5 cm in the vertical direction, (3) it has to be at least 1 m from the wall while the lamp is in

its fully extended position, and (4) it cannot be more than 400 mm from the wall in its closed

position. Furthermore, the lamp has to fit into a 1.5 by 1.5 m box in both its closed and fully

extended positions. Lastly, no links can be below point A at anytime and the lamp cannot rotate

more than 1° while the mechanism is in motion. In order to accomplish these requirements,

MATLAB was used as an aid to optimize the link lengths and generate plots of the preliminary

mechanism to certify that the results were satisfactory. After that, a CAD model of the finished

design was made to simulate the motion of the mechanism. Ultimately, the mechanism satisfied

all of the requirements.

Figure 1 – Lamp mechanism to be created

List of Symbols

• MATLAB – Matrix Laboratory

• CAD – Computer Aided Design

• A.x – Appendix, section x

Page 3: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

3

1. Introduction

This report describes the theory and process of synthesizing a mechanism. The lamp mechanism

to be created has six links, including the ground link, which requires two loop closure equations

expressed as vectors to make certain that the geometry is exact. Since none of the links’ lengths

were given, trial-and-error had to be used with the help of MATLAB’s fsolve function. Plots

of the links were created for the preliminary design until a final mechanism satisfied all of the

requirements. Finally, the final design was created with SolidWorks to verify that it functioned

properly.

2. Background

To synthesize the lamp, the links have to be expressed as vectors to give them directions and

magnitudes. Then, two loop closures can be formed by inspection. Due to the shear number of

unknowns, the two trapezoidal loops have to be broken into four triangular loops so that the links

are constrained properly among each other. Then, geometric relationships can be used to

generate positions for the joints relative to an arbitrary coordinate system. A couple of scripts can

be created in MATLAB to verify that the joints are constrained properly using the fsolve

function since the trigonometric functions in the relationships are nonlinear. After the testing was

done, the final model was created with SolidWorks to simulate the lamp’s motion.

3. Analysis and Synthesis Details

The lamp assembly is given below in figure 2 for the lamp assembly in the problem statement.

Here, R0 is the ground link and the rest of the links are labeled corresponding to their respective

links in figure 1. An arbitrary coordinate system is also shown.

Page 4: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

4

Figure 2 – Lamp assembly with linkages expressed as vectors

Two loop closure equations are needed to synthesize the mechanism. The first loop is given

below in figure 3:

Figure 3 – Loop 1 of lamp assembly

The loop closure equation for the solid lines is expressed as

R1 +R4 −

R3 +R0 = 0 (1)

In complex algebra form:

ae jθ1 + ce jθ4 − r3ejθ3 + r0e

jθ0 = 0 (2)

Separating the real and imaginary parts:

Real: Imaginary:

acosθ1 + ccosθ4 − r3 cosθ3 + r0 cosθ0 = 0 asinθ1 + csinθ4 − r3 sinθ3 + r0 sinθ0 = 0

(3) (4)

R3  

R0  

R2  

R4  

R1  

x

y

c

r0 r3

θ3  

θ4  

1 2

A B

C

D

E

F

G R5  

A

D

B

E θ0  

a θ1   θAE  

Page 5: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

5

Equations 3 and 4 can generally be used when two unknown values have to be solved for, but

additional relations are needed since there are more than two unknown values. Using the

Pythagorean theorem, and Laws of sine and cosine, the following relations are obtained for the

two triangular loops separated by the dashed line in figure 3:

r0 = (Dx − Ax )2 + (Ay −Dy )

2 (5)

θ0 =180°− arctan

Ay −Dy

Dx − Ax

(6)

Ex = Dx + r3 cosθ3 (7)

Ey = Dy + r3 sinθ3 (8)

RAE = ro2 + r3

2 − 2r0r3 cos(θ0 −θ3) (9)

θAE =180°+θ3 − arcsin

r0 sin(θ0 −θ3)RAE

(10)

θ4 =θAE − arccos

RAE2 + c2 − a2

2aRAE

(11)

θ1 =θAE −180°+ arccos

a2 + RAE2 − c2

2aRAE

(12)

Bx = Ax + acosθ1 (13)

By = Ay + asinθ1 (14)

Equations (5) to (14) were inputted into the Lamp.m function file (see A.2).

Page 6: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

6

The second loop is given below in figure 4:

Figure 4 – Loop 2 of lamp assembly

The loop closure equation for the solid lines is expressed as

R1 +R2 −

R5 −R4 = 0 (15)

In complex algebra form:

be jθ1 + r2ejθ2 − r5e

jθ5 − (c+ d)e jθ4 = 0 (16)

Separating the real and imaginary parts:

Real: Imaginary:

bcosθ1 + r2 cosθ2 − r5 cosθ5 − (c+ d)cosθ4 = 0 bsinθ1 + r2 sinθ2 − r5 sinθ5 − (c+ d)sinθ4 = 0

(17) (18)

Using the Pythagorean theorem, and Laws of sine and cosine, the following relations are

obtained for the two loops separated by the dashed line in figure 4:

Cx = Ax + (a+ b)cosθ1 (19)

Cy = Ay + (a+ b)sinθ1 (20)

Fx = Bx − (c+ d)cosθ4 (21)

Fy = By − (c+ d)cosθ4 (22)

RFC = b2 + (c+ d)2 − 2b(c+ d)cos(180−θ4 +θ1) (23)

c + d

r2

r5

b θ4  

θ5  

θ2  

θ1  B

C

G

F θFC  

Page 7: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

7

θFC =180− arctanCy −FyFx −Cx

(24)

θ2 =180+θ5 − arccosr52 + r2

2 − RFC2

2r2r5 (25)

Gx = Fx + r5 cosθ5 (26)

Gy = Fy + r5 sinθ5 (27)

Equations (19) to (27) were inputted into the Lamp.m (A.2) function file. The values Ax, Ay, Dx,

Dy, a+b, r2, r3, c+d, r5, c, a, and θ3 are used in the guess matrix for Main.m (see A.1). Three

additional input angles—θ3a, θ3b, and θ3c—are included in the guess matrix to perturb the links.

Then, the fsolve function was used to call Lamp.m to determine the optimum values of the

guesses. In order to choose the initial guesses, the mechanism was drawn to scale on graph paper

inside a 1.5 by 1.5 m box while in its closed position ensuring that none of the links are no more

than 0.4 m from the wall. The vertical and angular deviation of point A can be found using the

positional information for link 5 since they are connected to each other. In order to accomplish

this, two for loops were created to run through specified angles and log the positional

information of link 5. Then the differences between the final and initial angles/displacements

were plotted. The succeeding guesses (see A.3) got complicated since the lengths of the links had

to be the right size or else MATLAB would return an error saying that the argument inside the

cosine argument was unreal because the joints could not be connected properly and fsolve

could not solve the equations since the joints were too far off. By observing the plots, the link

lengths were either shortened or lengthened until the mechanism was able to stay near the 0.4 m

mark in its closed position and outside the 1 m mark in its extended position. Simultaneously, the

vertical and angular deviation of link 5 had to be kept track of to check that the requirements are

met.

Page 8: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

8

4. Results and Discussion

The final guess parameters used for the final design are given in A.4 and the lengths of the links

are given in Table 1. Figure 5 shows that the mechanism isn’t behind the 0.4 m mark in its closed

position due to the maximum input angle of θ3 = 80° that could be used in MATLAB or else it

would return an error. The CAD model of the mechanism in figure 6 reassures that point A is

less than 0.4 m from the wall in its closed configuration.

Table 1 – Resulting values of parameters for the designed mechanism Link Name Joint 1 Joint 2 Length (mm)

R1 A C 392.1734 R2 C G 1337.1151 R3 D E 708.0000 R4 B F 1352.6028 R5 G F 103.2434

Figure 5 – Diagram of 6 bar linkage showing that the entire mechanism fits inside a 1.5 m by 1.5 m box. Fully extended configuration, two intermediate configuration, and fully

collapsed configuration are shown.

Page 9: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

9

Figure 6 – Actual closed configuration.

Figure 5 also shows that the mechanism still fits in the box in its fully extended position, which

can be verified by the CAD model in figure 7.

Figure 7 – Actual opened configuration.

Page 10: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

10

The vertical and angular displacements of point G are given in figures 8 and 9, respectively.

Point A and the lamp travel with point G, which was why G was of importance with little need to

write a separate vector equation for point A.

Figure 8 – Trajectory of point G as a function of input angle θ3.

Figure 9 – Rotation of the lamp head as a function of input angle θ3.

Page 11: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

11

Table 2 – Compliance to the requirements Requirement Specified Achieved Units

X Displacement More than 600 938.38 mm Y Displacement Less than 50 < 9 mm

Rotation Less than 1 < 0.4 degrees Collapsed Config. Less than 1500 1443.69 mm

Fully Extended Less than 1500 1300.23 mm

Table 2 summarizes the motion of the mechanism. In the final analysis, this mechanism

exceeded all of the requirements.

5. Conclusions

One possible design of a lamp mechanism was created to meet all of the requirements. Although

the plots generated by MATLAB showed that the lamp could not be less than 0.4 m away from

the wall, the CAD model verified that it could be done by manually rotating the input link.

Supplementary MATLAB coding or repairing of the code would be needed for a broader range

of input angles to completely justify whether the lamp design was adequate or not. Several lines

of code for a rough lamp head and point A would add value to the plots in figure 5.

Acknowledgement

Special thanks to Alex Riggs who assisted me on the MATLAB scripts.

References

Jain, S., Position and Displacement in Mechanism Notes. Los Angeles, CA, 2011.

Uicker Jr., J.J., Pennock, G.R., and Shigley, J.E., Theory of Machines and Mechanisms, 4th ed., Oxford University Press, New York, 2011.

Page 12: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

12

Appendices

A.1 | Main.m Inputs guesses in the matrix x0 = [Ax Ay Dx Dy R1 R2 R3 R4 R5 BE AB θ3 θ3a θ3b θ3c] and calls Lamp.m to store and calculate positional information using the fsolve command. Then it plots and saves four different positions of the mechanism, and the vertical and angular displacements of point G. clc; clear all; close all; x0 = [0 1.1 0.09 0.38 0.4 1.34 0.7 1.35 0.1 0.35 0.36 50 60 70 80]; options=optimset('Display','iter'); [x,fval] = fsolve(@Lamp,x0,options) Ax=x(1); Ay=x(2); Dx=x(3); Dy=x(4); R1=x(5); R2=x(6); R3=x(7); R4=x(8); R5=x(9); BE=x(10); AB=x(11); Th3=x(12); Th3a=x(13); Th3b=x(14); Th3c=x(15); % Ref Position R0=sqrt((Dx-Ax)^2+(Ay-Dy)^2); Th0=180-atand((Ay-Dy)/(Dx-Ax)); Ex=Dx+R3*cosd(Th3); Ey=Dy+R3*sind(Th3); AE=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3)); ThAE=180+Th3-asind((R0*sind(Th0-Th3)/AE)); Th4=ThAE-acosd((AE^2+BE^2-AB^2)/(2*AE*BE)); Th1=ThAE-180+acosd((AB^2+AE^2-BE^2)/(2*AB*AE)); Bx=Ax+AB*cosd(Th1); By=Ay+AB*sind(Th1); Cx=Ax+R1*cosd(Th1); Cy=Ay+R1*sind(Th1); Fx=Bx-R4*cosd(Th4); Fy=By-R4*sind(Th4); FC=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4+Th1)); ThFC=180-atand((Cy-Fy)/(Fx-Cx)); Th5=ThFC-acosd((FC^2+R5^2-R2^2)/(2*FC*R5)); Th2=180+Th5-acosd((R5^2+R2^2-FC^2)/(2*R5*R2)); Gx=Fx+R5*cosd(Th5); Gy=Fy+R5*sind(Th5); % Position 1 Exa=Dx+R3*cosd(Th3a); Eya=Dy+R3*sind(Th3a); AEa=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3a)); ThAEa=180+Th3a-asind((R0*sind(Th0-Th3a)/AEa)); Th4a=ThAEa-acosd((AEa^2+BE^2-AB^2)/(2*AEa*BE)); Th1a=ThAEa-180+acosd((AB^2+AEa^2-BE^2)/(2*AB*AEa)); Bxa=Ax+AB*cosd(Th1a); Bya=Ay+AB*sind(Th1a); Cxa=Ax+R1*cosd(Th1a); Cya=Ay+R1*sind(Th1a); Fxa=Bxa-R4*cosd(Th4a); Fya=Bya-R4*sind(Th4a); FCa=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4a+Th1a)); ThFCa=180-atand((Cya-Fya)/(Fxa-Cxa));

Page 13: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

13

Th5a=ThFCa-acosd((FCa^2+R5^2-R2^2)/(2*FCa*R5)); Th2a=180+Th5a-acosd((R5^2+R2^2-FCa^2)/(2*R5*R2)); Gxa=Fxa+R5*cosd(Th5a); Gya=Fya+R5*sind(Th5a); % Position 2 Exb=Dx+R3*cosd(Th3b); Eyb=Dy+R3*sind(Th3b); AEb=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3b)); ThAEb=180+Th3b-asind((R0*sind(Th0-Th3b)/AEb)); Th4b=ThAEb-acosd((AEb^2+BE^2-AB^2)/(2*AEb*BE)); Th1b=ThAEb-180+acosd((AB^2+AEb^2-BE^2)/(2*AB*AEb)); Bxb=Ax+AB*cosd(Th1b); Byb=Ay+AB*sind(Th1b); Cxb=Ax+R1*cosd(Th1b); Cyb=Ay+R1*sind(Th1b); Fxb=Bxb-R4*cosd(Th4b); Fyb=Byb-R4*sind(Th4b); FCb=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4b+Th1b)); ThFCb=180-atand((Cyb-Fyb)/(Fxb-Cxb)); Th5b=ThFCb-acosd((FCb^2+R5^2-R2^2)/(2*FCb*R5)); Th2b=180+Th5b-acosd((R5^2+R2^2-FCb^2)/(2*R5*R2)); Gxb=Fxb+R5*cosd(Th5b); Gyb=Fyb+R5*sind(Th5b); % Closed Position Exc=Dx+R3*cosd(Th3c); Eyc=Dy+R3*sind(Th3c); AEc=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3c)); ThAEc=180+Th3c-asind((R0*sind(Th0-Th3c)/AEc)); Th4c=ThAEc-acosd((AEc^2+BE^2-AB^2)/(2*AEc*BE)); Th1c=ThAEc-180+acosd((AB^2+AEc^2-BE^2)/(2*AB*AEc)); Bxc=Ax+AB*cosd(Th1c); Byc=Ay+AB*sind(Th1c); Cxc=Ax+R1*cosd(Th1c); Cyc=Ay+R1*sind(Th1c); Fxc=Bxc-R4*cosd(Th4c); Fyc=Byc-R4*sind(Th4c); FCc=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4c+Th1c)); ThFCc=180-atand((Cyc-Fyc)/(Fxc-Cxc)); Th5c=ThFCc-acosd((FCc^2+R5^2-R2^2)/(2*FCc*R5)); Th2c=180+Th5c-acosd((R5^2+R2^2-FCc^2)/(2*R5*R2)); Gxc=Fxc+R5*cosd(Th5c); Gyc=Fyc+R5*sind(Th5c); figure(1) subplot(1,4,1) plot(Ax,Ay,'r^',Bx,By,'ro',Cx,Cy,'ro',Dx,Dy,'r^',Ex,Ey,'ro',Fx,Fy,'ro','LineWidth',2); plot([Ax Bx],[Ay By],'r',[Bx Cx],[By Cy],'r',[Dx Ex],[Dy Ey],'b',[Bx Ex],[By Ey],'k',[Cx Gx],[Cy Gy],'g',[Ex Fx],[Ey Fy],'k',[Fx Gx],[Fy Gy],'y','LineWidth',2); title('Extended Position') xlabel('Distance (m)') ylabel('Height (m)') axis([0 1.5 0 1.5]) grid on subplot(1,4,2) plot(Ax,Ay,'r^',Bxa,Bya,'ro',Cxa,Cya,'ro',Dx,Dy,'r^',Exa,Eya,'ro',Fxa,Fya,'ro','LineWidth',2); plot([Ax Bxa],[Ay Bya],'r',[Bxa Cxa],[Bya Cya],'r',[Dx Exa],[Dy Eya],'b',[Bxa Exa],[Bya Eya],'k',[Cxa Gxa],[Cya Gya],'g',[Exa Fxa],[Eya Fya],'k',[Fxa Gxa],[Fya Gya],'y','LineWidth',2); title('Position 1') xlabel('Distance (m)') ylabel('Height (m)') axis([0 1.5 0 1.5]) grid on subplot(1,4,3) plot(Ax,Ay,'r^',Bxb,Byb,'ro',Cxb,Cyb,'ro',Dx,Dy,'r^',Exb,Eyb,'ro',Fxb,Fyb,'ro','LineWidth',2); plot([Ax Bxb],[Ay Byb],'r',[Bxb Cxb],[Byb Cyb],'r',[Dx Exb],[Dy Eyb],'b',[Bxb Exb],[Byb Eyb],'k',[Cxb Gxb],[Cyb Gyb],'g',[Exb Fxb],[Eyb Fyb],'k',[Fxb Gxb],[Fyb Gyb],'y','LineWidth',2); title('Position 2') xlabel('Distance (m)') ylabel('Height (m)') axis([0 1.5 0 1.5]) grid on

Page 14: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

14

subplot(1,4,4) plot(Ax,Ay,'r^',Bxc,Byc,'ro',Cxc,Cyc,'ro',Dx,Dy,'r^',Exc,Eyc,'ro',Fxc,Fyc,'ro','LineWidth',2); plot([Ax Bxc],[Ay Byc],'r',[Bxc Cxc],[Byc Cyc],'r',[Dx Exc],[Dy Eyc],'b',[Bxc Exc],[Byc Eyc],'k',[Cxc Gxc],[Cyc Gyc],'g',[Exc Fxc],[Eyc Fyc],'k',[Fxc Gxc],[Fyc Gyc],'y','LineWidth',2); title('Closed Position') xlabel('Distance (m)') ylabel('Height (m)') axis([0 1.5 0 1.5]) grid on print('-dpng',[pwd,'\plots\figure',num2str(1),'.png']); % Angular and Vertical Deviation Th3d=[50:0.1:80]; for i=1:301 R0=sqrt((Dx-Ax)^2+(Ay-Dy)^2); Th0=180-atand((Ay-Dy)/(Dx-Ax)); Ex=Dx+R3*cosd(Th3d(i)); Ey=Dy+R3*sind(Th3d(i)); AE=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3d(i))); ThAE=180+Th3d(i)-asind((R0*sind(Th0-Th3d(i))/AE)); Th4=ThAE-acosd((AE^2+BE^2-AB^2)/(2*AE*BE)); Th1=ThAE-180+acosd((AB^2+AE^2-BE^2)/(2*AB*AE)); Bx=Ax+AB*cosd(Th1); By=Ay+AB*sind(Th1); Cx=Ax+R1*cosd(Th1); Cy=Ay+R1*sind(Th1); Fx=Bx-R4*cosd(Th4); Fy=By-R4*sind(Th4); FC=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4+Th1)); ThFC=180-atand((Cy-Fy)/(Fx-Cx)); Th5d(i)=ThFC-acosd((FC^2+R5^2-R2^2)/(2*FC*R5)); Th2=180+Th5d(i)-acosd((R5^2+R2^2-FC^2)/(2*R5*R2)); Gxd(i)=Fx+R5*cosd(Th5d(i)); Gyd(i)=Fy+R5*sind(Th5d(i)); end figure(2) subplot(1,2,1) plot(Th3d,abs(Gy-Gyd)*100,'LineWidth',2) title('Vertical Deviation') xlabel('Input Angle (degrees)') ylabel('Lamp Vertical Deviation (cm)') grid on subplot(1,2,2) plot(Th3d,abs(Th5-Th5d),'LineWidth',2) title('Angular Deviation') xlabel('Input Angle (degrees)') ylabel('Lamp Angle Deviation (degrees)') grid on print('-dpng',[pwd,'\plots\figure',num2str(2),'.png']); A.2 | Lamp.m Function file that stores and calculates the positions of the joints. A reference position and three other positions were coded to verify the guesses and make sure that the requirements were met. function F = Lamp(x) % Initial Guesses Ax=x(1); Ay=x(2); Dx=x(3); Dy=x(4); R1=x(5); R2=x(6); R3=x(7); R4=x(8); R5=x(9); BE=x(10); AB=x(11); Th3=x(12); Th3a=x(13);

Page 15: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

15

Th3b=x(14); Th3c=x(15); % Ref Position R0=sqrt((Dx-Ax)^2+(Ay-Dy)^2); Th0=180-atand((Ay-Dy)/(Dx-Ax)); Ex=Dx+R3*cosd(Th3); Ey=Dy+R3*sind(Th3); AE=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3)); ThAE=180+Th3-asind((R0*sind(Th0-Th3)/AE)); Th4=ThAE-acosd((AE^2+BE^2-AB^2)/(2*AE*BE)); Th1=ThAE-180+acosd((AB^2+AE^2-BE^2)/(2*AB*AE)); Bx=Ax+AB*cosd(Th1); By=Ay+AB*sind(Th1); Cx=Ax+R1*cosd(Th1); Cy=Ay+R1*sind(Th1); Fx=Bx-R4*cosd(Th4); Fy=By-R4*sind(Th4); FC=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4+Th1)); ThFC=180-atand((Cy-Fy)/(Fx-Cx)); Th5=ThFC-acosd((FC^2+R5^2-R2^2)/(2*FC*R5)); Th2=180+Th5-acosd((R5^2+R2^2-FC^2)/(2*R5*R2)); Gx=Fx+R5*cosd(Th5); Gy=Fy+R5*sind(Th5); % Position 1 Exa=Dx+R3*cosd(Th3a); Eya=Dy+R3*sind(Th3a); AEa=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3a)); ThAEa=180+Th3a-asind((R0*sind(Th0-Th3a)/AEa)); Th4a=ThAEa-acosd((AEa^2+BE^2-AB^2)/(2*AEa*BE)); Th1a=ThAEa-180+acosd((AB^2+AEa^2-BE^2)/(2*AB*AEa)); Bxa=Ax+AB*cosd(Th1a); Bya=Ay+AB*sind(Th1a); Cxa=Ax+R1*cosd(Th1a); Cya=Ay+R1*sind(Th1a); Fxa=Bxa-R4*cosd(Th4a); Fya=Bya-R4*sind(Th4a); FCa=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4a+Th1a)); ThFCa=180-atand((Cya-Fya)/(Fxa-Cxa)); Th5a=ThFCa-acosd((FCa^2+R5^2-R2^2)/(2*FCa*R5)); Th2a=180+Th5a-acosd((R5^2+R2^2-FCa^2)/(2*R5*R2)); Gxa=Fxa+R5*cosd(Th5a); Gya=Fya+R5*sind(Th5a); % Position B=2 Exb=Dx+R3*cosd(Th3b); Eyb=Dy+R3*sind(Th3b); AEb=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3b)); ThAEb=180+Th3b-asind((R0*sind(Th0-Th3b)/AEb)); Th4b=ThAEb-acosd((AEb^2+BE^2-AB^2)/(2*AEb*BE)); Th1b=ThAEb-180+acosd((AB^2+AEb^2-BE^2)/(2*AB*AEb)); Bxb=Ax+AB*cosd(Th1b); Byb=Ay+AB*sind(Th1b); Cxb=Ax+R1*cosd(Th1b); Cyb=Ay+R1*sind(Th1b); Fxb=Bxb-R4*cosd(Th4b); Fyb=Byb-R4*sind(Th4b); FCb=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4b+Th1b)); ThFCb=180-atand((Cyb-Fyb)/(Fxb-Cxb)); Th5b=ThFCb-acosd((FCb^2+R5^2-R2^2)/(2*FCb*R5)); Th2b=180+Th5b-acosd((R5^2+R2^2-FCb^2)/(2*R5*R2)); Gxb=Fxb+R5*cosd(Th5b); Gyb=Fyb+R5*sind(Th5b); % Closed Position Exc=Dx+R3*cosd(Th3c); Eyc=Dy+R3*sind(Th3c); AEc=sqrt(R0^2+R3^2-2*R0*R3*cosd(Th0-Th3c)); ThAEc=180+Th3c-asind((R0*sind(Th0-Th3c)/AEc)); Th4c=ThAEc-acosd((AEc^2+BE^2-AB^2)/(2*AEc*BE)); Th1c=ThAEc-180+acosd((AB^2+AEc^2-BE^2)/(2*AB*AEc)); Bxc=Ax+AB*cosd(Th1c);

Page 16: Synthesis of a Lamp Mechanism - Daniel Nguyendnguyenx21.bol.ucla.edu/assets/docs/Daniel_Nguyen_Lamp_Synthesis… · 1 Synthesis of a Lamp Mechanism MAE 162A – Introduction to Mechanisms

16

Byc=Ay+AB*sind(Th1c); Cxc=Ax+R1*cosd(Th1c); Cyc=Ay+R1*sind(Th1c); Fxc=Bxc-R4*cosd(Th4c); Fyc=Byc-R4*sind(Th4c); FCc=sqrt((R1-AB)^2+R4^2-2*(R1-AB)*R4*cosd(180-Th4c+Th1c)); ThFCc=180-atand((Cyc-Fyc)/(Fxc-Cxc)); Th5c=ThFCc-acosd((FCc^2+R5^2-R2^2)/(2*FCc*R5)); Th2c=180+Th5c-acosd((R5^2+R2^2-FCc^2)/(2*R5*R2)); Gxc=Fxc+R5*cosd(Th5c); Gyc=Fyc+R5*sind(Th5c); % Function Arrays F1 = abs(Gy-Gya)+abs(Gy-Gyb)+abs(Gy-Gyc); F2 = abs(Th5-Th5a)+abs(Th5-Th5b)+abs(Th5-Th5c); F = [F1 F2]; A.3 | Guesses Only values that returned solutions are listed. The numbers guessed for the final design are listed in the last row. Angles are in degrees.

Ax (m) Ay (m) Dx (m) Dy (m) r1 (m) r2 (m) r3 (m) r4 (m) r5 (m) c (m) a (m) θ3 θ3a θ3b θ3c

0 0.98 0.11 0.45 0.38 0.99 0.41 1.08 0.162 0.398 0.325 50 60 70 80 0 0.97 0.11 0.45 0.38 0.99 0.41 1.08 0.162 0.398 0.325 50 60 70 80 0 0.74 0.11 0.45 0.61 0.97 0.56 1.05 0.163 0.289 0.43 50 60 70 80 0 0.86 0.1 0.47 0.452 0.11 0.61 0.11 0.14 0.26 0.38 50 60 70 80 0 0.8 0.09 0.37 0.43 1.15 0.61 1.15 0.14 0.261 0.387 49 60 70 81 0 0.8 0.09 0.37 0.43 1.24 0.61 1.15 0.14 0.261 0.387 49 60 70 81 0 1.1 0.09 0.38 0.4 1.34 0.7 1.35 0.1 0.35 0.36 50 60 70 80 A.4 | Final Input and Output The guess matrix x0 is used for the final design and fsolve returned the matrix x with the exact measurements. Angles are in degrees.

Ax (mm)

Ay (mm)

Dx (mm)

Dy (mm)

r1 (mm)

r2 (mm)

r3 (mm)

r4 (mm)

r5 (mm)

c (mm)

a (mm) θ3 θ3a θ3b θ3c

x0 0.00 1100.00 90.00 380.00 400.00 1340.00 700.00 1350.00 100.00 350.00 360.00 50 60 70 80 x -3.06 1092.06 93.06 387.94 392.17 1337.12 708.00 1352.60 103.24 359.07 359.51 50 60 70 80