> restart: libname := libname, "C:/libs/MBSymba.mla": with(MBSymba_r6):
Vector loop
definition of the vectors
> AC := make_VECTOR(ground,a4,0,0): show(AC);
> AB := make_VECTOR(rotate('Z',theta),a1,0,0): show(AB);
> CB := make_VECTOR(rotate('Z',q),r,0,0): show(CB);
closing the vector loop: definition of a closure vector
> closure := AC + CB - AB: show(closure);
this expression must be null
> {comp_X(closure) , comp_Y(closure)};
## find the solution with respect to the variables a1and theta which depend on the generalized coordinate q(rotation of the crank)
> solve(%,{theta, a1}):
solution := allvalues(%);
select the positive solutions
> a1 := subs(solution[1],a1);
theta := subs(solution[1],theta);
Numerical Solution
numerical solution for specified crank and rod lengths:
> dataset := [a4=0.4, r=0.1, l=0.6];
> theta := subs(dataset, theta);
> a1 := subs(dataset,a1);
> a4 := subs(dataset,a4);
> l := subs(dataset,l);
Plot of the mechanism
> A := origin(ground): #show(A);
> B := A + AB: show(B): show(B);
> C := A + AC: show(C): show(C);
> plot(theta, q=0..2*Pi, labels=[q, "theta"], title="theta vs. q");
> plot(a1, q=0..2*Pi, labels=[q, "a1"], title="location of the slider on the rod vs. q");
Animation of the Mechanism
##Substitute in values for problem
> with(plots):with(plottools):
##Generate frames for the animation
> N:=15; ##number of steps
for n from 0 to N-1 do
q := evalf(2*Pi*n/N);
##crank
crank ||n := plot( {[ [comp_X(C)+0.01*cos(q),comp_Y(C)+0.01*sin(q)], [comp_X(B),comp_Y(B)] ]}, color=black, thickness=3 ):
##rod AD
rod ||n := plot( {[ [comp_X(A)+0.01*cos(theta),comp_Y(A)+0.01*sin(theta)], [l*cos(theta), l*sin(theta)] ]}, color=blue, thickness=3 ):
## pin joint A
revj_A ||n := disk( [comp_X(A),comp_Y(A)], 0.01, color=yellow );
## pin joint B
revj_B ||n := disk( [comp_X(B),comp_Y(B)], 0.01, color=grey );
## pin joint C
revj_C ||n := disk( [comp_X(C),comp_Y(C)], 0.01, color=yellow );
total
inverted_slider ||n := display ( {crank||n, revj_A||n, revj_B||n, revj_C||n} );
> end:
Display the animation
> display([inverted_slider||(0..N-1)], insequence=true, scaling=constrained);
>