{"id":2403,"date":"2022-03-18T22:31:56","date_gmt":"2022-03-18T22:31:56","guid":{"rendered":"https:\/\/blog.metu.edu.tr\/eresmech\/?page_id=2403"},"modified":"2025-02-26T13:26:45","modified_gmt":"2025-02-26T13:26:45","slug":"ek2","status":"publish","type":"page","link":"https:\/\/blog.metu.edu.tr\/eresmech\/mechanisms\/ek2\/","title":{"rendered":"ek2"},"content":{"rendered":"<div id=\"pl-gb2403-69d7910ee5052\"  class=\"panel-layout wp-block-siteorigin-panels-layout-block\" ><div id=\"pg-gb2403-69d7910ee5052-0\"  class=\"panel-grid panel-no-style\" ><div id=\"pgc-gb2403-69d7910ee5052-0-0\"  class=\"panel-grid-cell\" ><div id=\"panel-gb2403-69d7910ee5052-0-0-0\" class=\"so-panel widget widget_sow-editor panel-first-child panel-last-child widgetopts-SO\" data-index=\"0\" ><div\n\t\t\t\n\t\t\tclass=\"so-widget-sow-editor so-widget-sow-editor-base\"\n\t\t\t\n\t\t>\n<div class=\"siteorigin-widget-tinymce textwidget\">\n\t<p style=\"text-align: right\"><b><span style=\"font-size: 300%\">Appendix-2<\/span><\/b><\/p>\n<h1>Function Routines for Simple Mechanisms and Basic Trigonometry<\/h1>\n<p>In practice complex mechanisms are usually formed from the simple four-link mechanism loops connected to each other in series or in parallel. Usually the loops formed form a quadrilateral which can be solved geometrically. If simple function subroutines can be written for the simple mechanisms, these subroutines can be used for the solution of more complex mechanisms. In Excel, these function subroutines can be written in Basic language (Visual Basic for Applications, VBA\u00ae for short). Such function subroutines are very important building block for more complex analysis. Similar subroutines can as well be written in C, Fortran, Pascal or in any other computer language. In this appendix several function subroutines which were found to be very useful in mechanism analysis will be explained and using these functions kinematic analysis of mechanisms with several links will be performed.<\/p>\n<p><span style=\"color: #003399\"><b>2.1. Function routines written in Visual Basic for Applications (VBA)<\/b><\/span><\/p>\n<p><span style=\"color: #003399\"><b>2.1.1 Conversion from rectangular to polar form<\/b><\/span><\/p>\n<p>In Cartesian reference the coordinates of a point in plane is given by its x and y coordinates. If we want to determine the distance OP (magnitude of the vector OP), and the angle the vector makes with respect to the positive x axis, we can write two function routines (<strong>Mag(x,y)<\/strong>\u00a0and\u00a0<strong>Ang(x,y)<\/strong>) to determine the magnitude and the angular orientation of the vector OP defined by (x,y) coordinates (see figure). Note that\u00a0<strong>Ang(x,y)<\/strong>\u00a0function is similar to TAN2(x,y) function in Excel. It uses Atn(x) function in Basic language for the inverse tangent which returns the result within &#8211;<span style=\"font-family: Symbol\">p<\/span>\/2 &lt; <span style=\"font-family: Symbol\">q <\/span>&lt; <span style=\"font-family: Symbol\">p<\/span>\/2. Next the the quadrant in which the angle lies is determined from the values of x and y and correct result is given within the range &#8211;<span style=\"font-family: Symbol\">p <\/span>&lt; <span style=\"font-family: Symbol\">q <\/span>&lt; <span style=\"font-family: Symbol\">p<\/span>\u00a0Outside the function routine, two global constants PI and Eps are defined.<\/p>\n<p>Global Const PI = 3.1415926<br \/>\nGlobal Const Eps = 0.0000001<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-1875\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/09\/image1-6.gif\" alt=\"\" width=\"429\" height=\"351\" \/><\/p>\n<p><strong>Function Mag(X, Y)<\/strong><br \/>\nMag = Sqr(X ^ 2 + Y ^ 2)<br \/>\nEnd Function<\/p>\n<p><strong>Function Ang(X, Y)<\/strong><br \/>\nDim AA<br \/>\nIf Abs(X) &gt; Eps Then<br \/>\nAA = Atn(Y \/ X)<br \/>\nIf X &lt; 0 Then<br \/>\nAA = AA + PI<br \/>\nElse:<br \/>\nIf Y &lt; 0 Then AA = AA + 2*PI<br \/>\nEnd If<br \/>\nElse:<br \/>\nIf Y &gt; 0 Then AA = PI \/ 2 Else AA = -PI \/ 2<br \/>\nEnd If<br \/>\n<span style=\"font-family: Arial, Helvetica, sans-serif\">Ang<\/span>\u00a0= AA<br \/>\nEnd Function<\/p>\n<p><span style=\"color: #003399\"><b>2.1.2. Inverse Sine and Cosine Functions:<\/b><\/span><\/p>\n<p>Normally in most languages\u00a0<strong>Atn(x)<\/strong>&#8211; the inverse tangent function is defined only. when writing programs in basic, we shall need other inverse trigonometric functions such as\u00a0<strong>ASIN(x)<\/strong>\u00a0and\u00a0<strong>ACOS(x)<\/strong>. Although these inverse functions are double valued, only one result is returned. If the user wants to use the other angle he must add or subtract\u00a0<span style=\"font-family: Symbol\">p<\/span>\u00a0to the result.<\/p>\n<p><b>Function Acos(X)<\/b><br \/>\nAcos = Atn(-X \/ Sqr(-X * X + 1)) + 2 * Atn(1)<b><br \/>\nEnd Function<\/b><\/p>\n<p><b>Function Asin(X)<\/b><br \/>\nAsin = Atn(X \/ Sqr(-X * X + 1))<b><br \/>\nEnd Function<\/b><\/p>\n<p><span style=\"color: #003399\"><b>2.1.3. Triangle Solution (Cosine Theorem):<\/b><\/span><\/p>\n<p>During the analysis of mechanisms solution for a triangle is often used. Using the cosine theorem one can determine the angle when the three sides of a triangle is given (<strong><span style=\"font-family: Symbol\">a<\/span>= AngCos(U1,U2,Opposite)<\/strong>) or one can determine the opposite side when the two sides and the included angle\u00a0<span style=\"font-family: Symbol\"><strong>a<\/strong><\/span><strong>\u00a0(ANGLE)<\/strong>\u00a0is given (<strong>Opposite = MagCos(U1,U2;Angle)<\/strong>) (see Figure ) . The following two BASIC functions can give you the result when the three values are given. Note that AngCos() function uses Acos() function which was written in Basic<\/p>\n<p><b>Function A<span style=\"font-family: Arial, Helvetica, sans-serif\">ng<\/span>Cos(<span style=\"font-family: Arial, Helvetica, sans-serif\">U<\/span>1,\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">U<\/span>2, Opposite)<\/b><br \/>\nDim u u = (<span style=\"font-family: Arial, Helvetica, sans-serif\">U<\/span>1 *\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">U<\/span>1 +\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">U<\/span>2 *\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">U<\/span>2 &#8211;\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">Opposite<\/span>\u00a0*\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">Opposite<\/span>) \/ (2 * u1 * u2)<br \/>\nAA = Acos(u)<br \/>\nA<span style=\"font-family: Arial, Helvetica, sans-serif\">ng<\/span>Cos = AA<b><br \/>\nEnd Function<\/b><\/p>\n<p><b>Function MagCos(U1, U2,<span style=\"font-family: Arial, Helvetica, sans-serif\">Angle<\/span>)<\/b><br \/>\n<span style=\"font-family: Arial, Helvetica, sans-serif\">Mag<\/span>Cos = (U1 ^ 2 + U2 ^ 2 &#8211; 2 * U1 * U2 * Cos(<span style=\"font-family: Arial, Helvetica, sans-serif\">Angle<\/span>)) \/ (2 * U1 * U2)<b><br \/>\nEnd Function<\/b><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2405\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image2e.gif\" alt=\"\" width=\"367\" height=\"240\" \/><\/p>\n<p><span style=\"color: #003399\"><b>2.1.4. Position Analysis of Simple Mechanisms:<\/b><\/span><\/p>\n<p><span style=\"color: #003399\">2.1.4-a) Four-Bar Mechanism<\/span><\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2406 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image3ee1copy.gif\" alt=\"\" width=\"1224\" height=\"797\" \/><\/p>\n<p style=\"text-align: left\" align=\"center\">Three function subroutines have been written to determine the unknown position variables in a four-bar mechanism when the link lengths, the configuration in which the links are assembled and the input crank angle are given. All three functions require the same input parameters output from the\u00a0<strong>FourBar()\u00a0<\/strong>function is the rocker angle whereas for\u00a0<strong>FourBarCoupler()<\/strong>\u00a0it is the coupler angle. In case of\u00a0<strong>FourBar2()<\/strong> function there are two outputs as [Coupler Angle, Rocker Angle] The user must type +1 or \u20131 for the Config variable depending whether the mechanism is assembled in open or crossed form respectively.<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2407\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image3e-copy-1.gif\" alt=\"\" width=\"726\" height=\"292\" \/><\/p>\n<p>Note that this program uses Ang() and Mag() and AngCos() functions. These functions must be available for this function routine (i.e you cannot use these functions alone).<\/p>\n<p><strong>Function FourBar(Crank, Coupler, Rocker, Fixed, Config, Theta)<\/strong><br \/>\n<span style=\"color: #008080\">&#8216;Determines the output rocker angle wr to the fixed link<\/span><br \/>\nDim S, Fi, Si As Double \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Dim sx, sy As Double<br \/>\nsx = -Fixed + Crank * Cos(Theta)<br \/>\nsy = Crank * Sin(Theta)<br \/>\nS = Mag(sx, sy)<br \/>\nFi = Ang(sx, sy)<br \/>\nSi = AngCos(Rocker, S, Coupler)<br \/>\nFourBar = Fi &#8211; Config * Si<br \/>\nEnd Function<\/p>\n<p><strong>Function FourBrCoupler(Crank, Coupler, Rocker, Fixed, Config, Theta)<\/strong><br \/>\n<span style=\"color: #008080\">&#8216;Determines the coupler link angle wr to the fixed link<\/span><br \/>\nDim S, Fi, Si, Mu As Double<br \/>\nDim sx, sy, Theta14 As Double<br \/>\nsx = -Fixed + Crank * Cos(Theta)<br \/>\nsy = Crank * Sin(Theta)<br \/>\nS = Mag(sx, sy)<br \/>\nFi = Ang(sx, sy)<br \/>\nSi = AngCos(Rocker, S, Coupler)<br \/>\nTheta14 = Fi &#8211; Config * Si<br \/>\nMu = AngCos(Coupler, Rocker, S)<br \/>\nFourBrCoupler = Theta14 &#8211; Config * Mu<br \/>\nEnd Function<\/p>\n<p><strong>Function FourBar2(Crank, Coupler, Rocker, Fixed, Config, Theta)<\/strong><br \/>\n<span style=\"color: #008040\">&#8216;Determines the both the coupler link and the rocker angles with respect to the fixed link<br \/>\n&#8216;first term is coupler angle<\/span><br \/>\nDim S, Fi, Si As Double<br \/>\nDim sx, sy As Double<br \/>\nDim A(2)<br \/>\nsx = -Fixed + Crank * Cos(Theta)<br \/>\nsy = Crank * Sin(Theta)<br \/>\nS = Mag(sx, sy)<br \/>\nFi = Ang(sx, sy)<br \/>\nSi = AngCos(Rocker, S, Coupler)<br \/>\nMu = AngCos(Coupler, Rocker, S)<br \/>\nA(1) = Fi &#8211; Config * Si<br \/>\nA(0) = A(1) &#8211; Config * Mu<br \/>\nFourBar2 = A<br \/>\nEnd Function<\/p>\n<p><span style=\"color: #003399\">2.1.4-b) Slider-Crank Mechanism:<\/span><\/p>\n<p>For the slider crank mechanism shown again three different function programs are written.\u00a0<strong>SliderCrank()<\/strong>\u00a0gives the slider displacement s<sub>14<\/sub>,\u00a0<strong>SliderCrankCoupler()<\/strong>\u00a0coupler angle\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>13<\/sub>\u00a0and\u00a0<strong>SliderCrank2()<\/strong>) which gives both the coupler angle and the slider displacement [<span style=\"font-family: Symbol\">q<\/span><sub>13<\/sub>,s<sub>14<\/sub>] for given link lengths and corresponding crank angle\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>12<\/sub>\u00a0(Theta) . .<\/p>\n<p>The user must type Config as +1 or -1 depending on the position of the slider with respect to the crank.<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2408 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image4e-copy.gif\" alt=\"\" width=\"943\" height=\"347\" \/><\/p>\n<p><strong>Function SliderCrank(Crank, Coupler, Eccentricity, Config, Theta)<\/strong><br \/>\n<span style=\"color: #008040\">&#8216;Determines the slider displacement<\/span><br \/>\nDim Fi As Double<br \/>\nFi = Asin((Crank * Sin(Theta) &#8211; Eccentricity) \/ Coupler)<br \/>\nIf Config = 1 Then Fi = 4 * Atn(1) &#8211; Fi<br \/>\nSliderCrank = Crank * Cos(Theta) &#8211; Coupler * Cos(Fi)<br \/>\nEnd Function<\/p>\n<p><strong>Function SliderCrank2(Crank, Coupler, Eccentricity, Config, Theta)<\/strong><br \/>\n<span style=\"color: #008040\">\u00a0&#8216;Determines both the slider displacement and the coupler link angle<\/span><br \/>\nDim Fi As Double<br \/>\nDim A(2) As Double<br \/>\nFi = Asin((Crank * Sin(Theta) &#8211; Eccentricity) \/ Coupler)<br \/>\nIf Config = 1 Then Fi = 4 * Atn(1) &#8211; Fi<br \/>\nA(0) = Fi<br \/>\nA(1) = Crank * Cos(Theta) &#8211; Coupler * Cos(Fi)<br \/>\nSliderCrank2 = A<br \/>\nEnd Function<\/p>\n<p><strong>Function SliderCrankCoupler(Crank, Coupler, Eccentricity, Config, Theta)<\/strong><br \/>\n<span style=\"color: #008040\">&#8216;Determines the coupler link angle<\/span><br \/>\nDim Fi As Double<br \/>\nFi = Asin((Crank * Sin(Theta) &#8211; Eccentricity) \/ Coupler)<br \/>\nIf Config = 1 Then Fi = 4 * Atn(1) &#8211; Fi<br \/>\nSliderCrankCoupler = Fi<br \/>\nEnd Function<\/p>\n<p><span style=\"color: #003399\">2.1.4-c) Inverted Slider-Crank Mechanism:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2409 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image5e2.gif\" alt=\"\" width=\"1174\" height=\"465\" \/><\/p>\n<p>For the inverted slider crank mechanism shown the visual basic function routine is\u00a0<strong>Invslider2(Crank, Fixed, Eccentricity, Alfa, Config, Theta)<\/strong>\u00a0Config can be +1 or -1 according to the way the mechanism is assembled. This function returns the slider displacement s and the output link angle\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>14<\/sub>.<\/p>\n<p><strong><span style=\"color: #000000\">Function InvSlider2(Crank, Fixed, Eccentricity, Alfa, Config, Theta)<\/span><\/strong><br \/>\n<span style=\"color: #008040\">&#8216;Determines the slider displacement and the output link angle for an inverted slider-crank mechanism<br \/>\n&#8216;For centric inverted slider you must select both eccentricity and angle alfa as zero<\/span><br \/>\nDim A(2) As Double<br \/>\nDim S, Fi, Si, Q, Delta As Double<br \/>\nDim sx, sy As Double<br \/>\nsx = -Fixed + Crank * Cos(Theta)<br \/>\nsy = Crank * Sin(Theta)<br \/>\nS = Mag(sx, sy)<br \/>\nFi = Ang(sx, sy)<br \/>\nDelta = S ^ 2 &#8211; Eccentricity ^ 2 * Sin(Alfa) ^ 2<br \/>\nQ = -Eccentricity * Cos(Alfa) + Sqr(Delta)<br \/>\nSi = Ang((Eccentricity + Q * Cos(Alfa)), Q * Sin(Alfa))<br \/>\nA(0) = Q<br \/>\nA(1) = Fi &#8211; Config * Si<br \/>\nInvSlider2 = A<br \/>\nEnd Function<\/p>\n<p>In case of a centric inverted slider-crank mechhanism the same program can be used by selecting the parameters Eccentricity=0 and Alfa=0 or Another function can be written. Also instead of two outputs you may want to have one output only.<\/p>\n<p><span style=\"color: #ff2020\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/04\/important.gif\" alt=\"\" width=\"28\" height=\"27\" \/> Write a function routine for the solution of a centric inverted slider crank mechanism.(and Call it <strong>InvSliderCrankCentric()<\/strong>)<\/span><\/p>\n<p><span style=\"color: #ff2020\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/04\/important.gif\" alt=\"\" width=\"28\" height=\"27\" \/> Write a function routine that gives <span style=\"font-family: Symbol\">q<\/span><sub>14<\/sub>\u00a0as the output only (and Call it\u00a0<strong>InvSliderCrank()<\/strong>)<\/span><\/p>\n<p>All the above functions are written in Visual basic and is available as Basic.bas file <a href=\"http:\/\/www.makted.org.tr\/Kinematic_Synthesis_of_Mechanisms\/Chapter2\/BASIC.bas\">here<\/a>. If you want to use these files in an excel sheet, switch to (and Call it <strong>InvSliderCrank()<\/strong>)Visual Basic editor (From the tools menu select macro and Visual Basic Editor of simply press\u00a0<strong>Alt+F11<\/strong>\u00a0buttons) and then from the file menu select &#8220;import file&#8221; (or\u00a0<strong>Ctrl+M<\/strong>) and import Basic.bas file as a module. Now, when you are on an Excel Sheet you can use any of the above functions (use &#8220;insert&#8221; menu- &#8220;functions&#8221; and &#8220;user defined&#8221; type. You will be able to see all the above functions)<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff2020\">Example <\/span><\/p>\n<p>Using these build in functions, analysis of mechanisms with several loops simplify to a very great extent. These functions can be used for the analysis of complex mechanisms.<\/p>\n<p>The six link mechanism shown below is composed of a four-bar and a slider crank mechanism connected in series.We are to determine the displacement of the slide s, for a given value of the crank angle th. Once the mechanisms that form the structure are identified, we can break the analysis in two parts. First for a given input crank angle th (link 2) we determine the angular position of link 4 (th4) using the\u00a0<strong>FourBar()<\/strong>\u00a0function. Next Using (<span style=\"font-family: Symbol\">q<\/span><sub>14<\/sub>&#8211;<span style=\"font-family: Symbol\">a<\/span>) as the input crank angle of link 4 we determine the horizontal distance B<sub>0<\/sub>D of the slider using\u00a0<strong>SliderCrank()\u00a0<\/strong>function. s=B<sub>0<\/sub>D<sub>x<\/sub>+B<sub>0<\/sub>A<sub>0x<\/sub>\u00a0B<sub>0<\/sub>A<sub>0x<\/sub>=1250 mm given.<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2410 size-full aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image6e2.gif\" alt=\"\" width=\"1058\" height=\"545\" \/><\/p>\n<p>On the excel Sheet let us first enter the known link dimensions (lengths and angles).<\/p>\n<table border=\"1\" width=\"92%\">\n<tbody>\n<tr bgcolor=\"#CCCCCC\">\n<td><\/td>\n<td align=\"center\">A<\/td>\n<td align=\"center\">B<\/td>\n<td align=\"center\">C<\/td>\n<td align=\"center\">D<\/td>\n<td align=\"center\">E<\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">1<\/td>\n<td>Four_Bar<\/td>\n<td><\/td>\n<td>Slider-Crank<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">2<\/td>\n<td>Crank<\/td>\n<td>320<\/td>\n<td>Crank 2<\/td>\n<td>1050<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">3<\/td>\n<td>Coupler<\/td>\n<td>1180<\/td>\n<td>Coupler 2<\/td>\n<td>1140<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">4<\/td>\n<td>Rocker<\/td>\n<td>528<\/td>\n<td>Eccentric<\/td>\n<td>400<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">5<\/td>\n<td>Fixed_Lx<\/td>\n<td>1250<\/td>\n<td>Alfa4<\/td>\n<td>0.43633231<\/td>\n<td>25<\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">6<\/td>\n<td>Fixed_Ly<\/td>\n<td>546<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">7<\/td>\n<td>Fixed_Link<\/td>\n<td>1364.044<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">8<\/td>\n<td>Fixed Angle<\/td>\n<td>2.72977<\/td>\n<td>156.40429<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"center\" bgcolor=\"#CCCCCC\">9<\/td>\n<td>Alfa1<\/td>\n<td>0.411823<\/td>\n<td>23.595705<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>From the given x and y lengths (Fixed_Lx and Fixed_Ly) the fixed link length is determined by using the function mag() as\u00a0<strong>mag(B5;B6<\/strong>) in cell B7. in cell B8 we determine the angle B<sub>0<\/sub>A<sub>0<\/sub> vector makes with the horizontal using ATAN2() Excel function in the form ATAN2(-B5;B6). angle Afa1 is obtained by typing &#8220;=pi()-B8&#8221; into cell B9. In cell E5 the angle BB<sub>0<\/sub>C =Alfa4 is entered in degrees and it is converted to radians in\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">c<\/span>ell D5 . Cells in columns B ve D are named cells whose names are the labels entered left of the corresponding cell (i.e. Cell B7 is named as &#8220;Crank&#8221;, Cell D3 is named as &#8220;Coupler_2&#8221;, etc.)<\/p>\n<p>Now into cells A16-A40 the input crank angle, Th, from 0 to 360 degrees at 15<sup>0<\/sup>\u00a0interval is entered.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2411 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image7e.gif\" alt=\"\" width=\"623\" height=\"569\" \/><\/p>\n<p>The angle Th entered in column A is\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>12\u00a0<\/sub>shown on the sketch. This is the angle link 2 makes with respect to a horizontal line, not with respect to A<sub>0\u00a0<\/sub>B<sub>0\u00a0<\/sub>. In column B after converting\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>12\u00a0<\/sub>into radians the angle Alfa1 Given in cell B9 is added by typing\u00a0<strong>&#8220;=A16*PI()\/180+Alfa1&#8221;<\/strong>\u00a0into cell B16 and copying this formula from B16-B40. (If you have not named cell B9 as &#8220;Alfa1&#8221;, then you must type $B$9 to fix this cell. Into cell C16 type<\/p>\n<p>&#8220;<b>=FourBar(Crank;Coupler;Rocker;Fixed_Link;1;B16)-Alfa1<\/b>&#8220;<br \/>\nor<br \/>\n&#8220;<b>=FourBar($B$2;$B$3;$B$4;$B$7;1;B16)-$B$9<\/b>&#8220;<\/p>\n<p>Using the FourBar() function You have calculated the angular position of link 4 with respect to the horizontal,\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>14\u00a0<\/sub>. When the formula is copied for cells C17-C40,<span style=\"font-family: Symbol\">q<\/span><sub>14\u00a0<\/sub>is determined in radians for every input crank angle\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>12\u00a0<\/sub>given in column A. In column D you can convert the angle\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>14\u00a0<\/sub>into degrees. Now, we can solve the slider crank mechanism (Links 1,4,5 and 6). Into cell E16 if we type:<\/p>\n<p>&#8220;<b>=SliderCrank(Crank2;Coupler2;Eccentric;1;(C15-Alfa4)) + Fixed_Lx<\/b>&#8220;<br \/>\nor<br \/>\n&#8220;<b>=SliderCrank($D$2;$D$3;$D$4;1;(C15-$D$5)) + $B$5<\/b>&#8220;<\/p>\n<p>We determine the distance S for the crank angle given at A16. When this formula is copied into cells E17-E40, you have determined the slider displacement for every 15<sup>0<\/sup>\u00a0of the crank angle. Using Excel Chart menu you can plot S displacement as a function of input crank angle\u00a0<span style=\"font-family: Symbol\">q<\/span><sub>12<\/sub>\u00a0as shown below. .<\/p>\n<p>Now into cells A16-A40 the input crank angle, Th, from 0 to 360 degrees at 15<sup>0<\/sup>\u00a0interval is entered.<\/p>\n<p align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2412 size-full aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image8ee.gif\" alt=\"\" width=\"686\" height=\"399\" \/><\/p>\n<p style=\"text-align: center\" align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1883\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/09\/image9-1.gif\" alt=\"\" width=\"600\" height=\"467\" \/> <span style=\"color: #000099\">Fig a<\/span><\/p>\n<p style=\"text-align: center\" align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1884\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/09\/image10-1.gif\" alt=\"\" width=\"591\" height=\"513\" \/> <span style=\"color: #000099\">Fig b<\/span><\/p>\n<p>What if the slider-crank part of the mechanism is assembled differently as shown in Figures a and b? The Four-bar solution will not change. In Fig a since the input to the slider-crank mechanism must be along the slider axis, the input crank angle will be:<span style=\"font-family: Symbol\">\u00a0q<\/span><sub>14<\/sub>\u00a0&#8211;<span style=\"font-family: Symbol\">a<\/span><sub>4<\/sub>+<span style=\"font-family: Symbol\">p<\/span>\/2 . To determine S,vertical displacement of the slider 6, into cell E16<span style=\"font-family: Arial, Helvetica, sans-serif\">\u00a0<\/span>type:<\/p>\n<p>&#8220;<b>=SliderCrank(Crank2 ;Coupler2 ;Eccentric ;1;(C15-Alfa4+PI()\/2))<\/b>&#8220;<\/p>\n<p>and then copy this formula into cells E17-E40. For the mechanism shown in Figure b, in cell E16 the slider-<span style=\"font-family: Arial, Helvetica, sans-serif\">c<\/span>rank formula for the determination of slider displacement will be in the form:<\/p>\n<p>&#8220;<b>= -SliderCrank(crank2 ;Coupler2 ;Eccentric ;-1;(C15-Alfa4+PI()\/2))\u00a0<\/b>&#8220;<\/p>\n<p>Note that the slider displacement is considered po<span style=\"font-family: Arial, Helvetica, sans-serif\">s<\/span>itive when moving downwards in\u00a0<span style=\"font-family: Arial, Helvetica, sans-serif\">case (a) and upwards in case (b)<\/span>. In the second case the configuration is -1, since the me<span style=\"font-family: Arial, Helvetica, sans-serif\">chanism is assembled in the second form<\/span>. The slider displacement for the mechanism shown in (a) is as shown in (c) and that of (b) is shown in(d) (In Figure d there is a double hump. why?).<\/p>\n<p style=\"text-align: center\" align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2413 size-full aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image11e.gif\" alt=\"\" width=\"695\" height=\"453\" \/> \u00a0<span style=\"color: #000099\">Fig c<\/span><\/p>\n<p style=\"text-align: center\" align=\"center\"><span style=\"color: #000099\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2414 size-full aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image12e.gif\" alt=\"\" width=\"671\" height=\"422\" \/>Fig d<\/span><\/p>\n<p><a href=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/09\/sixlink.xls\">Click here for the Excel file<\/a><\/p>\n<p><span style=\"color: #003399\"><b>2.2. Basic trigonometry and simple mechanisms function files in MathCad<\/b><\/span><\/p>\n<p>One can also write the basic function routines within mathematical packages such as MathCad or Matlab. When Mathcad is used these functions can be written as:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2410 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image6e2.gif\" alt=\"\" width=\"1058\" height=\"545\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2412 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image8ee.gif\" alt=\"\" width=\"686\" height=\"399\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2413 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image11e.gif\" alt=\"\" width=\"695\" height=\"453\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2414 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image12e.gif\" alt=\"\" width=\"671\" height=\"422\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2415\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image13e.gif\" alt=\"\" width=\"658\" height=\"192\" \/><\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2416\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image14e_1.gif\" alt=\"\" width=\"180\" height=\"116\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2417\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image14e_2.gif\" alt=\"\" width=\"151\" height=\"146\" srcset=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image14e_2.gif 151w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image14e_2-100x97.gif 100w\" sizes=\"auto, (max-width: 151px) 100vw, 151px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2418 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image3e.gif\" alt=\"\" width=\"726\" height=\"292\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2419 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image15e.gif\" alt=\"\" width=\"632\" height=\"576\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2420 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image4e.gif\" alt=\"\" width=\"943\" height=\"347\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2421 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image16e.gif\" alt=\"\" width=\"757\" height=\"492\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2422 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image18e.gif\" alt=\"\" width=\"633\" height=\"413\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2423 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/image17e.gif\" alt=\"\" width=\"749\" height=\"597\" \/><\/p>\n<p align=\"left\">Note that for the inverted slider-crank mechanism, the file written in MathCAD is for a different model of inverted slider-crank mechanism than the one written in VBA for Excel. When all the functions are written on a MathCAD sheet and saved as a MathCAD file (say <a href=\"https:\/\/ocw.metu.edu.tr\/pluginfile.php\/3961\/mod_resource\/content\/12\/appendices\/ek2\/BasicMechanisms2000.mcd\">BasicMechanisms.mcd<\/a> or <a href=\"https:\/\/ocw.metu.edu.tr\/pluginfile.php\/3961\/mod_resource\/content\/12\/appendices\/ek2\/BasicMechanisms2000.xmcd\">BasicMechanisms.xmcd<\/a>). Whenever you want to use this file in another MathCAD sheet, from the Insert menu select \u201creference\u201d and insert the name and the location of the file onto the new sheet. The result will be seen similar to the following line:<\/p>\n<p style=\"text-align: center\" align=\"left\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3136\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2025\/02\/image19e.gif\" alt=\"\" width=\"567\" height=\"26\" \/><\/p>\n<p align=\"left\">Of course, the place and the name of the file you have referenced must be different than the one seen above. Now on this MathCAD sheet you can use the functions that you have defined as if it is a standard MathCAD function.<\/p>\n<div align=\"center\">\n<p align=\"left\"><span style=\"color: #ff0000;font-size: x-large\"><strong>Example<\/strong><\/span><\/p>\n<p style=\"text-align: left\">Consider the baler mechanism shown<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2424 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2.jpg\" alt=\"\" width=\"655\" height=\"663\" srcset=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2.jpg 655w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-296x300.jpg 296w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-100x101.jpg 100w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-150x152.jpg 150w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-200x202.jpg 200w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-300x304.jpg 300w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-450x455.jpg 450w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/Bale2-600x607.jpg 600w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n<p style=\"text-align: left\">|A<sub>0<\/sub>A| = |A<sub>0<\/sub>A&#8217;| = a<sub>2<\/sub>\u00a0;\u00a0 |AB| = a<sub>3<\/sub>\u00a0; |BB<sub>0<\/sub>| = a<sub>4<\/sub> ; |BC| = b<sub>3<\/sub>\u00a0; A<sub>0<\/sub>Q=b<sub>1<\/sub>; QB<sub>0<\/sub>\u00a0=a<sub>1<\/sub>; |CD| = a<sub>5<\/sub> ; |AD| = a<sub>6<\/sub> ; |DE| = b<sub>6<\/sub> ; &lt;A<span style=\"color: #008080\">&#8216;<\/span>DE = <span style=\"font-family: Symbol\">g<\/span><sub>6<\/sub><\/p>\n<p style=\"text-align: left\"><a href=\"https:\/\/ocw.metu.edu.tr\/pluginfile.php\/3961\/mod_resource\/content\/12\/appendices\/ek2\/Baler.htm\">Click for the solution in MathCad<\/a><\/p>\n<p style=\"text-align: left\"><a href=\"https:\/\/ocw.metu.edu.tr\/pluginfile.php\/3961\/mod_resource\/content\/12\/appendices\/ek2\/Baler.xmcd\">Click to download Baler.xmcd file<\/a><\/p>\n<p style=\"text-align: left\"><a href=\"http:\/\/Click for the avi file created using MathCad\">Click for the avi file created using MathCad<\/a><\/p>\n<p style=\"text-align: left\"><span style=\"color: #003399\"><b>2.3. Basic trigonometry and simple mechanisms function files in MatLab<\/b><\/span><\/p>\n<p style=\"text-align: left\">In case of Matlab\u00ae\u00a0 each of the above functions must be written as separate m-files with the name of the function as the file name. When you place these m-files into the MatLab workspace, you can use these functions in another m file. The above codes written in Mathcad and in Excel (in Basic language) are written as m-files in Matlab as:<\/p>\n<p style=\"text-align: left\">function ac=angcos(u1,u2,opposite)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">apply cosine theorem to determine an angle when the three sides are known<\/span><br \/>\nu=(u1^2+u2^2-opposite^2)\/(2*u1*u2);<br \/>\nac=acos(u);<\/p>\n<div style=\"text-align: left\">\n<p>function mc=magcos(u1,u2,angle)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">apply cosine theorem to determine one side of the triangle when the two sides and the included angle is known<\/span><br \/>\nmc=sqrt(u1^2+u2^2-2*u1*u2*cos(angle));<\/p>\n<p>function mag=mag(x,y)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">Determine the hypotenus of a right angled triangle when the other two sides (x,y) are given<\/span><br \/>\nmag=sqrt(x^2+y^2);<\/p>\n<\/div>\n<p style=\"text-align: left\">function fb=fourbar(crank,coupler,rocker,fixed,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">Fourbar function to determine the rocker angle<\/span><br \/>\nsx=-fixed+crank*cos(theta);<br \/>\nsy=crank*sin(theta);<br \/>\ns=abs(sx+i*sy);<br \/>\nfi=angle(sx+i*sy);<br \/>\nsi=angcos(rocker,s,coupler);<br \/>\nfb=fi-config*si;<\/p>\n<p style=\"text-align: left\">function fbc=fourbarcoupler(crank,coupler,rocker,fixed,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">Fourbar function to determine the coupler angle<\/span><br \/>\nsx=-fixed+crank*cos(theta);<br \/>\nsy=crank*sin(theta);<br \/>\ns=abs(sx+i*sy);<br \/>\nfi=angle(sx+i*sy);<br \/>\nsi=angcos(rocker,s,coupler);<br \/>\ntheta4=fi-config*si;<br \/>\nmu=angcos(coupler,rocker,s);<br \/>\nfbc=theta4-config*mu;<\/p>\n<p style=\"text-align: left\">function fb2=fourbar2(crank,coupler,rocker,fixed,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">Fourbar function to determine both the coupler and rocker angle. This function returns an array of two elements<\/span><br \/>\nfb2=zeros(1,2);<br \/>\nsx=-fixed+crank*cos(theta);<br \/>\nsy=crank*sin(theta);<br \/>\ns=abs(sx+i*sy);<br \/>\nfi=angle(sx+i*sy);<br \/>\nsi=angcos(rocker,s,coupler);<br \/>\nmu=angcos(coupler,rocker,s);<br \/>\nfb2(2)=fi-config*si;<br \/>\nfb2(1)=fb2(2)-config*mu;<\/p>\n<p style=\"text-align: left\">function sc=slidercrank(crank,coupler,eccentricity,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">determines the slider displacenet of a slider crank mechanism for a given crank angle and link lengths<\/span><br \/>\nfi=asin((crank*sin(theta)-eccentricity)\/coupler);<br \/>\nif config==1<br \/>\nfi=pi-fi;<br \/>\nend<br \/>\nsc=crank*cos(theta)-coupler*cos(fi);<\/p>\n<p style=\"text-align: left\">function scc=slidercrankcoupler(crank,coupler,eccentricity,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">determines the coupler angle of a slider crank mechanism for a given crank angle and link lengths<\/span><br \/>\nfi=asin((crank*sin(theta)-eccentricity)\/coupler);<br \/>\nif config==1<br \/>\nfi=pi-fi;<br \/>\nend<br \/>\nscc=fi;<\/p>\n<p style=\"text-align: left\">function sc2=slidercrank2(crank,coupler,eccentricity,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">%<\/span><span style=\"color: #00ff00\">determines both the coupler angle and slider displacement of a slider crank mechanism for a given crank angle and link lengths<\/span><br \/>\nsc2=zeros(1,2);<br \/>\nfi=asin((crank*sin(theta)-eccentricity)\/coupler);<br \/>\nif config==1<br \/>\nfi=pi-fi;<br \/>\nend<br \/>\nsc2(1)=fi;<br \/>\nsc2(2)=crank*cos(theta)-coupler*cos(fi);<\/p>\n<p style=\"text-align: left\">function inv=invslider(crank,fixed,eccentricity,alpha,config,theta)<br \/>\n<span style=\"color: #00ff00;font-family: Arial, Helvetica, sans-serif\">$<\/span><span style=\"color: #00ff00\">determines the output link angle of an inverted slider crank mechanism for a given crank angle and link lengths<\/span><br \/>\nsx=-fixed+crank*cos(theta);<br \/>\nsy=crank*sin(theta);<br \/>\ns=abs(sx+i*sy);<br \/>\nfi=angle(sx+i*sy);<br \/>\ndelta=s^2-eccentricity^2*sin(alpha)^2;<br \/>\nq=-eccentricity*cos(alpha)+sqrt(delta);<br \/>\nsi=angle(eccentricity+q*cos(alpha)+i*q*sin(alpha));<br \/>\ninv=fi-config*si;<\/p>\n<p style=\"text-align: left\">function inv2=invslider2(crank,fixed,eccentricity,alpha,config,theta)<br \/>\n<span style=\"color: #00ff00\">%determines both the output angle and the relative displacement of the slide of an inverted slider crank mechanism for a given crank angle and link lengths<\/span><br \/>\ninv2=zeros(1,2);<br \/>\nsx=-fixed+crank*cos(theta);<br \/>\nsy=crank*sin(theta);<br \/>\ns=abs(sx+i*sy);<br \/>\nfi=angle(sx+i*sy);<br \/>\ndelta=s^2-eccentricity^2*sin(alpha)^2;<br \/>\nq=-eccentricity*cos(alpha)+sqrt(delta);<br \/>\nsi=angle(eccentricity+q*cos(alpha)+i*q*sin(alpha));<br \/>\ninv2(1)=q;<br \/>\ninv2(2)=fi-config*si;<\/p>\n<p style=\"text-align: left\"><a href=\"https:\/\/ocw.metu.edu.tr\/pluginfile.php\/3961\/mod_resource\/content\/12\/appendices\/ek2\/Basic%20M%20files.rar\">Click here to obtain the above Basic M files (Basic M files.rar)<\/a>.<\/p>\n<p style=\"text-align: left\"><span style=\"color: #ff0000;font-size: medium\"><strong>Example<\/strong><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2425 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1.jpg\" alt=\"\" width=\"607\" height=\"174\" srcset=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1.jpg 607w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1-300x86.jpg 300w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1-100x29.jpg 100w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1-150x43.jpg 150w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1-200x57.jpg 200w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1-450x129.jpg 450w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab1-600x172.jpg 600w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/p>\n<p style=\"text-align: left\">For the mechanism shown input is the crank angle th and we would like to simulate the mechanism the link dimensiona are<br \/>\n|B<sub>0<\/sub>Q| = a<sub>1<\/sub>\u00a0= 526, |A<sub>0<\/sub>Q| = b<sub>1<\/sub>\u00a0= 75, |A<sub>0<\/sub>A| = a<sub>2<\/sub>= 135, |B<sub>0<\/sub>B| = a<sub>4<\/sub>\u00a0= 826, |BC| = a<sub>5<\/sub>\u00a0= 481.<\/p>\n<p style=\"text-align: left\">The m file written for this example is :<\/p>\n<p style=\"text-align: left\">clc\u00a0<span style=\"color: #00ff00\">%Clear Command Window<\/span><br \/>\nclf\u00a0<span style=\"color: #00ff00\">%Clear figure windows<\/span><br \/>\nclear\u00a0<span style=\"color: #800080\">all<\/span>\u00a0<span style=\"color: #00ff00\">%Clear all in the workspace<\/span><br \/>\ndeg=180\/pi;\u00a0<span style=\"color: #00ff00\">%To convert radians to degrees<\/span><br \/>\na1=526; b1=75; c1=75; a2=135; a4=826; a5=481;<span style=\"color: #00ff00\">\u00a0%Link length definitions<\/span><br \/>\nfor i=1:1:144<br \/>\nth12=5*i\/deg;<br \/>\nth_12(i)=i;<br \/>\nalpha1=atan2(-b1,-a1);<br \/>\nd1=mag(a1,b1);<br \/>\nth14=invslider(a2,d1,0,0,1,th12-alpha1)+alpha1;<br \/>\nBx=-a1+a4*cos(th14);<br \/>\nBy=-b1+a4*sin(th14);<br \/>\nS=mag(Bx,By);<br \/>\nfi=atan2(By,Bx);<br \/>\ns16=slidercrank(S,a5,c1,1,fi);<br \/>\nA0x=0; A0y=0;<br \/>\nth_14(i)=mod(th14*deg,360);<br \/>\ns_16(i)=s16;<br \/>\nA0x=0; A0y=0; B0x=-a1; B0y=-b1;<br \/>\nAx=a2*cos(th12); Ay=a2*sin(th12);<br \/>\nCx=s16; Cy=c1;<br \/>\nx1=[A0x,Ax]; y1=[A0y,Ay];\u00a0<span style=\"color: #00ff00\">%Joint locations of the links<\/span><br \/>\nx2=[B0x,Bx]; y2=[B0y,By]; x3=[Bx,Cx]; y3=[By,Cy];<br \/>\nt1=30; t2=50; %Thickness values for slider boxes<br \/>\nbox11x=Ax+t1*cos(th14+pi\/2)+t2*cos(th14);\u00a0<span style=\"color: #00ff00\">%Slider 3 box corners<\/span><br \/>\nbox11y=Ay+t1*sin(th14+pi\/2)+t2*sin(th14);<br \/>\nbox12x=box11x-2*t2*cos(th14); box12y=box11y-2*t2*sin(th14);<br \/>\nbox13x=box12x+2*t1*cos(th14-pi\/2); box13y=box12y+2*t1*sin(th14-pi\/2);<br \/>\nbox14x=box13x+2*t2*cos(th14); box14y=box13y+2*t2*sin(th14);<br \/>\nx4=[box11x,box12x,box13x,box14x,box11x];<br \/>\ny4=[box11y,box12y,box13y,box14y,box11y];<br \/>\nbox21x=Cx+t2; box21y=Cy+t1;\u00a0<span style=\"color: #00ff00\">%Slider 6 box corners<\/span><br \/>\nbox22x=box21x-2*t2; box22y=box21y;<br \/>\nbox23x=box22x; box23y=box22y-2*t1;<br \/>\nbox24x=box23x+2*t2; box24y=box23y;<br \/>\nx5=[box21x,box22x,box23x,box24x,box21x];<br \/>\ny5=[box21y,box22y,box23y,box24y,box21y];<br \/>\nplot(x1,y1,&#8217;<span style=\"color: #800080\">r-o&#8217;<\/span>,x2,y2,&#8217;<span style=\"color: #800080\">g-o<\/span>&#8216;,x3,y3,&#8217;<span style=\"color: #800080\">b-o<\/span>&#8216;,x4,y4,&#8217;<span style=\"color: #800080\">m-&#8216;<\/span>,x5,y5,<span style=\"color: #800080\">&#8216;c-<\/span>&#8216;,&#8217;<span style=\"color: #800080\">LineWidth&#8217;<\/span>,2.5)<br \/>\naxis\u00a0<span style=\"color: #800080\">equal<\/span><br \/>\ngrid\u00a0<span style=\"color: #800080\">on<\/span><br \/>\naxis([-1.1*a1 2*a5 -3*b1 2*a2])<br \/>\nhold on<\/p>\n<p style=\"text-align: left\">pause(0.01)<br \/>\nif(i &lt; 144)<br \/>\nclf<br \/>\nend<br \/>\nend<br \/>\nfigure\u00a0<span style=\"color: #00ff00\">%Insert a new figure window<\/span><br \/>\nplot(th_12*5,s_16)<br \/>\ntitle(<span style=\"color: #8000ff\">&#8216;Variation of s16 with respect to th12<\/span>&#8216;)<br \/>\nxlabel(<span style=\"color: #800080\">&#8216;th12&#8217;<\/span>)<br \/>\nylabel(&#8216;<span style=\"color: #800080\">s16&#8242;<\/span>)<br \/>\ngrid on<br \/>\nxlim([0 360])<br \/>\nylim([650 800])<\/p>\n<p style=\"text-align: left\">The result is the simulation of the mechjanism and the s16 versus crank angle plot as shown in Figure below.<\/p>\n<p style=\"text-align: left\"><a href=\"https:\/\/ocw.metu.edu.tr\/pluginfile.php\/3961\/mod_resource\/content\/12\/appendices\/ek2\/example.m\">Click to download the example.m file<\/a>. Keep in mind that this m file will not run unless if you have placed the other m files used in the same place.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2426 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2.jpg\" alt=\"\" width=\"507\" height=\"215\" srcset=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2.jpg 507w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2-300x127.jpg 300w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2-100x42.jpg 100w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2-150x64.jpg 150w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2-200x85.jpg 200w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab2-450x191.jpg 450w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2427 aligncenter\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG.jpg\" alt=\"\" width=\"561\" height=\"420\" srcset=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG.jpg 561w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG-300x225.jpg 300w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG-100x75.jpg 100w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG-150x112.jpg 150w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG-200x150.jpg 200w, https:\/\/blog.metu.edu.tr\/eresmech\/files\/2022\/03\/ExforMatlab3JPG-450x337.jpg 450w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/p>\n<p style=\"text-align: left\">As you can see, you can perform kinematic analysis using Excel, MathCad or MatLab. Basically the general approach is the same. You must first construct an algorithm with which you can compute the unknown parameters in sequence. In case of MathCad and Matlab you can use complex numbers (excel does not have this feature). However, Excel is the most available and cheapest product. Graphics is the simplest in Excel.<\/p>\n<\/div>\n<\/div>\n<\/div><\/div><\/div><\/div><\/div>\n\n\n<p>  <a href=\"https:\/\/blog.metu.edu.tr\/eresmech\/mechanisms\/ch3\/3-8\/\" data-type=\"page\"><img loading=\"lazy\" decoding=\"async\" width=\"38\" height=\"38\" class=\"wp-image-16\" style=\"width: 38px\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/04\/back_button.gif\" alt=\"\"><\/a><a href=\"https:\/\/blog.metu.edu.tr\/eresmech\/mechanisms\/ch3\/\" data-type=\"page\" data-id=\"52\"><img loading=\"lazy\" decoding=\"async\" width=\"38\" height=\"38\" class=\"wp-image-17\" style=\"width: 38px\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/04\/contents_button.gif\" alt=\"\"><\/a><a href=\"https:\/\/blog.metu.edu.tr\/eresmech\/mechanisms\/\" data-type=\"page\" data-id=\"47\"><img loading=\"lazy\" decoding=\"async\" width=\"38\" height=\"38\" class=\"wp-image-18\" style=\"width: 38px\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/04\/home_button.gif\" alt=\"\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"119\" height=\"40\" class=\"wp-image-15\" style=\"width: 119px\" src=\"https:\/\/blog.metu.edu.tr\/eresmech\/files\/2021\/04\/ceres.gif\" alt=\"\"> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Appendix-2 Function Routines for Simple Mechanisms and Basic Trigonometry In practice complex mechanisms are usually formed from the simple four-link mechanism loops connected to each other in series or in parallel. Usually the loops formed form a quadrilateral which can &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/blog.metu.edu.tr\/eresmech\/mechanisms\/ek2\/\"> <span class=\"screen-reader-text\">ek2<\/span> Devam\u0131n\u0131 Oku &raquo;<\/a><\/p>\n","protected":false},"author":7747,"featured_media":0,"parent":1932,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"full-width-page.php","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-2403","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/pages\/2403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/users\/7747"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/comments?post=2403"}],"version-history":[{"count":0,"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/pages\/2403\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/pages\/1932"}],"wp:attachment":[{"href":"https:\/\/blog.metu.edu.tr\/eresmech\/wp-json\/wp\/v2\/media?parent=2403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}