
## Example 3.2

The belt-transfer mechanism shown in the figure pushes boxes with a mass of 80 kg from one conveyor belt to another. The driving link rotates at a constant speed of $\omega_2=40~rpm$ counterclockwise. To carry out a complete kinematic and dynamic analysis of the mechanism, we will use all the analysis methods studied in this course. We will perform the analysis at the position given by $\theta_2 =350^{\circ }$. Compute the reaction forces and the motor torque needed to produce that motion.


<img src="./figs/ejemplo3_02_media/image_0.png" alt="ejemplo302a" width="520px">

```matlab
clear, clc
```
### Part 1: Velocity Analysis

For the velocity problem we first identify a four-bar sub-chain, and write the relative-velocity equation between points A and B:

 $ {\vec{v} }_B ={\vec{v} }_A +{\vec{v} }_{A/B} $ 

we see which terms are missing and work them out.


\- For ${\vec{v} }_B$:

 $ {\vec{v} }_B ={\vec{\omega} }_4 \times {\vec{r} }_{O4B} $ 
```matlab
% define the unknown w4k, the vector w4, rO4B, and finally express vB
syms w4k real
w4=[0 0 w4k];
rO4B=[1.174 2.761 0];
vB=cross(w4,rO4B);
```

\- For ${\vec{v} }_A$:

 $ {\vec{v} }_A ={\vec{\omega} }_2 \times {\vec{r} }_{O2A} $ 
```matlab
% define the vector w2, rO2A, and finally express vA
w2=[0 0 40*2*pi/60];
rO2A=[cosd(350) sind(350) 0];
vA=cross(w2,rO2A);
```

\- For ${\vec{v} }_{B/A}$:

 $ {\vec{v} }_{B/A} ={\vec{\omega} }_3 \times {\vec{r} }_{AB} $ 
```matlab
% define the unknown w3k, the vector w3, rAB, and finally express vB_A
syms w3k real
w3=[0 0 w3k];
rAB=[3.889 0.934 0];
vB_A=cross(w3,rAB);
```

Now we solve the equation:

```matlab
sol_v1 = solve(vB==vA+vB_A,w3k, w4k);
w3k = subs(sol_v1.w3k);
w4k = subs(sol_v1.w4k);
```

Next we analyze bar 5 and write the relative-velocity equation between points C and D:

 $ {\vec{v} }_D ={\vec{v} }_C +{\vec{v} }_{D/C} $ 

we see which terms are missing and work them out.


\- For ${\vec{v} }_D$:

 $ {\vec{v} }_D =v_D \hat{i} $ 
```matlab
% define the unknown vDi, the vector vD
syms vDi real
vD=[vDi 0 0];
```

\- For ${\vec{v} }_C$:

 $ {\vec{v} }_C ={\vec{\omega} }_4 \times {\vec{r} }_{O4C} $ 
```matlab
% Vector w4 is already known, and rO4C is obtained from GeoGebra: 
rO4C=[0.831 5.942 0];
vC=cross(w4,rO4C);
```

\- For ${\vec{v} }_{D/C}$:

 $ {\vec{v} }_{D/C} ={\vec{\omega} }_5 \times {\vec{r} }_{CD} $ 
```matlab
% define the unknown w5k, the vector w5, rCD, and finally express vD_C
syms w5k real
w5=[0 0 w5k];
rCD=[-6.431 -0.942 0];
vD_C=cross(w5,rCD);
```

Now we solve the equation:

```matlab
sol_v2 = solve(vD==vC+vD_C,w5k, vDi);
w5k = subs(sol_v2.w5k);
vDi = subs(sol_v2.vDi);
```
### Part 2: Acceleration Analysis
#### Accelerations of points A, B, C and D

For the acceleration problem we proceed in the same way, first between points A and B:

 $ {\vec{a} }_B ={\vec{a} }_A +{\vec{a} }_{A/B} $ 

which, decomposing, gives us:

 $ {\vec{a} }_B^n +{\vec{a} }_B^t ={\vec{a} }_A +{\vec{a} }_{A/B}^n +{\vec{a} }_{A/B}^t $ 

we see which terms are missing and work them out.


\- For ${\vec{a} }_B^n$:

 $ {\vec{a} }_B^n ={\vec{\omega} }_4 \times ({\vec{\omega} }_4 \times {\vec{r} }_{O4B} ) $ 
```matlab
% Express aBn
aBn=cross(w4,cross(w4,rO4B));
```

\- For ${\vec{a} }_B^t$:

 $ {\vec{a} }_B^t ={\vec{\alpha} }_4 \times {\vec{r} }_{O4B} $ 
```matlab
% define the unknown af4k, the vector af4, express aBt
syms af4k real
af4=[0 0 af4k];
aBt=cross(af4,rO4B);
```

\- For ${\vec{a} }_A$:

 $ {\vec{a} }_A ={\vec{a} }_A^n ={\vec{\omega} }_2 \times ({\vec{\omega} }_2 \times {\vec{r} }_{O2A} ) $ 
```matlab
% Express aA
aA=cross(w2,cross(w2,rO2A));
```

\- For ${\vec{a} }_{B/A}^n$:

 $ {\vec{a} }_{B/A}^n ={\vec{\omega} }_3 \times ({\vec{\omega} }_3 \times {\vec{r} }_{AB} ) $ 
```matlab
% Express aB_An
aB_An=cross(w3,cross(w3,rAB));
```

\- For ${\vec{a} }_{B/A}^t$:

 $ {\vec{a} }_{B/A}^t ={\vec{\alpha} }_3 \times {\vec{r} }_{AB} $ 
```matlab
% define the unknown af3k, the vector af3, express aB_At
syms af3k real
af3=[0 0 af3k];
aB_At=cross(af3,rAB);
```

Now we solve the equation:

```matlab
sol_ac1 = solve(aBn+aBt==aA+aB_An+aB_At,af3k, af4k);
% Display the solutions:
af3k = subs(sol_ac1.af3k);
af4k = subs(sol_ac1.af4k);
```

Next we analyze bar 5 and write the relative-acceleration equation between points C and D:

 $ {\vec{a} }_D ={\vec{a} }_C +{\vec{a} }_{D/C} $ 

decomposing:

 $ {\vec{a} }_D ={\vec{a} }_C^n +{\vec{a} }_C^t +{\vec{a} }_{D/C}^n +{\vec{a} }_{D/C}^t $ 

we see which terms are missing and work them out.


\- For ${\vec{a} }_D$:

 $ {\vec{a} }_D =a_D \hat{i} $ 
```matlab
syms aDi real
aD=[aDi 0 0];
```

\- For ${\vec{a} }_C^n$:

 $ {\vec{a} }_C^n ={\vec{\omega} }_4 \times ({\vec{\omega} }_4 \times {\vec{r} }_{O4C} ) $ 
```matlab
aCn=cross(w4,cross(w4,rO4C));
```

\- For ${\vec{a} }_C^t$:

 $ {\vec{a} }_C^t ={\vec{\alpha} }_4 \times {\vec{r} }_{O4C} $ 
```matlab
aCt=cross(af4,rO4C);
```

\- For ${\vec{a} }_{D/C}^n$:

 $ {\vec{a} }_{D/C}^n ={\vec{\omega} }_5 \times ({\vec{\omega} }_5 \times {\vec{r} }_{CD} ) $ 
```matlab
aD_Cn=cross(w5,cross(w5,rCD));
```

\- For ${\vec{a} }_{D/C}^t$:

 $ {\vec{a} }_{D/C}^t ={\vec{\alpha} }_5 \times {\vec{r} }_{CD} $ 
```matlab
syms af5k real
af5=[0 0 af5k];
aD_Ct=cross(af5,rCD);
```

Now we solve the equation:

```matlab
sol_ac2 = solve(aD==aCn+aCt+aD_Cn+aD_Ct,aDi, af5k);
aDi = subs(sol_ac2.aDi);
af5k = subs(sol_ac2.af5k);
```
#### Accelerations of the centers of gravity

\- For ${\vec{a} }_{G2} ={\vec{a} }_{G2}^n$ we need ${\vec{r} }_{O2G2}$:

```matlab
rO2G2=rO2A/2;
aG2=cross(w2,cross(w2,rO2G2));
```

\- For ${\vec{a} }_{G3} ={\vec{a} }_A +{\vec{a} }_{G3/A}^n +{\vec{a} }_{G3/A}^t$ we need ${\vec{r} }_{AG3}$:

```matlab
rAG3=rAB/2;
aG3=subs(aA+cross(w3,cross(w3,rAG3))+cross(af3,rAG3));
```

\- For ${\vec{a} }_{G4} ={\vec{a} }_{G4}^n +{\vec{a} }_{G4}^t$ we need ${\vec{r} }_{O4G4}$:

```matlab
rO4G4=[0.668 2.901 0];
aG4=subs(cross(w4,cross(w4,rO4G4))+cross(af4,rO4G4));
```

\- For ${\vec{a} }_{G5} ={\vec{a} }_C^n +{\vec{a} }_C^t +{\vec{a} }_{G5/C}^n +{\vec{a} }_{G5/C}^t$ we need ${\vec{r} }_{CG5}$:

```matlab
rCG5=rCD/2;
aG5=subs(aCn+aCt+cross(w5,cross(w5,rCG5))+cross(af5,rCG5));
```

\- For ${\vec{a} }_{G6} ={\vec{a} }_D$ it is enough to evaluate ${\vec{a} }_D$:

```matlab
aG6=subs(aD);
```
#### Part 3: Dynamics Applying D'Alembert's Principle

In this part we will compute the reaction forces and the motor torque from the static equilibrium of each body making up the mechanism, including the inertia forces and moments according to D'Alembert's principle. Masses (in kg) and inertias (in kg·m², about the center of mass): $m_2=15.31$, $m_3=61.26$, $m_4=154.75$, $m_5=99.54$, $m_6=85$, $I_2=1.278$, $I_3=81.68$, $I_4=495.76$, $I_5=358.479$. The centers of mass of the links are located at: the midpoint of segment $O_2A$, the midpoint of segment $AB$, the centroid of triangle $O_4BC$, the midpoint of segment $CD$, and point $D$. 


#### Body 2

We define the equations from the free body diagram:

<img src="./figs/ejemplo3_02_media/image_1.png" alt="ejemplo302b" width="320px">

 $ \begin{array}{l} {\vec{F} }_{32} +{\vec{F} }_{12} -m_2 {\vec{a} }_{G2} =0\newline {\vec{p} }_2 \times {\vec{F} }_{32} +{\vec{q} }_2 \times {\vec{F} }_{12} +{\vec{M} }_0 -I_{G2} {\vec{\alpha} }_2 =0 \end{array} $ 
```matlab
% 1 - define m2, IG2, p2, q2
% 2 - declare the unknowns and define the
% vectors for the forces and moments
% 3 - define the equations: eq1_2 for forces and eq3 for moments
m2=15.31; IG2=1.278;
p2=rO2G2; q2=-p2;
syms F12x F12y F32x F32y M0k real
F12=[F12x F12y 0];
F32=[F32x F32y 0];
M0=[0 0 M0k]; 
eq1_2=F32+F12-m2*aG2==0;
eq3=cross(p2,F32)+cross(q2,F12)+M0-[0 0 IG2*0]==0;
```
#### Body 3

We define the equations from the free body diagram:

<img src="./figs/ejemplo3_02_media/image_2.png" alt="ejemplo302c" width="320px">

 $ \begin{array}{l} {\vec{F} }_{43} -{\vec{F} }_{32} -m_3 {\vec{a} }_{G3} =0\newline {\vec{p} }_3 \times {\vec{F} }_{43} -{\vec{q} }_3 \times {\vec{F} }_{32} -I_{G3} {\vec{\alpha} }_3 =0 \end{array} $ 
```matlab
% 1 - define m3, IG3, p3, q3
% 2 - declare the unknowns and define the
% vectors for the forces and moments
% 3 - define the equations: eq4_5 for forces and eq6 for moments
m3=61.26; IG3=81.68; 
p3=rAG3; q3=-p3;
syms F43x F43y real
F43=[F43x F43y 0];
eq4_5=F43-F32-m3*aG3==0;
eq6=cross(p3,F43)+cross(q3,-F32)-[0 0 IG3*af3k]==0;
```
#### Body 4

We define the equations from the free body diagram:

<img src="./figs/ejemplo3_02_media/image_3.png" alt="ejemplo30d" width="320px">

 $ \begin{array}{l} {\vec{F} }_{54} -{\vec{F} }_{43} +{\vec{F} }_{14} -m_4 {\vec{a} }_{G4} =0\newline {\vec{p} }_4 \times {\vec{F} }_{54} -{\vec{q} }_4 \times {\vec{F} }_{43} +{\vec{r} }_4 \times {\vec{F} }_{14} -I_{G4} {\vec{\alpha} }_4 =0 \end{array} $ 
```matlab
% 1 - define m4, IG4, p4, q4, r4
% 2 - declare the unknowns and define the
% vectors for the forces and moments:
% 3 - define the equations: eq7_8 for forces and eq9 for moments
m4=154.75;IG4=495.76;
p4=[0.1692 3.1052 0]; q4=[0.5144 -0.0766 0];
r4=[-0.6598 -2.8373 0];
syms F54x F54y F14x F14y real
F54=[F54x F54y 0];
F14=[F14x F14y 0];
eq7_8=F54-F43+F14-m4*aG4==0;
eq9=cross(p4,F54)+cross(q4,-F43)+cross(r4,F14)-[0 0 IG4*af4k]==0;
```
#### Body 5

We define the equations from the free body diagram:


<img src="./figs/ejemplo3_02_media/image_4.png" alt="ejemplo302e" width="320px">

 $ \begin{array}{l} {\vec{F} }_{65} -{\vec{F} }_{54} -m_5 {\vec{a} }_{G5} =0\newline {\vec{p} }_5 \times {\vec{F} }_{65} -{\vec{q} }_5 \times {\vec{F} }_{54} -I_{G5} {\vec{\alpha} }_5 =0 \end{array} $ 
```matlab
% 1 - define m5, IG5, p5, q5
% 2 - declare the unknowns and define the
% vectors for the forces and moments:
% 3 - define the equations: eq10_11 for forces and eq12 for moments
m5=99.54; IG5=358.479;
p5=rCG5; q5=-p5;
syms F65x F65y real
F65=[F65x F65y 0]; 
eq10_11=F65-F54-m5*aG5==0;
eq12=cross(p5,F65)+cross(q5,-F54)-[0 0 IG5*af5k]==0;
```
#### Body 6

We define the equations from the free body diagram:

<img src="./figs/ejemplo3_02_media/image_5.png" alt="ejemplo302f" width="220px">

 $ {\vec{F} }_{16} -{\vec{F} }_{65} +{\vec{F} }_R -m_6 {\vec{a} }_{G6} =0 $ 
```matlab
% 1 - define m6, FR
% 2 - declare the unknowns and define the
% vectors for the forces
% 3 - define the equations: eq13_14 for forces
m6=85;
syms F16y  real
F16=[0 F16y 0];
FR=[314.2 0 0];
eq13_14=F16-F65+FR-m6*aG6==0;
```
#### Solution:

To solve the system made up of the 14 equations we must use the *solve* function, as in the previous parts, keeping in mind that we must group the equations into a vector. The 14 unknowns are entered separated by commas, just as in the previous parts.

```matlab
% Solve the complete system:
solf=solve([eq1_2,eq3,eq4_5,eq6,eq7_8,eq9,eq10_11,eq12,eq13_14],...
    F12x, F12y, F32x, F32y, F43x, F43y, F54x, F54y,...
    F14x, F14y, F65x, F65y, F16y, M0k);
% Evaluate the results:
F12x=double(solf.F12x);
F12y=double(solf.F12y);
F32x=double(solf.F32x);
F32y=double(solf.F32y);
F43x=double(solf.F43x);
F43y=double(solf.F43y);
F14x=double(solf.F14x);
F14y=double(solf.F14y);
F54x=double(solf.F54x);
F54y=double(solf.F54y);
F65x=double(solf.F65x);
F65y=double(solf.F65y);
F16y=double(solf.F16y);
M0k=double(solf.M0k);
```

Finally, we display the results:

```matlab
% Print results:
fprintf('F12x=%5.0f F12y=%5.0f\n', F12x,F12y)
```

```matlabTextOutput
F12x=-32317 F12y=-7403
```

```matlab
fprintf('F32x=%5.0f F32y=%5.0f\n', F32x,F32y)
```

```matlabTextOutput
F32x=32184 F32y= 7426
```

```matlab
fprintf('F43x=%5.0f F43y=%5.0f\n', F43x,F43y)
```

```matlabTextOutput
F43x=30877 F43y= 7802
```

```matlab
fprintf('F54x=%5.0f F54y=%5.0f\n', F54x,F54y)
```

```matlabTextOutput
F54x=10153 F54y=  942
```

```matlab
fprintf('F14x=%5.0f F14y=%5.0f\n', F14x,F14y)
```

```matlabTextOutput
F14x=16637 F14y= 7574
```

```matlab

fprintf('F65x=%5.0f F65y=%5.0f\n', F65x,F65y)
```

```matlabTextOutput
F65x= 4829 F65y= 1172
```

```matlab
fprintf('F16y=%5.0f\n', F16y)
```

```matlabTextOutput
F16y= 1172
```

```matlab
fprintf('T2k=%5.0f\n', M0k)
```

```matlabTextOutput
T2k=-12902
```

The following [GeoGebra model](https://www.geogebra.org/m/r8b9vhae) shows an alternative solving procedure, leading to the same solutions:

---

<iframe scrolling="no" title="Example 3.2" src="https://www.geogebra.org/material/iframe/id/sbc7tbpz/width/700/height/640/border/888888/sfsb/true/smb/false/stb/false/stbh/false/ai/false/asb/false/sri/true/rc/true/ld/false/sdz/true/ctl/false" width="800px" height="600px" style="border:0px;"> </iframe>
