A pump includes a cylinder, a piston and a controller. The cylinder has first and second ends and includes first and second inlet-outlet ports, each of the first and second inlet-outlet ports is configured to alternately intake a fluid to the cylinder and output the fluid from the cylinder. The piston is configured to be moved within the cylinder between the first and second ends by alternately reversing a direction of movement of the piston, so as to pump the fluid through the first and second inlet-outlet ports. The controller is configured to control the movement of the piston within the cylinder, including: (a) choosing between first and second operational modes, (b) in the first operational mode, controlling the piston to oscillate over a predefined interval that does not exceed a predefined distance from the first end or from the second end, and (c) in the second operational mode, controlling the piston to move at a selected speed between the first end and the second end.