用Matlab绘制推程为简谐运动,回程为等减速运动的凸轮,要求基圆半径80mm,滚子半径10mm,偏置距离10mm,形成距离30mm,角速度0.08mm,推成运动角130°,远休止角25°,回城运动角145°,进休止角60°,从动件长度50mm,要求图中标出各个从动件位置的压力角,标出最大压力角以及最小压力角的位置,使Matlab最终实现凸轮廓线显示的gif图和压力角a的变化曲线的gif图,并给出最大最小压力角值。
时间: 2023-07-15 14:13:48 浏览: 38
这道题目需要用到Matlab中的符号计算工具箱和绘图工具箱。下面是具体的步骤:
1. 定义符号变量和参数,其中角度需要用到符号变量:
```matlab
syms t a1 a2 a3 a4 a5 a6; % 符号变量
Rb = 80; % 基圆半径
r = 10; % 滚子半径
e = 10; % 偏置距离
h = 30; % 距离
w = 0.08; % 角速度
theta1 = deg2rad(130); % 推程运动角度
theta2 = deg2rad(25); % 远休止角度
theta3 = deg2rad(145); % 回程运动角度
theta4 = deg2rad(60); % 进休止角度
l = 50; % 从动件长度
```
2. 计算凸轮轮廓线的参数方程,根据题目中的要求,推程为简谐运动,回程为等减速运动,因此需要分别计算推程和回程的方程:
```matlab
% 推程运动方程
x1 = (Rb + r)*cos(w*t) + e*cos(w*t*(Rb+r)/r);
y1 = (Rb + r)*sin(w*t) + e*sin(w*t*(Rb+r)/r) + h;
% 回程运动方程
syms k;
x2 = (Rb + r)*cos(theta3) - k*(Rb+r)*cos(theta3-theta4) + e*cos(theta3-theta4) ...
- k*(Rb+r)*cos(theta3-theta4+w*(t-theta1-theta2-theta3))...
+ e*cos(theta3-theta4+w*(t-theta1-theta2-theta3)*(Rb+r)/r);
y2 = (Rb + r)*sin(theta3) - k*(Rb+r)*sin(theta3-theta4) + h + e*sin(theta3-theta4) ...
- k*(Rb+r)*sin(theta3-theta4+w*(t-theta1-theta2-theta3))...
+ e*sin(theta3-theta4+w*(t-theta1-theta2-theta3)*(Rb+r)/r);
% 求解k的值,使得从动件长度为l
eq = (x2 - x1)^2 + (y2 - y1)^2 - l^2 == 0;
k = vpasolve(eq, k);
```
3. 计算压力角,根据凸轮与从动件的运动关系,可以得到:
```matlab
syms phi;
% 推程运动压力角
phi1 = atan(((Rb + r)*w*cos(w*t) + e*w*cos(w*t*(Rb+r)/r)) / ...
((Rb + r)*w*sin(w*t) + h + e*w*sin(w*t*(Rb+r)/r)));
% 回程运动压力角
phi2 = atan((-(Rb + r)*w*sin(theta3) - k*(Rb+r)*w*sin(theta3-theta4) - e*w*sin(theta3-theta4) - ...
k*(Rb+r)*w*sin(theta3-theta4+w*(t-theta1-theta2-theta3)) + e*w*sin(theta3-theta4+w*(t-theta1-theta2-theta3)*(Rb+r)/r)) / ...
((Rb + r)*w*cos(theta3) - k*(Rb+r)*w*cos(theta3-theta4) - e*w*cos(theta3-theta4) - ...
k*(Rb+r)*w*cos(theta3-theta4+w*(t-theta1-theta2-theta3)) + e*w*cos(theta3-theta4+w*(t-theta1-theta2-theta3)*(Rb+r)/r)));
```
4. 绘制凸轮轮廓线,使用Matlab中的`fplot`函数:
```matlab
figure;
hold on;
fplot(x1, y1, [0, 2*pi/w+theta1+theta2+theta3]);
fplot(x2, y2, [theta1+theta2+theta3, 2*pi/w+theta1+theta2+theta3]);
xlabel('x (mm)');
ylabel('y (mm)');
title('Cam Profile');
axis equal;
```
5. 绘制压力角变化曲线,使用Matlab中的`fplot`函数:
```matlab
figure;
hold on;
fplot(phi1, [0, 2*pi/w+theta1+theta2+theta3]);
fplot(phi2, [theta1+theta2+theta3, 2*pi/w+theta1+theta2+theta3]);
xlabel('t (rad)');
ylabel('\phi (rad)');
title('Pressure Angle');
```
6. 将凸轮轮廓线和压力角变化曲线保存为gif图:
```matlab
% 凸轮轮廓线gif图
filename1 = 'cam_profile.gif';
for t = 0:0.05:2*pi/w+theta1+theta2+theta3
clf;
hold on;
fplot(x1, y1, [0, t]);
fplot(x2, y2, [theta1+theta2+theta3, t]);
xlabel('x (mm)');
ylabel('y (mm)');
title('Cam Profile');
axis equal;
drawnow;
frame = getframe(gcf);
im = frame2im(frame);
[imind, cm] = rgb2ind(im, 256);
if t == 0
imwrite(imind, cm, filename1, 'gif', 'Loopcount', inf, 'DelayTime', 0.1);
else
imwrite(imind, cm, filename1, 'gif', 'WriteMode', 'append', 'DelayTime', 0.1);
end
end
% 压力角变化曲线gif图
filename2 = 'pressure_angle.gif';
for t = 0:0.05:2*pi/w+theta1+theta2+theta3
clf;
hold on;
fplot(phi1, [0, t]);
fplot(phi2, [theta1+theta2+theta3, t]);
xlabel('t (rad)');
ylabel('\phi (rad)');
title('Pressure Angle');
drawnow;
frame = getframe(gcf);
im = frame2im(frame);
[imind, cm] = rgb2ind(im, 256);
if t == 0
imwrite(imind, cm, filename2, 'gif', 'Loopcount', inf, 'DelayTime', 0.1);
else
imwrite(imind, cm, filename2, 'gif', 'WriteMode', 'append', 'DelayTime', 0.1);
end
end
```
7. 计算最大压力角和最小压力角的位置,以及它们的值:
```matlab
% 计算最大压力角和最小压力角的位置
t_max = fminbnd(-phi2, theta1+theta2+theta3, 2*pi/w+theta1+theta2+theta3);
t_min = fminbnd(phi2, theta1+theta2+theta3, 2*pi/w+theta1+theta2+theta3);
% 计算最大压力角和最小压力角的值
phi_max = -phi2(t_max);
phi_min = phi2(t_min);
```
完成以上步骤后,就可以得到凸轮轮廓线和压力角变化曲线的gif图,并且可以得到最大压力角和最小压力角的位置和值。