kinematics_slider_crank.mws

1.6 Example: Kinematics of the Slider Crank Mechanism

by Roberto Lot, Pasquale de Luca - date 20/04/04

         [Maple Plot]

>    restart: mylib :="G:\LIBS":  libname := mylib,libname: with(MBsymba):

Vector loop

definition of the vectors

>    AC := make_VECTOR(ground,c,0,0): show(AC);
>    AB := make_VECTOR(rotate('Z',q),r,0,0): show(AB);
>    BC := make_VECTOR(rotate('Z',-theta),l,0,0): show(BC); NOTE: theta is clockwise, so it requires the minus (-) sign.

AC = VECTOR(frame = matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),comps = matrix([[c], [0], [0], [0]]))

AB = VECTOR(frame = matrix([[cos(q), -sin(q), 0, 0], [sin(q), cos(q), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),comps = matrix([[r], [0], [0], [0]]))

BC = VECTOR(frame = matrix([[cos(theta), sin(theta), 0, 0], [-sin(theta), cos(theta), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),comps = matrix([[l], [0], [0], [0]]))

>    project(velocity(velocity(AB)),rotate('Z',q(t))): show(%);

VECTOR(frame = matrix([[cos(q(t)), -sin(q(t)), 0, 0], [sin(q(t)), cos(q(t)), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),comps = matrix([[-diff(q(t),t)^2*r], [diff(q(t),`$`(t,2))*r], [0], [0]]))

closing the vector loop: definition of a closure vector

>    closure := AC - BC - AB: show(closure);

closure = VECTOR(frame = matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),comps = matrix([[-cos(q)*r-cos(theta)*l+c], [-sin(q)*r+sin(theta)*l], [0], [0]]))

this expression must be null

>    {Xcomp(closure) , Ycomp(closure)};

we find the solution with respect to the variables c  and theta which depend on the generalized coordinate q  (rotation of the crank)
>    solution := solve(%,{theta,c});

{-sin(q)*r+sin(theta)*l, -cos(q)*r-cos(theta)*l+c}

solution := {theta = arcsin(sin(q)*r/l), c = cos(q)*r+sqrt(-(-l^2+sin(q)^2*r^2)/l^2)*l}

we extract the solutions

>    eval([theta, c], solution):
>    theta := %[1];
>    c := %%[2];

theta := arcsin(sin(q)*r/l)

c := cos(q)*r+sqrt(-(-l^2+sin(q)^2*r^2)/l^2)*l

anothe trick for univocally identify variables from solution set

>    c := subs(solution,c);
>    theta := subs(solution,theta);

c := cos(q)*r+sqrt(-(-l^2+sin(q)^2*r^2)/l^2)*l

theta := arcsin(sin(q)*r/l)

Numerical Solution

numerical solution for specified crank and rod lengths:
crank length r = 0.1 m
rod length l = 0.4 m

>    dataset := [r=0.1, l=0.4];

dataset := [r = .1, l = .4]

>    theta := subs(dataset, theta);
>    c := subs(dataset,c);
>    r := subs(dataset,r);
>    l := subs(dataset,l);

theta := arcsin(.2500000000*sin(q))

c := .1*cos(q)+.4*sqrt(1.000000000-.6250000000e-1*sin(q)^2)

r := .1

l := .4

Plot of the mechanism

>    A := origin(ground): #show(A);
>    B := A + AB: show(B): show(B);
>    C := A + AC: show(C): show(C);

B = POINT(frame = matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),coords = matrix([[.1000000000*cos(q)], [.1000000000*sin(q)], [0.], [1]]))

C = POINT(frame = matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]),coords = matrix([[c], [0], [0], [1]]))

>    vertex := [ [Xcomp(A),Ycomp(A)] , [Xcomp(B),Ycomp(B)] , [Xcomp(C),Ycomp(C)] ];

vertex := [[0, 0], [.1000000000*cos(q), .1000000000*sin(q)], [.1*cos(q)+.4*sqrt(1.000000000-.6250000000e-1*sin(q)^2), 0]]
vertex := [[0, 0], [.1000000000*cos(q), .1000000000*sin(q)], [.1*cos(q)+.4*sqrt(1.000000000-.6250000000e-1*sin(q)^2), 0]]

>    plot(theta, q=0..2*Pi, labels=[q, "theta"], title="theta vs. q");

[Maple Plot]

>    plot(c, q=0..2*Pi, labels=[q, "c"], title="location of the slider vs. q");

[Maple Plot]

Animation of the Mechanism

Substitute in values for problem

>    q:=2*Pi*t;
vertex;

q := 2*Pi*t

[[0, 0], [.1000000000*cos(2*Pi*t), .1000000000*sin(2*Pi*t)], [.1*cos(2*Pi*t)+.4*sqrt(1.000000000-.6250000000e-1*sin(2*Pi*t)^2), 0]]
[[0, 0], [.1000000000*cos(2*Pi*t), .1000000000*sin(2*Pi*t)], [.1*cos(2*Pi*t)+.4*sqrt(1.000000000-.6250000000e-1*sin(2*Pi*t)^2), 0]]

>    with(plots):
with(plottools):

Generate frames for the animation

>    for t from 0 to 29/30 by 1/30 do

     crank
  crank || (30*t) := plot(
  {[ [Xcomp(A)+0.01*cos(2*Pi*t),Ycomp(A)+0.01*sin(2*Pi*t)],                               [Xcomp(B)-0.01*cos(2*Pi*t),Ycomp(B)-0.01*sin(2*Pi*t)] ]
  }, color=black, thickness=3 ):

     connecting rod
  rod || (30*t) := plot(
  {[ [Xcomp(B)+0.01*cos(theta),Ycomp(B)-0.01*sin(theta)],
     [Xcomp(C)-0.01*cos(theta),Ycomp(C)+0.01*sin(theta)] ]
  }, color=black, thickness=3 ):

      the slider
  slider || (30*t) := rectangle(
  [Xcomp(C)-0.08/2, Ycomp(C)+0.02], [Xcomp(C)+0.08/2, Ycomp(C)-0.02], color=grey
  ):

      pin joints
      in A:

  revj_A || (30*t) := disk(  
  [Xcomp(A),Ycomp(A)], 0.01, color=yellow
  );
  
in B:
  revj_B || (30*t) := disk(  
  [Xcomp(B),Ycomp(B)], 0.01, color=yellow
  );

      in C:
      
revj_C || (30*t) := disk(  
  [Xcomp(C),Ycomp(C)], 0.01, color=yellow
  );

  
total
  total || (30*t) := display (
  {crank || (30*t), rod || (30*t), slider || (30*t), revj_A || (30*t), revj_B || (30*t),    revj_C || (30*t)}
  );
od:
t:='t';

Display the animation.

>    display([total || (0..29)], insequence=true, scaling=constrained);

[Maple Plot]