a locking device is used for locking at least a piston associated with an operating element of a valve , a choke , a blowout preventer or some other unit used in the field of oil / natural gas drilling and / or oil / natural gas production . the locking device comprises a sleeve , which is axially displaceable relative to the piston and which is threadedly engaged with a rotatably supported rod for displacement in an axial direction . the rod is drivingly connected to a motor . in order to be able to determine , by means of simple structural measures , the position of the piston for each of its positions in a sufficiently precise and reproducible manner , the locking device is provided with a position sensor , which extends from a fixed point through a longitudinal bore of the lock rod up to the hydraulic piston and by means of which a distance between the piston and the fixed point can be detected .