back-matter - Appendix A Programs of Chapter 2: Position...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Appendix A Programs of Chapter 2: Position Analysis A.1 Slider-Crank (R-RRT) Mechanism %A 1 % Position analysis % R-RRT clear % clears all variables from the workspace clc % clears the command window and homes the cursor close all % closes all the open figure windows % Input data AB=0.5; BC=1; phi = pi/4; % Position of joint A (origin) x A=0 ;y A=0 ; % Position of joint B - position of the driver link x B=A B * cos(phi); y B=A B * sin(phi);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
302 A Programs of Chapter 2: Position Analysis % first component of the vector solC xC1=eval(solC(1)); % second component of the vector solC xC2=eval(solC(2)); % eval executes string as an expression or statement % Select the correct position for C % for the given input angle if xC1 > xB xC = xC1; else xC = xC2; end % if conditionally executes statements % Angle of the link 2 with the horizontal phi2 = atan((yB-yC)/(xB-xC)); fprintf(’Results \n\n’) % Print the coordinates of B fprintf(’xB = %g (m)\n’, xB) fprintf(’yB = %g (m)\n’, yB) % Print the coordinates of C fprintf(’xC = %g (m)\n’, xC) fprintf(’yC = %g (m)\n’, yC) % Print the angle phi2 fprintf(’phi2 = %g (degrees) \n’, phi2 * 180/pi) % Graphic of the mechanism plot([xA,xB],[yA,yB],’r-o’,. .. [xB,xC],[yB,yC],’b-o’),. .. xlabel(’x (m)’),. .. ylabel(’y (m)’),. .. title(’positions for \phi = 45 (deg)’),. .. text(xA,yA,’ A’),. .. text(xB,yB,’ B’),. .. text(xC,yC,’ C’),. .. axis([-0.2 1.4 -0.2 1.4]),. .. grid % the commas and ellipses (. ..) after the commands % were used to execute the commands together % end of program Results: xB = 0.353553 (m) yB = 0.353553 (m) xC = 1.28897 (m) yC = 0 (m) phi2 = -20.7048 (degrees)
Background image of page 2
A.2 Four-Bar (R-RRR) Mechanism 303 A.2 Four-Bar (R-RRR) Mechanism %A 2 % Position analysis % R-RRR clear all; clc; close all % Input data AB=0.15; %(m) BC=0.35; %(m) CD=0.30; %(m) CE=0.15; %(m) xD=0.30; %(m) yD=0.30; %(m) phi = pi/4 ; %(rad) x A=0 ;y A=0 ; rA = [xA yA 0]; rD = [xD yD 0]; x B=A B * cos(phi); yB = AB * sin(phi); rB = [xB yB 0]; % Position of joint C % Distance formula: BC=constant eqnC1 = ’(xCsol - xB)ˆ2 + (yCsol - yB)ˆ2 = BCˆ2 ’; % Distance formula: CD=constant eqnC2 = ’(xCsol - xD)ˆ2 + (yCsol - yD)ˆ2 = CDˆ2 ’; % Simultaneously solve above equations solC = solve(eqnC1, eqnC2, ’xCsol, yCsol’); % Two solutions for xC - vector form xCpositions = eval(solC.xCsol); % Two solutions for yC - vector form
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
304 A Programs of Chapter 2: Position Analysis % first component of the vector yCpositions yC1 = yCpositions(1);
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 177

back-matter - Appendix A Programs of Chapter 2: Position...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online