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® 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. 2.1. Function routines written in Visual Basic for Applications (VBA) 2.1.1 Conversion from rectangular to polar form 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 (Mag(x,y) and Ang(x,y)) to determine the magnitude and the angular orientation of the vector OP defined by (x,y) coordinates (see figure). Note that Ang(x,y) function 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 -p/2<q<p/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 -p<q<p Outside the function routine, two global constants PI and Eps are defined. Global Const PI = 3.1415926
Function Mag(X, Y) Function Ang(X, Y)
2.1.2. Inverse Sine and Cosine Functions: Normally in most languages Atn(x)- the inverse tangent function is defined only. when writing programs in basic, we shall need other inverse trigonometric functions such as ASIN(x) and ACOS(x). 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 p to the result. Function Acos(X) Function Asin(X)
2.1.3. Triangle Solution (Cosine Theorem): 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 (a= AngCos(U1,U2,Opposite)) or one can determine the opposite side when the two sides and the included angle a (ANGLE) is given (Opposite = MagCos(U1,U2;Angle)) (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 Function AngCos(U1, U2, Opposite) Function MagCos(U1, U2,Angle)
2.1.4. Position Analysis of Simple Mechanisms: 2.1.4-a) Four-Bar Mechanism 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 FourBar() function is the rocker angle whereas for FourBarCoupler() it is the coupler angle. In case of FourBar2() function there are two outputs as [Coupler Angle, Rocker Angle] The user must type +1 or –1 for the Config variable depending whether the mechanism is assembled in open or crossed form respectively.
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). Function FourBar(Crank, Coupler, Rocker, Fixed, Config, Theta)
2.1.4-b) Slider-Crank Mechanism: For the slider crank mechanism shown again three different function programs are written. SliderCrank() gives the slider displacement s14, SliderCrankCoupler() coupler angle q13 and SliderCrank2()) which gives both the coupler angle and the slider displacement [q13,s14] for given link lengths and corresponding crank angle q12 (Theta) . . The user must type Config as +1 or -1 depending on the position of the slider with respect to the crank.
Function SliderCrank(Crank, Coupler, Eccentricity, Config, Theta) Function SliderCrank2(Crank, Coupler, Eccentricity, Config, Theta) Function SliderCrankCoupler(Crank, Coupler, Eccentricity, Config, Theta) 2.1.4-c) Inverted Slider-Crank Mechanism:
For the inverted slider crank mechanism shown the visual basic function routine is Invslider2(Crank, Fixed, Eccentricity, Alfa, Config, Theta) Config 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 q14. Function InvSlider2(Crank, Fixed, Eccentricity, Alfa, Config, Theta) 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.
All the above functions are written in Visual basic and is available as Basic.Bas file which you can download here If you want to use these files in an excel sheet, switch to (and Call it InvSliderCrank())Visual Basic editor (From the tools menu select macro and Visual Basic Editor of simply press Alt+F11 buttons) and then from the file menu select "import file" (or Ctrl+M).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 "insert" menu- "functions" and "user defined" type. You will be able to see all the above functions)
Example 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. 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 FourBar() function. Next Using (q14-a) as the input crank angle of link 4 we determine the horizontal distance B0D of the slider using SliderCrank() function. s=B0Dx+B0A0x B0A0x=1250 mm given.
On the excel Sheet let us first enter the known link dimensions (lengths and angles).
From the given x and y lengths (Fixed_Lx and Fixed_Ly) the fixed link length is determined by using the function mag() as mag(B5;B6) in cell B7. in cell B8 we determine the angle B0A0 vector makes with the horizontal using ATAN2() Excel
function in the form ATAN2(-B5;B6). angle Afa1 is obtained by typing "=pi()-B8" into cell B9. In cell E5 the angle
Now into cells A16-A40 the input crank angle, Th, from 0 to 360 degrees at 150 interval is entered.
The angle Th entered in column A is q12 shown on the sketch. This is the angle link 2 makes with respect to a horizontal line, not with respect to A0 B0 . In column B after converting q12 into radians the angle Alfa1 Given in cell B9 is added by typing "=A16*PI()/180+Alfa1" into cell B16 and copying this formula from B16-B40. (If you have not named cell B9 as "Alfa1", then you must type $B$9 to fix this cell. Into cell C16 type
"=SliderCrank(Crank2;Coupler2;Eeccentric;1;(C15-Alfa4)) + Fixed_Lx"
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: q14 -a4+p/2 . To determine S,vertical displacement of the slider 6, into cell E16 type:
Click here for the Excel File. 2.2. Basic trigonometry and simple mechanisms function files in MathCad 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:
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 BasicMechanisms.mcd or BasicMechanisms.xmcd)(Download Basic Mechanisms2000.mcd or BasicMechanisms2000xmcd by clicking here). Whenever you want to use this file in another MathCAD sheet, from the Insert menu select “reference” and insert the name and the location of the file onto the new sheet. The result will be seen similar to the following line: 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. Example Consider the baler mechanism shown A0A=A0A'=a2; AB=a3; BB0=a4 ; BC=b3;A0Q=b1; QB0 =a1; CD=a5; AD= a6; DE=b6; <A'DE=g6 ; Click for the solution in MathCadClick to download Baler.xmcd file Click for the avi file created using MathCad 2.3. Basic trigonometry and simple mechanisms function files inMatLab In case of Matlab® 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:
function mc=magcos(u1,u2,angle)
function mag=mag(x,y) function fb=fourbar(crank,coupler,rocker,fixed,config,theta)
function fbc=fourbarcoupler(crank,coupler,rocker,fixed,config,theta) function fb2=fourbar2(crank,coupler,rocker,fixed,config,theta) function sc=slidercrank(crank,coupler,eccentricity,config,theta) function scc=slidercrankcoupler(crank,coupler,eccentricity,config,theta) function sc2=slidercrank2(crank,coupler,eccentricity,config,theta) function inv=invslider(crank,fixed,eccentricity,alpha,config,theta) function inv2=invslider2(crank,fixed,eccentricity,alpha,config,theta) Click here to obtain the above Basic M files (Basic M files.rar) Example B0Q = a1 = 526, A0Q = b1 = 75, A0A = a2= 135, B0B = a4 = 826, BC = a5 = 481. The m file written for this example is : clc %Clear Command Window The result is the simulation of the mechjanism and the s16 versus crank angle plot as shown in Figure below.
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.
|