34. Cam is a mechanical device that transforms rotary motion into linear motion.
ID: 2325169 • Letter: 3
Question
34. Cam is a mechanical device that transforms rotary motion into linear motion. The shape of the disc is designed to produce a specified displacement pro- file. A displacement profile is a plot of the dis- placement of the follower as a function of the angle of rotation of the cam The motion of a cer- tain cam is given by the following equations: y 6120-0.5 sinej for 0s es y 6 for 1/2 se s21 /3 for 2R/3ses 6-3 1-0.5cos 3 6-2 3 for 4R/3 so s /2 for 31 /2s0s7R/4 1/4 for 71e KAS les 2T y 0.75 0.75 1Explanation / Answer
the following matlab program is developed globally for any cam profile with changable parameters as output in matlab interface- function cams(varargin) global S %{ Cam Simulator To launch, simply type cams in the MATLAB command window with this in the current directory. Alternatively, you can choose Debug -> Run from this editor window, or press F5. Helpful Notes: - The first edit box column is to contain the motion type(s). Each row of it should have one of the preset motions written inside it (SHM, CYC, etc...). - The second edit box is to specify the duration of each of the motion types. Each row should contain a duration in degrees for the corresponding respective motion type. - The third edit box contains the respective displacemens for the motion types. - The durations (second box) have to add up to 360 degrees. Also, while not necessary in the typical sense, the displacements should generally add up to 0. - To understand more, see one of the pre-set examples found at File -> Load. - As for the axis limits, the first is offline at the current time. The second changes the axis for the second plot (Velocity) and the third for the third plot (Acceleration). - The number under 'Res' changes the number of points for drawing the cam profile. It is the top critereon for the load time above it. - You can change the speed of rotation (Fast, Slow, Pause) during animation. - Any comments should be sent to . Don't hesitate to send! - Recommended resolution is 1280 by 800 pixels. - Works only on MATLAB 7.4 (R2007a) and above. %} %% Main Figure and Menus figure('units','normalized',... 'position',[.1 .1 .8 .75],... 'color','w',... 'numbertitle','off',... 'menubar','none',... 'name','Cam Simulator') m1=uimenu('Label','File'); m2=uimenu('Label','More'); % when you click on a menu the code go to its corresponding callback function uimenu(m1,'Label','Save Model','Callback',@savv); uimenu(m1,'Label','Load Model','Callback',@ladd,'Separator','on'); uimenu(m1,'Label','Quit','Callback',@xq,'Separator','on'); uimenu(m2,'Label','About','Callback',@bott); %% File -> quit function xq(varargin) close(gcf) end %% File -> Save function savv(varargin) % make a small figure with a button, text and edit figure('units','normalized','position',[0.1 .6 .2 .2],'color','w','numbertitle','off','menubar','none','name','Save') uicontrol('style','text','units','normalized','position',[.05 .7 .9 .2],'string','Save Model As','backgroundcolor','w',... 'fontsize',15,'fontweight','b','fontname','arial','horizontalalignment','left') se=uicontrol('style','edit','units','normalized','position',[.05 .525 .7 .2],'string','','backgroundcolor','w',... 'fontsize',15,'fontweight','b','fontname','arial','horizontalalignment','left'); uicontrol('style','pushbutton','units','normalized','position',[.1 .25 .5 .2],'string','Save','backgroundcolor','w',... 'fontsize',15,'fontweight','b','fontname','arial','horizontalalignment','left','callback',@savvy) % what happens when you press 'Save' function savvy(varargin) ns=get(se,'string'); % get name in edit box close(gcf) % close the 'Save' figure window % get important values from edit boxes Types=get(MT,'string');%#ok Disps=(get(MA,'string'));%#ok Durations=(get(MD,'string'));%#ok rb=(get(BC,'string'));%#ok if get(hr,'selectedobject')==hb1 % flat face follower has less variables to save ;) %this variable is to indicate how many variables are saved. it %will be used when we load kk=1; %#ok % save needed variables in the name in the directory Models save(['Models',ns,'.mat'],'Types','Disps','Durations','rb','kk') else kk=2; %#ok rd=(get(t2,'string')); %#ok e=(get(t4,'string')); %#ok kc=(get(t6,'string')); %#ok save(['Models',ns,'.mat'],'Types','Disps' ,'Durations' ,'rb','rd','e','kc','kk') end end end %% File -> Load function ladd(varargin) % make a small figure window with a button, edit and text figure('units','normalized','position',[0.1 .6 .4 .2],'color','w','numbertitle','off','menubar','none','name','Load') uicontrol('style','text','units','normalized','position',[.05 .7 .9/2 .2],'string','Enter Name of Model','backgroundcolor','w',... 'fontsize',11,'fontweight','b','fontname','arial','horizontalalignment','left') uicontrol('style','text','units','normalized','position',[.05+.9/2+.1-.1 .7 .9/2 .2],'string','Available Models','backgroundcolor','w',... 'fontsize',11,'fontweight','b','fontname','arial','horizontalalignment','left') se=uicontrol('style','edit','units','normalized','position',[.05 .525 .7/2 .2],'string','','backgroundcolor','w',... 'fontsize',15,'fontweight','b','fontname','arial','horizontalalignment','left'); uicontrol('style','pushbutton','units','normalized','position',[.1 .25 .5/2 .2],'string','Load','backgroundcolor','w',... 'fontsize',15,'fontweight','b','fontname','arial','horizontalalignment','left','callback',@laddy) % get all files in the folder 'Models' that end with '.mat' pW=dir('Models*.mat'); % save their names as a character matrix hol=strvcat(pW.name); % change '.mat' into spaces for each name for lopp=1:size(hol,1) hol(lopp,:)=strrep(hol(lopp,:),'.mat',repmat(' ',1,4)); end % make a listbox with the previous names matrix as string pl=uicontrol('style','listbox','max',2,'units','normalized','position',[.05+.9/2 .1 .9/2 .7],'string',hol,'backgroundcolor','w',... 'fontsize',11,'fontweight','b','fontname','arial','horizontalalignment','left','callback',@yah); % every time you click a name in the listbox the name is displayed in % the edit box as per the following function function yah(varargin) sh=get(pl,'value'); % get value of chosen element in the listbox sg=(get(pl,'string')); sj=sg(sh,:); % get the string respective to that value set(se,'string',sj) % put said string in edit box end % what happens when you press the 'Load' button in the Load figure window function laddy(varargin) ns=get(se,'string'); % get the name in the edit box ns(ns==' ')=[]; % delete spaces that strvcat produced at the end of names close(gcf) % close the Load figure window % load the variable kk from name (used to see how many variables are to % be loaded, since flat face follower has less characteristics to load) load(['Models',ns,'.mat'],'kk') if kk==1 % flat face follower % select flat face radio button set(hr,'selectedobject',hb1) % load variables from Models'filename' load(['Models',ns,'.mat'],'Types','Disps' ,'Durations' ,'rb') % set edit boxes as per loaded variables set(MT,'string',Types) set(MA,'string',Disps) set(MD,'string',Durations) set(BC,'string',rb) else % same as before, but roller follower has more variables to be loaded set(hr,'selectedobject',hb2) load(['Models',ns,'.mat'],'Types','Disps' ,'Durations' ,'rb','rd','e','kc') set(MT,'string',Types) set(MA,'string',Disps) set(MD,'string',Durations) set(BC,'string',rb) set(t2,'string',rd) set(t4,'string',e) set(t6,'string',kc) end CGMT % go to the function of changing follower type (to set some things visible on/off) end end %% More -> About function bott(varargin) figure('units','normalized','position',[0.1 .7 .25 .1],'color','w','numbertitle','off','menubar','none','name','About'); uicontrol('style','text','units','normalized','position',[.05 .25 .6 .2],'string','numandina@gmail.com','backgroundcolor','w',... 'fontsize',11,'fontweight','b','fontname','arial','horizontalalignment','left'); uicontrol('style','text','units','normalized','position',[.05 .65 .6 .2],'string','Husam Aldahiyat 28/12/2008','backgroundcolor','w',... 'fontsize',11,'fontweight','b','fontname','arial','horizontalalignment','left'); end %% Main Figure uicontrols (edits, text, etc...) % some texts uicontrol('style','text','units','normalized','position',[.025 .9 .08 .05],'backgroundcolor','w','max',2,... 'fontsize',12,'fontname','calibri','string','Motion Type') uicontrol('style','text','units','normalized','position',[.125 .9 .08 .075],'backgroundcolor','w','max',2,... 'fontsize',12,'fontname','calibri','string','Motion Duration') uicontrol('style','text','units','normalized','position',[.225 .875 .085 .075],'backgroundcolor','w','max',2,... 'fontsize',11,'fontname','calibri','string','Displacement') % this is the black axis that acts as a seperator axes('position',[.35 0 .025 1],'color','k','xcolor','w','ycolor','w','zcolor','w','xtick',100,'ytick',100) % the little squares above 'Res'. they act as a loading bar hl(1)=uicontrol('style','text','units','normalized','position',[.335 .95 .005 .0075],'backgroundcolor','r'); hl(2)=uicontrol('style','text','units','normalized','position',[.335 .94 .005 .0075],'backgroundcolor','r'); hl(3)=uicontrol('style','text','units','normalized','position',[.335 .93 .005 .0075],'backgroundcolor','r'); hl(4)=uicontrol('style','text','units','normalized','position',[.335 .92 .005 .0075],'backgroundcolor','r'); hl(5)=uicontrol('style','text','units','normalized','position',[.335 .91 .005 .0075],'backgroundcolor','r'); hl(6)=uicontrol('style','text','units','normalized','position',[.335 .9 .005 .0075],'backgroundcolor','r'); hl(7)=uicontrol('style','text','units','normalized','position',[.335 .89 .005 .0075],'backgroundcolor','r'); hl(8)=uicontrol('style','text','units','normalized','position',[.335 .88 .005 .0075],'backgroundcolor','r'); hl(9)=uicontrol('style','text','units','normalized','position',[.335 .87 .005 .0075],'backgroundcolor','r'); hl(10)=uicontrol('style','text','units','normalized','position',[.335 .86 .005 .0075],'backgroundcolor','r'); % dummy text, used only to store certain values so that they would be retrieved % later by another function dummy1=uicontrol('style','text','visible','off','max',2); dummy2=uicontrol('style','text','visible','off','max',2); dummy3=uicontrol('style','text','visible','off','max',2); % some more stuff uicontrol('style','text','units','normalized','position',[.31 .82 .035 .025],'string','Res','backgroundcolor','w'); rR=uicontrol('style','edit','units','normalized','position',[.31 .79 .035 .025],'string','100','backgroundcolor','w'); MT=uicontrol('style','edit','units','normalized','position',[.025 .6 .08 .3],'backgroundcolor','w','max',2,... 'fontsize',14,'fontname','calibri'); MD=uicontrol('style','edit','units','normalized','position',[.125 .6 .08 .3],'backgroundcolor','w','max',2,... 'fontsize',14,'fontname','calibri'); MA=uicontrol('style','edit','units','normalized','position',[.225 .6 .08 .3],'backgroundcolor','w','max',2,... 'fontsize',14,'fontname','calibri'); uicontrol('style','text','units','normalized','position',[.025 .5 .2 .05],'backgroundcolor','w',... 'fontsize',12,'fontname','calibri','string','SHM: Simple Harmonic Motion','horizontalalignment','left'); uicontrol('style','text','units','normalized','position',[.025 .45 .3 .05],'backgroundcolor','w',... 'fontsize',12,'fontname','calibri','string','DWL: Dwell CSV: Constant Velocity','horizontalalignment','left'); uicontrol('style','text','units','normalized','position',[.025 .4 .2 .05],'backgroundcolor','w',... 'fontsize',12,'fontname','calibri','string','PAR: Parabolic Motion','horizontalalignment','left'); uicontrol('style','text','units','normalized','position',[.025 .35 .2 .05],'backgroundcolor','w',... 'fontsize',12,'fontname','calibri','string','CYC: Cycloidal Motion','horizontalalignment','left'); uicontrol('style','text','units','normalized','position',[.025 .3 .15 .05],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','Base Circle Radius: ','horizontalalignment','left'); BC=uicontrol('style','edit','units','normalized','position',[.145 .32 .03 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string',' ','horizontalalignment','center'); % 'Go' pushbutton BB=uicontrol('style','pushbutton','units','normalized','position',[.225 .025 .08 .05],'backgroundcolor','w',... 'fontsize',14,'fontname','calibri','string','Go','callback',@go); D3=uicontrol('style','pushbutton','units','normalized','position',[.225 .4 .08 .05],'backgroundcolor','w',... 'fontsize',14,'fontname','calibri','string','3D','callback',@go3,'visible','off'); % choose follower type radio group hr=uibuttongroup('Units','normalized',... 'Position',[.025 .25 .3 .05],'SelectionChangeFcn',@CGMT); hb1=uicontrol('Style','Radiobutton','String','Flat Face Follower','Units','normalized',... 'Position',[0 0 1/2 1],'Parent',hr,'backgroundcolor',[1 1 1],'foregroundcolor',[0 0 0]); hb2=uicontrol('Style','Radiobutton','String','Translating Roller Follower','Units','normalized',... 'Position',[1/2 0 1/2 1],'Parent',hr,'backgroundcolor',[1 1 1],'foregroundcolor',[0 0 0]); % speed of animation radio group hr2=uibuttongroup('Units','normalized',... 'Position',[.175 .1 .15 .05]); hbs=uicontrol('Style','Radiobutton','String','Fast','Units','normalized',... 'Position',[0 0 1/3 1],'Parent',hr2,'backgroundcolor',[1 1 1],'foregroundcolor',[0 0 0]); hbk=uicontrol('Style','Radiobutton','String','Slow','Units','normalized',... 'Position',[1/3 0 1/3 1],'Parent',hr2,'backgroundcolor',[1 1 1],'foregroundcolor',[0 0 0]); uicontrol('Style','Radiobutton','String','Pause','Units','normalized',... 'Position',[2/3 0 1/3 1],'Parent',hr2,'backgroundcolor',[1 1 1],'foregroundcolor',[0 0 0]); % texts that are set on/off depending on follower type t1=uicontrol('style','text','units','normalized','position',[.025 .18 .15 .05],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','Roller Radius: ','horizontalalignment','left'); t2=uicontrol('style','edit','units','normalized','position',[.125 .2 .03 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string',' ','horizontalalignment','center'); t3=uicontrol('style','text','units','normalized','position',[.025 .14 .15 .05],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','Offset: ','horizontalalignment','left'); t4=uicontrol('style','edit','units','normalized','position',[.125 .16 .03 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string',' ','horizontalalignment','center'); t5=uicontrol('style','text','units','normalized','position',[.025 .1 .15 .05],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','Inside/Ouside(~): ','horizontalalignment','left'); t6=uicontrol('style','edit','units','normalized','position',[.125 .12 .03 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','0','horizontalalignment','center'); % text and edits at the lower left corner of the main figure window uicontrol('style','text','units','normalized','position',[.025 .065 .15 .05],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','Axis Limits: ','horizontalalignment','left'); uicontrol('style','text','units','normalized','position',[.025 -.005 .15 .05],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','[y1 y2]','horizontalalignment','left','fontweight','b'); uicontrol('style','edit','units','normalized','position',[.025 .05 .05 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','','horizontalalignment','center','callback',@ca1,'enable','off'); al2=uicontrol('style','edit','units','normalized','position',[.08 .05 .05 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','','horizontalalignment','center','callback',@ca2); al3=uicontrol('style','edit','units','normalized','position',[.13 .05 .05 .035],'backgroundcolor','w',... 'fontsize',10,'fontname','calibri','string','','horizontalalignment','center','callback',@ca3); % create the four axes and hide them for now a1=axes('position',[.4 .65 .55/3 .3]); % Displacement a2=axes('position',[.4+.55/3+.025 .65 .55/3 .3]); % Velocity a3=axes('position',[.4+.55/3*2+.05 .65 .55/3 .3]); % Acceleration a4=axes('position',[.4 .025 .55 .55]); % cam profile axes set(findobj('type','axes','-not','color','k'),'visible','off') % hide them % evaluate this function which sets certain uicontrols' visiblity on/off CGMT %% Change Axis Limits function ca2(varargin) an1=str2num(get(al2,'string')); %#ok % get limits from edit box set(a2,'ylim',an1(1:2)); % set these limits for the corresponding axes end function ca3(varargin) an1=str2num(get(al3,'string')); %#ok set(a3,'ylim',an1(1:2)); end %{ function ca1(varargin) an1=str2num(get(al1,'string')); set(a1,'ylim',an1(1:2)); end %} %% Change Follower Type function CGMT(varargin) if get(hr,'selectedobject')==hb1 % flat face set(t1,'visible','off') % rf text set(t2,'visible','off') % rf edit set(t3,'visible','off') % offset text set(t4,'visible','off') % offset edit set(t5,'visible','off') % inside/outside text set(t6,'visible','off') % inside/outside edit else set(t1,'visible','on') set(t2,'visible','on') set(t3,'visible','on') set(t4,'visible','on') set(t5,'visible','on') set(t6,'visible','on') end end %% Motion Program Functions % Dwell function [s,si,ti]=DWL(si,ti,a) s=sym(si); % create motion equation ezplot(s,[ti,ti+a]) % plot motion equation ti=ti+a; end % Simple Harmonic Motion function [s,si,ti]=SHM(si,ti,h,a) s=si+h/2*(1-cos(pi/a*(sym('x')-ti))); si=subs(s,a+ti); ezplot(s,[ti,ti+a]) ti=ti+a; end % Parabolic Motion function [s1,s2,si,ti]=PAR(si,ti,h,a) s1=si+2*h/a^2*(sym('x')-ti)^2; s2=si+h*(-1+4*(sym('x')-ti)/a-2*(sym('x')-ti)^2/a^2); si=subs(s2,ti+a); ezplot(s1,[ti,ti+a/2]) hold on ezplot(s2,[ti+a/2,ti+a]) xlim([ti ti+a]) ti=ti+a; end % Cycloidal Motion function [s,si,ti]=CYC(si,ti,h,a) s=si+h*((sym('x')-ti)/a-1/2/pi*sin(2*pi*(sym('x')-ti)/a)); si=subs(s,ti+a); ezplot(s,[ti,ti+a]) ti=ti+a; end % Constant Velocity function [s,si,ti]=CV(si,ti,h,a) s=si+h/a*((sym('x')-ti)); si=subs(s,ti+a); ezplot(s,[ti,ti+a]) ti=ti+a; end %% The 'Go' Button function go(varargin) % make 3D button disappear until after loading set(D3,'visible','off') % if the button's string is 'stop', do just that if strcmp(get(BB,'string'),'Stop') set(BB,'string','Go') if get(hr,'selectedobject')==hb1 % flat face chosen set(D3,'visible','on') % make 3D button appear end return end % reset all loading 'blocks' to red colour set(hl,'backgroundcolor','r') % get values for the three main edit boxes Types=get(MT,'string'); Disps=[str2num(get(MA,'string'));0];%#ok Durations=str2num(get(MD,'string')).*pi/180;%#ok % reveal axes set(findobj('type','axes'),'visible','on') si=0; % initial displacement is zero ti=0; % initial theta is zero S=[]; % motion equation(s) matrix T=ti; % theta timeline-esque vector % set displacement axes as current one (i.e. all subsequent plots will % be done on it) axes(a1) cla hold on %% Displacement Diagram % the following loop obtains for us the motion equation(s) for the % follower as well as plots the displacement diagram for lp1=1:length(Durations) % go through loop once for every motion type entered pp=ti; % variable used for parabolic motion switch Types(lp1,:) case 'DWL' [s,si,ti]=DWL(si,ti,Durations(lp1)); S=[S;s]; % stack latest motion equation T=[T;ti]; % put latest theta in theta timeline case 'SHM' [s,si,ti]=SHM(si,ti,Disps(lp1),Durations(lp1)); S=[S;s]; T=[T;ti]; case 'PAR' [s1,s2,si,ti]=PAR(si,ti,Disps(lp1),Durations(lp1)); S=[S;s1;s2]; T=[T;(ti+pp)/2;ti]; case 'CYC' [s,si,ti]=CYC(si,ti,Disps(lp1),Durations(lp1)); S=[S;s]; T=[T;ti]; case 'CSV' [s,si,ti]=CV(si,ti,Disps(lp1),Durations(lp1)); S=[S;s]; T=[T;ti]; end end JJ=zeros(length(S),1); %Preallocate to save time! for klp=1:length(S) % get displacements of follower at each of the critical values of theta JJ(klp)=subs(S(klp),T(klp+1)); end % using previous JJ vector set axis limits for displacement diagram axis([0 ti min(JJ)-(max(JJ)-min(JJ))/10-1e-9 max(JJ)+(max(JJ)-min(JJ))/10+1e-9]) title('Displacement') xlabel('Radians') %% Velocity Diagram axes(a2) cla hold on % velocity is the derivative of displacement ;) S1=diff(S); % plot each velocity equation for its equivalent theta range for lp1=1:length(S1) ezplot(S1(lp1),[T(lp1) T(lp1+1)]); end xlim([0 ti]) title('Velocity') xlabel('') %% Acceleration Diagram axes(a3) cla hold on % derivate velocity to obtain acceleration S2=diff(S1); % plot resultant equations for their matching theta ranges for lp1=1:length(S) ezplot(S2(lp1),[T(lp1) T(lp1+1)]); end xlim([0 ti]) title('Acceleration') xlabel('Radians') drawnow() % give user something to look at while he waits for the rest of the % computations %% Cam Profile reR=str2double(get(rR,'string')); % get number of points used to plot x=zeros(1,reR+1); % x points of profile y=zeros(1,reR+1); % y points of profile pa=zeros(1,reR+1); % pressure angles. there is a different pressure angle for each theta, % where it is the angle between the vertical line of motion and the normal % to the tangent of the two contact surfaces rb=str2double(get(BC,'string')); % get base circle radius cc=0; % counter QM=10; % used for loading blocks if get(hr,'selectedobject')==hb1 % flat face chosen who=1; e=0; rd=0; beta=0; else % translating roller follower who=0; rd=str2double(get(t2,'string')); % roller radius e=str2double(get(t4,'string')); % roller offset beta=asin(e/sum([rb,rd])); end % change theta from zeros to 360 degrees for k=0:2*pi/reR:2*pi % increment counter cc=cc+1; % obtain where the current angle is in terms of theta timeline % (i.e. get in which range of angles it is) for p=1:length(T)-1 if k2*pi p2=p2-2*pi; end % next comes the follower motion % get in what range of angles theta lies for p=1:length(T)-1 if p2Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.