A method for determining a position of a component in a medical apparatus along a travel distance. The method comprising the steps of generating light by a light source; fixing the component movably along a travel distance; providing a photosensitive sensor surface, and generating a silhouette of the component on the sensor surface by irradiating the component with light from the light source. Data relating to the silhouette is converted by a data processing unit into the position of the component along the travel distance. The component whose position is determined may comprise a stopper of a cartridge.