Exemplary embodiments of the invention provide a sensor attachment
mechanism capable of attaching a position detecting sensor having
directivity in a proper direction to a fluid pressure cylinder having a
rail extending along the length of a cylinder tube on the outer surface
thereof. Embodiments include a position detecting sensor for sensing the
operating position of a piston is attached with a sensor holder to a
grooved rail extending along the length of a cylinder tube on the outer
surface thereof. The position detecting sensor has directivity in
magnetic detection. The sensor holder includes a base mounted on the rail
and a sensor holding part extending from the base. The sensor holding
part is close to or in contact with the surface of the cylinder tube
outside rail walls. The sensor holding part has a holding guide for
holding the position detecting sensor in a direction parallel to the axis
line of the cylinder such that the directivity of the sensor in the
magnetic detection is directed to substantially the center of the
cylinder.