1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
| clc;clear;close all;
l1 = 92.4; l6 = 350; l3 = 757.4; omegal1 = -2.4*pi; H1 = 100; G3 = 200; G5 = 700; J_s3 = 1.1; l_s3 = l3/2; g = 10;
disp("代码说明:x右为0度,涉及转动的,逆时针为正,笛卡尔坐标系")
ifzu = input('你是组长吗?,是为1,不是为0\n'); if ifzu == 1 MyPar = parpool; ifzhouqi = input('周期绘图?,是为1,不是为0\n');
if ifzhouqi == 1 nzhouqi = input('几个周期?\n'); v = []; a = []; s = []; Mb = []; for i = -nzhouqi*2:0.01:0 phy1 = pi*i; [vi,ai,si,Mb_i] = sol_wzr(l1,l6,l3,omegal1,phy1,G5,G3,g,l_s3,J_s3); v = [v,vi]; a = [a,ai]; s = [s,si]; Mb = [Mb,Mb_i]; end phy1_n = (-nzhouqi*2:0.01:0)*pi; end if ifzhouqi == 0 v = []; a = []; s = []; Mb = []; for i = -2:0.001:0 phy1 = pi*i; [vi,ai,si,Mb_i] = sol_wzr(l1,l6,l3,omegal1,phy1,G5,G3,g,l_s3,J_s3); v = [v,vi]; a = [a,ai]; s = [s,si]; Mb = [Mb,Mb_i]; end phy1_n = (-2:0.001:0)*pi; end
set(gcf, 'Color', [1 1 1]); subplot(2,2,1) plot(phy1_n,v,'LineWidth',1.5,'Color','b') title("速度分析",'FontSize',14) xlabel('曲柄转角\theta_1/rad','FontSize',12) ylabel('刨刀速度v/(m/s)','FontSize',12) hold on; grid on; axis tight; set(gca, 'XDir', 'reverse'); set(gca, 'FontSize', 12) legend('速度','Location','best') subplot(2,2,2) plot(phy1_n,a,'LineWidth',1.5,'Color','r') title("加速度分析",'FontSize',14) xlabel('曲柄转角\theta_1/rad','FontSize',12) ylabel('刨刀加速度a/(mm/s^2)','FontSize',12) hold on; grid on; axis tight; set(gca, 'XDir', 'reverse'); set(gca,'FontSize',12) legend('加速度','Location','best') subplot(2,2,3) plot(phy1_n,s,'LineWidth',1.5,'Color','g') title("位移分析",'FontSize',14) xlabel('曲柄转角\theta_1/rad','FontSize',12) ylabel('刨刀位移s/mm','FontSize',12) hold on; grid on; axis tight; set(gca, 'XDir', 'reverse'); set(gca,'FontSize',12) legend('位移','Location','best') subplot(2,2,4) plot(phy1_n,Mb,'LineWidth',1.5,'Color','k') title("平衡力矩分析",'FontSize',14) xlabel('曲柄转角\theta_1/rad','FontSize',12) ylabel('平衡力矩Mb/Nm','FontSize',12) hold on; grid on; axis tight; set(gca, 'XDir', 'reverse'); set(gca,'FontSize',12) legend('平衡力矩','Location','best') delete(gcp('nocreate')); pause; end if ifzu == 0 phy_for_you = input('输入你的角度(角度制),逆时针为正\n'); phy1_wzr = phy_for_you*pi/180; [v_my,a_my,s_my,Mb_my,omegal3_my,alpha3_my,R_34_my,P_I3_my,M_I3_my,R_21_my] = sol_wzr(l1,l6,l3,omegal1,phy1_wzr,G5,G3,g,l_s3,J_s3) pause; end
function [v,a,s,Mb,omegal3,alpha3,R_34,P_I3,M_I3,R_21] = sol_wzr(l1,l6,l3,omegal1,phy1,G5,G3,g,l_s3,J_s3) sb = sqrt((l1*cos(phy1))^2 + (l6+l1*sin(phy1))^2); phy3 = acos(l1*cos(phy1)/sb); sol1 = [cos(phy3) -sb*sin(phy3);... sin(phy3) sb*cos(phy3)]\(omegal1 * l1*[-sin(phy1);cos(phy1)]); omegal3 = sol1(2); v23 = sol1(1); sol2 = [cos(phy3) -sb*sin(phy3);... sin(phy3) sb*cos(phy3)]\... (-[-omegal3*sin(phy3) -v23*sin(phy3)-sb*omegal3*cos(phy3);... omegal3*cos(phy3) v23*cos(phy3)-sb*omegal3*sin(phy3)]*sol1 ... - omegal1^2*l1*[cos(phy1);sin(phy1)]); alpha3 = sol2(2); vd = -omegal3*l3; v = vd*sin(phy3); a = -omegal3^2*l3*cos(phy3) - alpha3*l3*sin(phy3); s = l3*cos(phy3)+200;
phy_cha = mod(phy1,-2*pi); if (phy_cha<-15.31*pi/180) && (phy_cha>-(180-15.31)*pi/180) F_r = 0; else F_r = -4500; end R_34 = -F_r - G5*(-a)*(1e-3)/g; R_43 = - R_34; a_s3x = -l_s3*(1e-3)*(omegal3^2*cos(phy3)+alpha3*sin(phy3)); a_s3y = -l_s3*(1e-3)*(omegal3^2*sin(phy3)-alpha3*cos(phy3)); P_I3x = -G3*a_s3x/g; P_I3y = -G3*a_s3y/g; P_I3 = sqrt(P_I3x^2+P_I3y^2); M_I3 = -J_s3*alpha3;
sol3 = [1 0 1 0; 0 1 0 1; -(sb-l_s3)*(1e-3)*sin(phy3) (sb-l_s3)*(1e-3)*cos(phy3) l_s3*(1e-3)*sin(phy3) -l_s3*(1e-3)*cos(phy3);... cos(phy3) sin(phy3) 0 0]\[-P_I3x-R_43; -P_I3y+G3; R_43*l_s3*(1e-3)*sin(phy3)-M_I3; 0]; R_23x = sol3(1); R_23y = sol3(2); R_21x = -R_23x; R_21y = -R_23y; R_21 = sqrt(R_21x^2+R_21y^2); if phy_cha <=0 && phy_cha >=-pi/2 Mb = -R_21x*l1*(1e-3)*abs(sin(phy1))-R_21y*l1*(1e-3)*abs(cos(phy1)); end if phy_cha <-pi/2 && phy_cha >=-pi Mb = R_21x*l1*(1e-3)*abs(sin(phy1))-R_21y*l1*(1e-3)*abs(cos(phy1)); end if phy_cha <-pi && phy_cha >=-3*pi/2 Mb = -R_21x*l1*(1e-3)*abs(sin(phy1))-R_21y*l1*(1e-3)*abs(cos(phy1)); end if phy_cha <-3*pi/2 && phy_cha >=-2*pi Mb = R_21x*l1*(1e-3)*abs(sin(phy1))-R_21y*l1*(1e-3)*abs(cos(phy1)); end end
|