Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Aug 19, 2015
01:22 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2015
01:22 PM

plot results of linkeage analysis instead of just instantaneous results

In my mathCAD sheet, I've solved this four bar linkeage for any user input of crank position, but what I'd like to do now is develop equations to describe the motion of the links (and particularly a point in question) through out the entire 360 degree range of my crank arm. This sheet uses scalar position equations and Given / Find solve blocks to solve for link arm angle, angular velocity, and angular acceleration based on the user input of crank angle, which in my sheet is θ2.

I would like to make θ2 a range variable, or a matrix of values from 0 - 360 degrees so I can output and then plot the motion of the point I'm looking for, but I'm stuck. The Given / Find block fails, and then obviously the rest of the sheet fails. If I'm approaching this incorrectly from a programming stand point, please let me know.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Aug 19, 2015
03:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2015
03:48 PM

Additional notes:

If you do the same thing with your other solve blocks, you will run into severe performance problems - things really will get sloooow! This is because later solve blocks will call previous solve blocks multiple times in just one iteration und those solve blocks again call previous ones multiple times, etc.

Lets take for example your solveblock for VelSoln1 which calculates omega3 and omega4.

One iteration in this solveblock will call the solveblock for PosSoln1 four(!) times and if the solve block for VelSoln1 needs 100 iterations to get its values, the block for PosSoln1 is evaluated 400 times (and gets the very same values every time!).

So lets improve the situation up to the point, where the previous block is not called 400 times but just once:

The previous block is called once and the second solve block function gets the calculated values as additional arguments.

That way things are speeded up significantly.

LT

8 REPLIES 8

Aug 19, 2015
03:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2015
03:33 PM

You may turn the solve block into a function dependable on theta2:

Aug 19, 2015
03:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2015
03:48 PM

Thank you so much, Leopold.

Aug 19, 2015
03:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2015
03:48 PM

Additional notes:

If you do the same thing with your other solve blocks, you will run into severe performance problems - things really will get sloooow! This is because later solve blocks will call previous solve blocks multiple times in just one iteration und those solve blocks again call previous ones multiple times, etc.

Lets take for example your solveblock for VelSoln1 which calculates omega3 and omega4.

One iteration in this solveblock will call the solveblock for PosSoln1 four(!) times and if the solve block for VelSoln1 needs 100 iterations to get its values, the block for PosSoln1 is evaluated 400 times (and gets the very same values every time!).

So lets improve the situation up to the point, where the previous block is not called 400 times but just once:

The previous block is called once and the second solve block function gets the calculated values as additional arguments.

That way things are speeded up significantly.

LT

Aug 19, 2015
03:51 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2015
03:51 PM

Can you explain the underbar operator? What is the gist of this correction, and how does it change the performance problem?

Aug 20, 2015
04:08 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 20, 2015
04:08 PM

The underbar is not an operator, just a part of the name of the variables and functions. I needed different names but wanted names similiar to the original variables, so I added the underline character.

As you can see, the solve block function (the one with the undrline at the end) has three arguemnts. It would not have been necessary to add the underline at the additional two arguments but I thought it would be clearer that way.

So this solve block never calls one of the other solve blocks. It gets all it needs either by predefined constants (r2,r3,r4) or via function arguments.

Next I created the function VelSoln() with just one argument, theta2. Here in the first step I calculate the values for theta3 and theta4 corresponding to theta2 and then called the solveblock fucntion with those values as arguments. Note that I did not use the single functions theta3(theta2) and theta4(theta2) becuase doing so would call the previous solveblock twice. The way I did it needs just one call to that previous solve block.

Now, when you call VelSoln() Mathcad performs an iteration, evaluating the two equations every time with slightly different values of omega3 and omega4. In the fiorst version of this function, for every step of this iteration theta3 and theta4 would have been calculated again and again by calling the previous solve block. So each step of the iteration resulted in calling the previous solve block four times. This was time consuming, especially as you have other solve blocks which would call the last one the same way and so unneccessray calls are cascaded.

With the new function the previous solve block is called once and the results are used for every iteration. The previous solve block is not called a single time during the iteration process.

I know that its tedious to rewrite the sheet and turn all necessary variables into functions of theta2.

It is a long standing wish from the community to create a way to turn a whole Mathcad sheet into a function but I guess we better dont'n bet on this to happen some day.

LT

Aug 21, 2015
10:41 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 21, 2015
10:41 AM

LT,

I went through the sheet and updated my solve blocks with this programming style (both for the velocity equations and extrapolated that into the acceleration equations as well), and have everything working as I require. I also tried a version that used my previous and less efficient method - that took a while to compile! This programming method / advice was a real help to me, I just wanted to thank you for your input.

- Ryan

Aug 21, 2015
01:25 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 21, 2015
01:25 PM

LT, we would now like to be able to input a range, or set of data into this worksheet to use instead of the constant velocity motor speed. The data will be suggested servo-motor velocity which I will input as an excel file to my ω2 (input motor speed) variable, making it a single column vector of velocities (output from the servo driver as an excel file). I also have the corresponding crank arm acceleration as well as the jerk for each time step of the motor, so I'll have to do this more than once for each section of the linkage analysis.

I've tried dropping the file into my worksheet, but I think the fact that my input is now a vector is screwing with the Solve Block. It makes sense to put the "velocity" solve block into a while loop, and give exactly as many increments as there are rows in my file, and reference the row of angular velocity, but I don't know how to accomplish this, or even if it's the syntax that would work.

Attached is the updated version of the file we started this discussion with, and to recap, I'm interested in changing the motor input speed from a static value (ω2=400 rpm) to a table - referenced set of values so we can determine how the system would respond with a different servo-motor drive profile. I left my ω2 variable in place and vectorized it, and changed the solve block, but it failed.

If you change the "Velocity Equations" solve block back to ω2 instead of ωin it will compile appropriately. I've included the input excel file.

Aug 21, 2015
05:23 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 21, 2015
05:23 PM

Why not make omega2 a second argument of the functions in question ?

YOu should not vectorize in the solve block. The solve block should be setup using single values. Later you can vectorize the call to the solve block.

LT