I have good news and bad news.
The bad news first. I have researched this particular kind of mechanism, and there doesn't seem to be a solution with constraints and IK. I verified this with support. Q: What about expressions?...I have an mechical engineering background, and know that creating this expression, is rather lengthy. It requries some pretty intense kinematics. I would take the time to derive it, but I am pretty rusty on my higher math these days, and it would take a few days to get a result....but
The good news. It doesn't take but a few mintues to simply key it.
1. Place 1 bone skeleton to depict the crank. Select the joint and animate it 360 degrees. This can be done easily two ways. (1) Key the rotation value at the start and end and then use FcrvEdit/Extrap/Cycle (or use gradient) to make it cycle continuouly. Be sure use Select/Fcrv and make it's curve linear, or the cranck will start and stop on each revolution. Method (2) Or you can appy an expression to the rotatoin using the "Current Frame or Fc" value so that it rotates.
Now place a linear curve or use a viewport grid line which depicts the linear motion. The line should go right through the middle of the where the link attaches to the piston.
Now place another 1 bone skeleton with it's origin constrained to the effector of the cranck skeleton. Then place it's effector on the line reference. Use a positional constraint to place you piston on the effector (You may have to move center, or use a null parent).
Key the effector's postion with explicit translation key.
Move the time line. Then place the effector back on the line and key it again. Continue until you have made a complete revolution.
- Now use FcrvEdit/Extrap/Cycle to make it cycle continuously.
That's it. It looks like a lot, but is actually very quick to do. I have honestly made several attempts to solve this with IK and constraints, but 3D animation products don't really have a need for a linear constraint that can be driven, which is the real problem. However, I am still keeping hope alive, in case someone else has had more success. However, please don't post a solution unless you have actually gone through it fully, to be sure the piston is actually staying linear.
Most any other mechansim is easy to sovle with IK and constraints, so let me know if you need assistance on those, such as a hydralic piston/ram.
Hope this helps,
Urp