Following a cam ... as in camshaft ...

Having conquered the initial task of getting a crankshaft working properly in Blender (thanks to you guys), I have another machinery-related challenge.

I need to model a camshaft and the rods which follow each cam, moving upward and downward to follow its shape. (Some of the cams are actually mounted sideways on a disk and the follower moves left-and-right, but I think my idea will work equally well for either case.)

I’ve been pondering how one might do this. What I came up with, conceptually at least, is that you should be able to create a 3D curve, centered around the shaft, whose shape matches the outside of the cam, or whatever path the follower needs to follow. Then, I guess, you’d parent an “empty” to that, and constrain the follower to follow that empty. (A “LocY” constraint or whatever.)

My thinking here is that the “empty” will follow the path we have specified. And as it does that, for exactly the same number of frames, we rotate … not only the curved path, but the cam-polygon that it’s matched to. So as the path rotates, and the empty follows the path, the empty is basically going to stay in one place in space, and the follower will look like it’s doing the right thing.

Am I close? :expressionless:

not sure if i got you right, can you post a sketch? anyway give it a try.

Sounds like a good idea to me!

I gave it a try and couldn’t come up with anything better. I put mine together with a few less pieces than you described, though. :slight_smile:

Try opening my cam.blend file, and hit Alt-A

You’ve probably figured most of this out too(especially since your post has been unanswered for 4 days!), but if I may make a couple of suggestions:

-Instead of empties, I find that using armatures and constraints keeps most of the animation controlling pieces in a tidier package.

-The curve path can be extruded to be the cam body as well. This means you don’t need to add any more geometry, and if you change the curve you are changing both the geometry and the path.

-I tweaked the curve for the path to try and get the cam2 bone (equivalent to your empty) to stay more precicely in the right area more of the time.

I hope some of that helped a little. Good luck, and if I come up with anything better I will post it!

J.

I have done this before. I promise I shall upload the .Blend file for you as soon as possible.

  1. Build camshaft
  2. Build rods
  3. Align rods to correct cam position
  4. Parent rods to camshaft
  5. Add empty above each rod
  6. Add constraint: Track to for each rod to each empty

Most important thing is the positioning of the pivot point of each rod.

If I can’t upload to my webspace I can email the .blend to anyone who wants it.

Hope this helps,

Sonix.

Thanks for the tips. At least I don’t feel quite so dumm :wink: as last time.

Sonix: I guess that the key to implementing your suggestion would be, “how did you go about building that camshaft?” That would be the key. I surmise that you built it by creating extruded curves.

Crackerjack: Thanx for the blend file. I was steering away from armatures for some reason.

Tricky will be the fact that some cams are mounted on the sides of disks and made of rough, pitted metal. But I guess it can follow an invisible curve track if need-be. But constraints seem to have been “the secret” I didn’t know.

This definitely needs to be a blender-doc tutorial.

Ok I didn’t use curves, just an extruded circle.

Click for anim of working engine, divx v5 242KB

Blendfile at the end of this link, 88KB zipfile.

Could do a tutorial if this method works for you guys.

Sonix.,

Sonix: Cool demo - I like it! But the connecting rods are driven by a crankshaft, not a cam/camshaft. They work sort of similarly, but they aren’t the same thing.
Sorry, Dude. :wink:

A cam is a little bit more difficult to animate. So I don’t think that you’ve really answer’s sundialsvc4’s question. Have a look at the file I posted if you would like some visualization of what sundialsvc4 is talking about.

Any other ideas?
J.

:expressionless: oops I really should have checked your blend file first.

I have an idea though. Could you not use the new follow terrain script that’s in the finished projects, that makes an object follow a surface?

The follow terrain script thread is Here.

Maybe you could adapt this.

Sonix.

Okay, folks, I see a couple of great tutorials! Somebody start writing.

Also, on the “follow the terrain” tutorial, please include the source-code of the script directly in the HTML page, and explain how it works. It’s very cumbersome to have to download a blend-file and boot up Blender just to follow along.

Obviously, the “follow” tutorial will really be a tutorial in advanced scripts in Blender… a topic that in general is woefully under-documented right now.

CrackerJack, “I just can’t find the prize anywhere in the box.” :expressionless:

I’ve studied the cam-demo and it’s great but I don’t understand how you did it. I thought I did … :o … but I see a lot of IPO setups and so-on and don’t really visualize in what order you did it.

A textual explanation would be fine: assume that I’ve started with an extruded circle as the cam, and a rectangle as the follower, and I am now ready to rig the thing up. (It would be even nicer if the follower were an anchored object that was going to pivot around its own shaft as it followed the cam.)

On another topic… a textual explanation of how the Python of “follow a terrain” actually works would be very useful, I think, to us all. (Copying the text of the script into the reply, rather than citing a blend-file containing it, would also make such an explanation easier.)

Thanks to you all. “The little lights are starting to come on, one by one, but this particular little light hasn’t done it yet.”

What’s the really greatest, really best, most complete book on the subject that (I surmise…) all of you “must have already read by now?” %|

Let’s see if I can explain it a little… :slight_smile:
If we just forget the armature stuff for now, and go over the base IPO stuff I did, maybe that will help. Try this:

  1. The extruded circle for the cam should be a curve, so that you can use it as a path.
  2. Make an empty and set it to follow the path (parent, and set the curve to curve path & curve follow), and edit the path IPO and set it to linear.
  3. Make your circle rotate (key frame rotation, move ahead say 20 frames, rotate say 90°, key frame rotation, make the IPO linear or change the vertex handles to cusps, set the IPO extend mode to extrapolation)
  4. Edit the path IPO for the empty so that the empty completes it’s trip in the same time as it the circle to rotate all the way around (80 frames in my example from step 3 ).
  5. Edit the path IPO and insert key frames at frames 20, 40, and 60 as well by going to those frames pressing I key for “insert current frame”, so that the curve stays as is. Move the 3 points in the IPO curve up/down a little so that the empty is in about the same spot in each even though the curve is rotating.
  6. Set the spin centre of the follower to be right on the end (at the contact point) and give it a copy position constraint to the empty (just in the axis that you would like it to move).

I think that is most of the important stuff. Let me know if I’ve left something out or something doesn’t make sense.

Good luck,
J.

You can append the Followterrain.py file into any other Blend file. Hit Shift+F1 to append, go to Followterrain .Blend file, open text directory and right click Followterrain.py then load. Go to text window and open Followterrain.py.

As for info about the script it’self

Hope this helps, if not PM Harkyman and pester him for a tutorial.

Sonix.

Crackerjack:
Okay, to recap what you just told me … you’ve got the empty running in place on a little exercise-wheel. It’s following a path, and meanwhile, that path is rotating … and it works because both of them are timed to complete (their trip along the path, or their rotation) at precisely the same time.

I’m afraid that I’m fuzzy on your point (5). The phrase that throws me is: “… so that the curve stays as is.” As I change the position of the three (key-frame?) “points,” what should I expect to see happening as I adjust them?

Ultimately I’m going to need to have the lever which is attached to the follower rotate on its axis as the follower rises and falls. But I think I can get that done with armatures …

Sonix: I’ll see what I can do. Later. :smiley:

(“Mrs. Hawkins, can I leave the room now? My brain is full…”) %|

Hi again sundialsvc4,

Sorry for the long break.
I check in here sort of irregularly at best, and I’ve been busy with other stuff lately.

What I meant by “…so that the curve stays as is”, is that I was going to frame 20, and pressing I>insert current frame.

This is as opposed to the method of mousing over the IPO curve and using ctrl-RMB, and having them be a little less precisely located along the timeline.

I just wanted to make sure the keyframe was at exactly frame 20 on the curve without changing it’s shape, so I had a nice starting point. And then I move the point up or down slightly. I guess you could numerically input things too. Just one of many approaches.

As for what you should see happening when you move the points…
You are moving the point to affect how far the empty has travelled on its path by that time. But since the path is rotating, you want to move the point up or down to get the Empty to look like it’s sitting in in the same spot as the path moves.

I hope that clarifies what I meant.

Did you get everything else working?
Goodluck!
J.