by Roberto Lot > restart: libname := libname, "C:/libs/MBSymba.mla": with(MBSymba_r6):

### Vector Loop

definition of he vectors

> AB := make_VECTOR(rotate('Z',q),a1,0,0): show(AB); crank

> BC := make_VECTOR(rotate('Z',theta2),a2,0,0): show(BC); coupler

> DC := make_VECTOR(rotate('Z',theta3),a3,0,0): show(DC); rocker     closing the vector loop: definition of a closure vector

> closure := AD + DC - BC - AB: show(closure); this expression must be null

> phi := {comp_X(closure) , comp_Y(closure) }; find the solution with respect to the variables theta andtheta which depend on the generalized coordinate q(rotation of the crank)

> solve(phi, {theta2,theta3} ):

select one solution

> solution := allvalues(%):

extract the solutions

> theta2 := subs(solution,theta2);                > theta3 := subs(solution,theta3);               ## Numerical Solution

numerical results for specified length [m]
a1 = crank length
a2 = coupler length
a3 = rocker length

> dataset := [a1=0.1, a2=0.4, a3=0.25, a4=0.30 ]; crank, coupler and rocker
num_sol := subs(dataset, solution):

> interface(displayprecision=3): coupler angle against crank angle

> theta2 := subs(dataset, theta2);

> plot(theta2, q=0..2*Pi, labels=[q, "[rad]"], title="theta2 vs. q");     rocker angle against crank angle

> theta3 := subs(dataset, theta3);

> plot(theta3, q=0..2*Pi, labels=[q, "[rad]"], title="theta3 vs. q");    ### Animation of the Mechanism

Plot of the mechanism

> A := origin(ground):

> B := A + AB: #show(B);

> C := B + BC:# show(C);

> D2 := A + AD:# show(D2); Note: Maple reserves D for differential operator

> with(plots):with(plottools):

##Generate frames for the animation

> N:=10; ##number of steps
for n from 0 to N-1 do

> q := evalf(Pi*n/N);

crank AB

> crank ||n := plot( {subs(dataset,[ [comp_X(A)+0.01*cos(q),comp_Y(A)+0.01*sin(q)], [comp_X(B),comp_Y(B)] ])}, color=black, thickness=3);
coupler BC

> coupler ||n := plot( {subs(dataset,[ [comp_X(B),comp_Y(B)], [comp_X(C),comp_Y(C)] ])}, color=black, thickness=3);
rocker DC

> rocker ||n := plot( {subs(dataset,[ [comp_X(C),comp_Y(C)], [comp_X(D2),comp_Y(D2)] ])}, color=black, thickness=3):
revolute joints

> revj_A ||n := disk( subs(dataset,[comp_X(A), comp_Y(A)]), 0.01, color=yellow);

> revj_B ||n := disk( subs(dataset,[comp_X(B), comp_Y(B)]), 0.01, color=yellow);

> revj_C ||n := disk( subs(dataset,[comp_X(C), comp_Y(C)]), 0.01, color=yellow);

> revj_D ||n := disk( subs(dataset,[comp_X(D2),comp_Y(D2)]),0.01, color=yellow);
mechanism

> four_bar||n := display ( {crank||n, coupler||n, rocker||n
,revj_A||n, revj_B||n, revj_C||n, revj_D ||n
});

> end:

Display the animation

> display([ four_bar||(0..N-1)], insequence=true, scaling=constrained);  