Ive been using this function for a piston simulation and it works very well. I have the part which extends in and out ‘looking at’ the part which it comes in and out of…and vice versa,this works beautifully. However when these objects get to a certain rotation they both spin 180 degrees?! 
Ive tried putting rotation constraints on them but nothing seem to stop this spinning problem? Anyone have any ideas?
Appreciate your time 
are you in use of a LookAt function for the pistons? Such similar artefact I experienced with a past 3D-Menu. A problem may be the hierarchy causing artefacts because rotations is relative to the parent you may have as a scenario… ever tried with other hierarchy combination or a simple LookAt or LocalRotation… post some more infos if I couldn’t inspire you for a solution…
LookAt() has this problem because it minimizes the angle between the local transform.up and Vector3.up (or whatever vector you set as the second parameter of the function, by default it is Vector3.up).
I wouldn’t use LookAt() for the situation you describe. If these objects only move in one axis relative to one another (like in a piston), just put them both in the same parent object and the movable part can move along it’s local axis toward the base.