Thursday, September 4, 2008

Dynamic Simulation using UG NX4 Motion Simulation Module

Which software are you using in your mechanical design project?

I have been using Solid Edge 3D CAD software for 1-2 years for my mechanical design projects in the past. But now, according to the standardization in my design organization, I have to switch to use Unigraphics software instead, or we call it in short as "UG NX4" (the latest version is NX6).

To be honest, at first I still like Solid Edge because I think I can make modeling and assembly in Solid Edge faster and easier than in UG. But one of the good thing for UG is Motion Simulation module that help me simulate the movement of mechanical assemblies before releasing for manufacturing. I know that Solid Edge also has this kind of simulation module, but I didn't have a chance to use (no license). So in this post, I would like to share how easy to set up motion simulation in UG NX4.

Let's start with a very simple modeling.



I would like to see how the cylinder moves when it is pushed by the rotating lever. So I start with making UG modeling as shown above. Those parts can be "features" in single UG file or the assembly of several UG files.

Once the assembly is ready, I can then start "Motion Simulation"



At Motion Navigator, right-click and select "New Simulation"



UG NX4 will show the pop-up Motion Joint Wizard windows for automatic setting of joints for simulation. For this example I just click at cancel button in order to set the links and joints manually.

Next, what I have to do is to set necessary links and joints for motion simulation. I have to start with creating of links. Parts or features that cannot moved and no contact with other parts, can be excluded for link setting. In the example, the fixed column can be excluded from link setting. I can leave it as it is, just for showing purpose only.

First, I would set the lever as a link in motion simulation by clicking at "link" icon and select the lever and rename it as "lever"



Do the same thing for the cylinder and the block.
Why do I need to set the block as link?

I have to set the block as link though it is not moving because I would like to set the 3D contact between the cylinder and the block, otherwise the cylinder will fall down during simulation! I have to also select "fix the link" for the block in order to prevent falling down when simulation start.



At Motion Navigator, I can see the links and joint I've created. We can see that though I don't set the joint for each link yet, but there is "J001" joint at Motion Navigator pane because UG NX4 creates "fixed joint" automatically when we select "fix the link" during creating of the link.



Next, I create a revolute joint and set motion driver for the lever. This step is very important. The point and direction of joint must be correct i.e. Z-axis should be the axis of rotation.



Then I create the 3D Contact between the cylinder and the block and also between the lever and the cylinder.



Then we're ready to start simulation. But we have to make sure that the solver environment is "Dynamics" not "Kinematics" because I would like to see the effect of 3D contact. (Click at calculator icon)



Next, start motion simulation by clicking at "Animation" and set time = 1 and step = 100 and see the result.



Watch the following video for the result.



Recommended articles related to Unigraphics NX4 Motion Simulation

Monday, September 1, 2008

Motion Simulation in Solid Edge using sketches together with Microsoft Excel VBA Programming Part III

In previous example, I showed how to control variables in Solid Edge sketch using direct link to excel spreadsheet. In this example, I am going to show how to use VBA (Visual Basic for Application) in excel to control the variables in Solid Edge sketch.

1) Create new file in Microsoft Excel

2) Press Alt+F11 to enter Microsoft Visual Basic windows as shown below



3) Right click in Project Explorer at new file name (in this example, new excel file name = Book2) > Insert > Module



4) To make Solid Edge type libraries available to the Visual Basic Object Browser, click References on the Project menu. On the References dialog box, select the Solid Edge libraries you want to access.



All variable automation is accessed through the Variables collection and Variable objects. The Variables collection serves two purposes: it allows you to create and access variable objects, and it allows you to work with dimensions as variables.

Note: When debugging programs that interact with the Variable Table, it helps to have the Variable Table displayed while stepping through the program. The Variable Table shows the results as they are executed.

5) Write the following code into VBA code area as shown below,


You can copy & paste the following code to your excel VBA.

' =================================================================
' Example of using VBA code to control variables in Solid Edge document
' By AkeBlogger
' http://mechanical-design-handbook.blogspot.com/
' =================================================================

Sub Simulate()
On Error Resume Next

'Declare the program variables.
Dim iAngle As Single
Dim objApp As Object
Dim objVariables As Object
Dim objVariable As Object

'------------------------------------------------------------------
' Checking for the active document
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
MsgBox "You must open Solid Edge before executing this module!!", vbOKOnly + vbExclamation, "Error"
Exit Sub
Else
'Connect to a running instance of Solid Edge.
Set objApp = GetObject(, "SolidEdge.Application")
'Access the Variables collection.
Set objVariables = objApp.ActiveDocument.Variables
End If

'SIMULATION STARTS!
For iAngle = 0 To 360 Step 2
' Changing Cam_angle from 0, 2, 4, ..., 360 deg.
Call objVariables.Edit("Cam_angle", iAngle)

Next iAngle

End Sub

6) Open Solid Edge file from previous example and delete formula in Variables Table as shown below, because in this example we will control the variable (dimension) using VBA code directly.



7) We are now ready for simulation. Resize VBA Windows as shown below then click run to see the result.



Watch the following video for the actual result!


video

Monday, August 25, 2008

Motion Simulation in Solid Edge using sketches together with Microsoft Excel VBA Programming Part II

To link solid edge variables to Microsoft excel, we can do by enter formula in the variables table or use VBA code.

In this post, I would like to show how easy to make it using variables table.You can use the Variable Table to define and edit functional relationships between the dimensions of a design in a familiar spreadsheet format. The Variable Table is accessed with the Variables command on the Tools menu. There are two types of variables: dimensions displayed in the design and variables you create directly in the Variable Table. Dimension variables directly control elements of a design. Variables that you create cannot directly control the design. A user variable must be set equal to a value or mathematical expression; for example, PI = 3.14159. Variables can control dimensional relationships by setting the dimensional relationship equal to the variable.Let's begin...

1) Open Solid Edge and make a sketch as shown below.

Mechanism in this example consists of cam, lever, pull rod and four bar linkage. What we have to do is to make sure that when the dimension of cam angle is changed, the entire mechanism is changed accordingly. You can simply check this by clicking at the dimension of cam angle and rotate your mouse wheel to see if entire mechanism is moving or not.

2) To set the name of variables
When you place the dimensions for a design, variables for these dimensions are placed into the variable table automatically. If the Variable Table is open, any dimension that is placed by you or the software will display in the Variable Table after the dimension is placed. Working with the variable table open allows you to change the dimension's name that is generated by the software to a more logical name as you work. When you rename variables, the variable names should contain only letters, numbers, and the underscore character. You should not use punctuation characters.In Solid Edge: select Tools > Variables > Variables
and click at the dimension you want to change the name, for this case select the dimension of cam angle and change "Name" to cam_angle and select "Expose" to show this variable name to other application as shown below.



3) To Link variable in Solid Edge to Microsoft Excel
You can use Microsoft Excel or other spreadsheet software to link Solid Edge variables to a spreadsheet. Before you can link variables to a spreadsheet, you must first create the variables you want in the Solid Edge document. When you link Solid Edge variables to a spreadsheet, the document names and folder path for the spreadsheet and the Solid Edge document should contain only letters, numbers, and the underscore character. You should not use punctuation characters. To successfully edit the linked Solid Edge variables from the spreadsheet later, you must open the Solid Edge and spreadsheet documents in a specific order:
  • You can open the spreadsheet document first, then open the linked Solid Edge document.

  • You can open the Solid Edge document first, then click the Edit Links command on the shortcut menu when a linked formula is selected within the variable table. You can then use the Open Source option on the Links dialog box to open the spreadsheet document.

Create new Microsoft Excel workbook and save it.
In this example, the excel file is saved at E:\Online Biz\Web\Blog\Mechanical-Design-Handbook\

File name: ex-solid-edge1.xls
and this is the content of the excel file...


In Solid edge: select Tools > Variables > Variables and select the variable named "cam_angle" as you created in previous step. And enter the following formula into "Formula" column,

@'E:\Online Biz\Web\Blog\Mechanical-Design-Handbook\ex-solid-edge1.xls'!'Sheet1!R2C2'

You can see that to link to another excel workbook, just put "@" at the first position then follows by the path and file name of excel file, sheet name and cell.

R2C2 means row 2 and column 2 which is cell B2

Now solid edge variable is linked and control by cell value in excel.
If you change value in cell B2, you will see the movement of cam mechanism.

Watch the result in the following video clip.

video

Saturday, May 17, 2008

Motion Simulation in Solid Edge using sketches together with Microsoft Excel VBA Programming Part I

Solid Edge has a very useful application called "Motion" which allows a user to simulate the movement of mechanical parts. This enables the machine designers to test and make sure that the movement of their mechanism is the same as they expect before manufacturing parts. This helps save a lot of money.

However, instead of using "Motion" application, I would like to show you how to simulate the motion of mechanical parts using a sketch in Solid Edge together with Microsoft Excel.

Why?

Most of the time, I started my mechanical design with the concept and layout using sketches. If we could simulate the motion of mechanical parts in a sketch, it would help me a lot.

I got this idea when I was playing with sketches and constraints in Solid Edge. Solid Edge allows us to change the dimensions easily by just rotating the mouse wheel.

Watch the following video to see how easy to make the motion in sketch.

video

So what I have to do is just to have Microsoft Excel VBA changes the dimensional values in Solid Edge sketch.

Here is the results of this idea ...

video

Let's see how to do this in the next post...


Read more info about Solid Edge: Ultimate 3D CAD Software

Friday, May 9, 2008

Microsoft Excel: Goal Seek Technique for solving mechanical engineering design's problems

Problems in mechanical design often require the solution of nonlinear equation such as

3x3 - 20x2 + 1000x + 12000 = 0

These problems are sometimes stated in the form, find the zeros or roots of the function

f(x) = 3x3 - 20x2 + 1000x + 12000 = 0

that is, find the values of x that make f(x) = 0. Therefore, they are sometimes called root solving problems. The equation shown above is a typical equation encountered in the problem of finding the maximum stress at a point. While such equations can be solved by trial and error (simply guessing value until the left-hand side of the equation is nearly zero), there exist simple, systematic ways to solve such problems. Two such methods - the Method of False Position and Newton-Raphson method.

The Method of False Position is a systematic method of narrowing down the region in which the root exists. And another one is the Newton-Raphson method of root solving. It is more sophisticate than the Method False Position. It uses the slope of the function to estimate the location of the root. For most functions, this method converges much more quickly to the solution than does the Method of False Position, and the Newton-Raphson method is the method of choice in most cases (it is my favorite root finding technique, I would like to share you the Excel VBA of the Newton-Raphson method later). However, there are certain types of functions that are not solved very well by the Newton-Raphson method, so the Method of False Position is a good method to use on these functions. The Newton-Raphson method uses the tangent line to the curve at the point xn to estimate the location of the root. The slope of the tangent line at xn is just the derivative of the function evaluated at xn. More info about these root solving techniques will be shared later.

In this post, I would like to share a very simple Excel technique to you in order to help you solve your problem easily on your desktop PC. It is called "Microsoft Excel Goal Seek" technique. Knowledge of Microsoft Excel VBA programming is not required for this technique.

Microsoft Excel: Goal Seek Technique for solving mechanical engineering design's problems

1. Open Microsoft Excel and enter the value and formula as shown below (Click at the picture for larger view)


2. After that, select Tools > Goal Seek...



3. Enter the values as shown below. This is to let Microsoft Excel change x [cell E14] until the value of f(x) [cell E16] is zero (or nearly). Then click OK.


4. You will see the following screen if the solution is found. Please note that the solution of x that gives f(x) = 0 also depends on the initial value of x you entered. Sometimes Microsoft Excel Goal Seek tells you that there is no solution found, but when you change the x value (=value in cell E14 for this case) to any other value instead of your first initial value, Microsoft Excel Goal Seek may find the solution.



Remark: The current value [f(x)] is not zero because of iteration process, but there is no problem if it is within your tolerances.

What if you want to design your shaft that has fatigue loading using the maximum-shear-stress theory combined with the Soderberg line for fatigue, which the diameter and safety factor are related by the following equation?



For example, if you want to the know value of maximum Mm that can apply to your shaft with known diameter (d) and other design factors shown in the equation, what you need to do is to set the several cells for each input factor e.g. d, n, Mm, Ma, Ta, etc. in Microsoft Excel. Next step is to set the formulas for both of your left-hand side and right-hand side of the equation.

So your LHS is something like =PI()*E20^3/32 (suppose that the value of d is in cell E20), then do in the same way for your RHS. Next, enter formula in another cell to calculate the difference between LHS and RHS. I suppose that you enter this formula in cell F11
Then use Microsoft Excel Goal Seek to find value of Mm that make difference between LHS and RHS equal zero.

So values in Goal Seek dialogue box will be...

Set cell: F11
To value: 0
By changing cell: E12 (suppose this the value of Mm)

Imagine that if you want to fix the value of Mm and find value of d instead. What you have to do is just to change the value in "By changing cell:" to the cell that stores the value of d. So it gives more flexibility to you.

Another technique is Microsoft Excel Solver. It is more sophisticate and very useful tools that can help you solve optimization problem. But it requires more customization, we will talk about this later.

Hope this is useful for you :)

password: mechanical-design-handbook.blogspot.com
DOWNLOAD EXAMPLE OF MICROSOFT EXCEL GOAL SEEK FOR FREE

Wednesday, April 30, 2008

Microsoft Excel VBA - Mohr's Circle for Plane Stress

The German engineer Otto Mohr (1835-1918) developed a useful pictorial or graphical interpretation of the equations for finding the principal stresses and the maximum shearing stress at a point in a stressed member. This method, commonly called Mohr's circle, involves the construction of a circle in such a manner that the coordinates of each point on the circle represent the normal and shearing stresses on one plane through the stressed point, and the angular position of the radius to the point gives the orientation of the plane.



Normal stresses are plotted as horizontal coordinates, with tensile stresses (positive) plotted to the right of the origin and compressive stresses (negative) plotted to the left. Shearing stresses are plotted as vertical coordinates, with those tending to produce a clockwise rotation of the stress element plotted above the s axis, and those tending to produce a counterclockwise rotation of the stress element plotted below the s axis.

The results obtained from Mohr's circle are identical with the equation derived from the free-body diagram. Consequently, Mohr's circle provides an extremely useful aid in the solution for, and visualization of, the stresses on various planes through a point in a stressed body in terms of the stresses on two mutually perpendicular planes through the point. Although Mohr's circle can be drawn to scale and used to obtain values of stresses and angles by direct measurements on the figure, it is probably more useful as a pictorial aid to the analyst who is performing analytical determinations of stresses and their directions at the point.



Useful information about Mohr's Circle:
You can download Mohr's Circle Excel file for free with password: mechanical-design-handbook.blogspot.com

DOWNLOAD Mohr's Circle Excel file for FREE

Wednesday, March 19, 2008

Motion Simulation with Microsoft Excel


video
Motion Simulation with Microsoft Excel

Mechanical design usually deals with movement of several parts. There are a lot of softwares that help simulate the movement of concerned parts of machines such as UG, Solid Edge, Solid Work, etc.

But how do you make simulation without those softwares?

I use Microsoft Excel to do the simulation of my timing diagram. Watch the video.

Actually it is nothing but motion simulation using graphing method in Microsoft Excel. It cannot simulate all of your complex movements, but it helps you get the feeling of how your machine will behave according to your timing diagram.

This technique uses VBA (Visual Basic for Application) to control the movements. What you have to do is to prepare the excel spreadsheet with the table defining the sketch of your machine parts to be used in simulation. You have to set the formula in excel spreadsheet to manipulate the location (x,y) and rotation (angle). After proper settings, just let VBA code, which is embedded in Microsoft Excel, changes the control values in the manipulation table (the x-y chart is linked to this table). Then you can control the movement of parts that move in translation or rotation. For example, I use an indexing box at my transport conveyor which has 4 stops and the cam profile is MS (Modified Sine). So I put MS function into my VBA code and I can see how my conveyor is moving at the same as others.

Example of Modified Sine Movement Function.

=================================================================
' Modified Sine function
' T is dimensionless
' hm is stroke of movement

Function MS(T As Double, hm As Double)
Const PI = 3.14159265358979
Dim T5 As Double, T6 As Double
Dim V1 As Double, V2 As Double, V3 As Double, V4 As Double, V5 As Double, V6 As Double
Dim S1 As Double, S2 As Double, S3 As Double, S4 As Double, S5 As Double, S6 As Double
Dim Am As Double
Dim s As Double

Const T1 = 0.125
Const T2 = 0.125
Const T3 = 0.5
Const T4 = 0.5

T5 = 1 - T1
T6 = T5
Am = 1 / (2 * T1 / PI + (2 - 8 * T1) / PI ^ 2)

V1 = 2 / PI * T1 * Am
V2 = V1
V5 = V1
V6 = V1

V3 = 2 / PI * (T3 - T2) * Am + V2
V4 = V3

S1 = 2 * T1 ^ 2 / PI * Am - (2 * T1 / PI) ^ 2 * Am
S2 = S1

S3 = (2 / PI * (T3 - T2)) ^ 2 * Am + V2 * (T3 - T2) + S2
S4 = S3

S5 = 1 - S1
S6 = S5

Select Case T
Case 0 To T1
s = 2 * T1 / PI * Am * (T - 2 * T1 / PI * Sin(PI * T / (2 * T1)))
Case T2 To T3
s = (2 / PI * (T3 - T2)) ^ 2 * Am * (1 - Cos(PI * (T - T2) / (2 * (T3 - T2)))) + V2 * (T - T2) + S2
Case T4 To T5
s = 2 / PI * (T5 - T4) * Am * (2 / PI * (T5 - T4) * Sin(PI * (T - T4) / (2 * (T5 - T4))) - (T - T4)) + V4 * (T - T4) + S4
Case T6 To 1
s = (2 / PI * (1 - T6)) ^ 2 * Am * (Cos(PI * (T - T6) / (2 * (1 - T6))) - 1) + V6 * (T - T6) + S6
Case Else
s = 1
End Select

MS = s * hm

End Function
=================================================================

For those who are interested in downloading the example file, please click the link below


DOWNLOAD EXAMPLE FILE FOR FREE

Extract the zip file with password: mechanical-design-handbook.blogspot.com

Thursday, February 21, 2008

Timing Belts

Timing belts solve the slip problems of flat, O ring, and V belts by using
a flexible tooth, molded to a belt that has tension members built in. The
teeth are flexible allowing the load to be spread out over all the teeth in
contact with the pulley. Timing belts are part of a larger category of
power transmission devices called synchronous drives. These belt or
cable-based drives have the distinct advantage of not slipping, hence the
name synchronous. Synchronous or positive drive also means these belts
can even be used in wet conditions, provided the pulleys are stainless
steel or plastic to resist corrosion.



Timing belts come in several types, depending on their tooth profile
and manufacturing method. The most common timing belt has a trapezoidal
shaped tooth. This shape has been the standard for many years,
but it does have drawbacks. As each tooth comes in contact with the mating
teeth on a pulley, the tooth tends to be deflected by the cantilever
force, deforming the belt’s teeth so that only the base of the tooth
remains in contact. This bending and deformation wastes energy and
also can make the teeth ride up pulley’s teeth and skip teeth. The deformation
also increases wear of the tooth material and causes the timing
belt drive to be somewhat noisy.

Trapezoidal Tooth Timing Belt


Several other shapes have been developed to improve on this design,
the best of which is the curved tooth profile. A trade name for this shape
is HTD for High Torque Design. Timing belts can be used at very low
rpm, high torque, and at power levels up to 250 horsepower. They are an
excellent method of power transfer, but for a slightly higher price than
chain or plastic-and-cable chain

HTD Timing Belt Tooth Profile