I was recently rigging a crank and piston type mechanical model, and I think the method I came up with is interesting. There are other methods I looked at, but they are quite complex. The idea of this rig is to only use constraints. There is the video at YouTube http://www.youtube.com/watch?v=FUhTuitVqJc (I should have made it loop a few times!)
The difficult component is the connecting rod because the big end follows the crank pin, while the little end is forced to follow the axis of the piston. This means that the axial length of the connecting rod varies, it is the same as the absolute length of the connecting rod when in line with the piston, but is shorter than the absolute length when the crank pin moves out of the axis of the piston.
One simplification for the rigging is to ignore this variation and constrain the piston to the axial component of the crank pin. A nice way of taking into account the variation would be to use python script with the math for a constraint so the connecting rod is perfectly positioned, but in 2.69 the script constraint is not working.
Here is a summary of the steps:
The flywheel is animated to rotate.
The crankshaft is constrained as a child.
The origin of the crankshaft is the centre of the crank pin.
The connecting rod has two constraints
The first has origin of the crankshaft is the centre of the big end - corresponding to the centre of the crank pin. This rotates the connecting rod correctly, but it is always parallel to the axis of the piston.
To get the connecting rod angle, a track to constraint is used with a target of an empty as described below.
The connecting rod has a vertex group which is created so that it is centred on the little end. This is done by using all the internal circular vertices of the little end.
For the connecting rod track to target empty (I have called it ‘crank pin’ in the .blend file), the empty is positioned along the piston axis twice the length of the connecting rod from the centre of the flywheel, where the connecting rod length is the length between the centre of the big end and the centre of the little end.
The empty is constrained to follow the position of the crank pin as an offset, but with an inverted direction of rotation.
This is still not the ideal position, because it does not include the off axis movement so it needs to be adjusted by moving it a little closer to the flywheel centre.
The gudgeon pin is constrained to follow the position of the connecting rod little end vertex group.
The piston head is constrained to follow the position of the gudgeon pin. To minimize any variation out of the axis of the piston, the piston head is only to constrained to follow the motion of the gudgeon pin along the axis of the piston.
Hope this is useful
PS. Sorry it took me so long to manage the attachments to get the .blend and figure up loaded.
Since the post at the weekend, Matthew has graciously replied.
He is totally correct!
An armature using bones would be 100% accurate, and for something complex it is the better way to go.
The idea of using just constraints was to create a quick and dirty animation