# Chapter 9: Cams¶

## Example 5, Page 300¶

In [4]:
%matplotlib inline
import math
import numpy as np
import matplotlib.pyplot as plt

#Variable declaration
alpha=55*math.pi/180
N=1200#rpm
lift=.5#in

#Calculations&Results
OQ=rmin+lift-rn
OP=(OQ**2-1)/(2*(1-OQ*math.cos(alpha)))#from triangle opq fig 201(a)
PQ=OP+rmin-rn
phi=math.asin(OQ*math.sin(alpha)/PQ)
x1=np.linspace(0,phi)
x2=np.linspace(phi,alpha)
y1=4.477*(1-np.cos(x1))#from 9.6
y2=1.5*np.cos(alpha-x2)-1#from 9.9
v1=math.pi*N*4.477*np.sin(x1)/(30*12)#from 9.7
v2=15.71*np.sin(alpha-x2)#from 9.10
f1=(math.pi*N/30)**2*(4.477/12)*np.cos(x1)#from 9.8
f2=-1974*np.cos(alpha-x2)#from 9.11
a=np.linspace(0,phi)
b=np.linspace(phi,alpha)
p=np.linspace(0,phi)
q=np.linspace(phi,alpha)
plt.subplot(3,1,3)
plt.subplot(3,1,1)
plt.plot(x1,y1,x2,y2)
plt.tick_params(axis='y', which='both', labelleft='off', labelright='on')
plt.xlabel("angle")
plt.ylabel("displacement")
plt.subplot(3,1,2)
plt.plot(a,v1,b,v2)
plt.tick_params(axis='y', which='both', labelleft='off', labelright='on')
plt.ylabel("velocity")
plt.subplot(3,1,3)
plt.plot(p,f1,q,f2)
plt.tick_params(axis='y', which='both', labelleft='off', labelright='on')
plt.xlabel("angle")
plt.ylabel("acceleration")
plt.show()


## Example 7, Page 309¶

In [3]:
import math

#Variable declaration
N=600#rpm
BC=3#in
rmin=1.125#in
rf=39/8#in
OP=rf-rmin
OM1=0.79#in;given
NZ1=2.66#in

#Calculations
w=N*math.pi/30
vb=w*OM1
Vang=vb/BC
at=w**2*NZ1
fBC=at/BC
OM2=.52#in
NZ2=3.24#in
af=w*OM2/BC
angf=w**2*NZ2/BC

#Results
print "When theta = 25 degrees\nangular velocity = %.1f rad/s\nangular acceleration = %.f rad/s^2"\
"\nWhen theta = 45 degrees\nangular velocity = %.1f rad/s\nangular acceleration = %.f rad/s^2"%(Vang,fBC,af,angf)

When theta = 25 degrees