A free piston device, comprising: - a housing having a cylindrical inner wall defining a cylindrical cavity, the cylindrical inner wall having a first wall opening connectable to a first channel and a second wall opening connectable to a second channel; - a cylindrical piston arranged in said cylindrical cavity and being movable in axial direction and being rotatable around its longitudinal axis; - the piston comprising a central element, and a first skirt having a cylindrical wall defining a first cylindrical space closed at one end by a first face of said central element, the first face and at least part of the cylindrical wall of the first skirt and a transverse wall section of an element mounted inside the housing or a transverse wall section being part of the housing, said transverse wall section being positioned inside the cylindrical space of the first skirt, forming a first chamber inside said first skirt, said first skirt having at least a first skirt opening in the form of a first hole through the cylindrical wall of the first skirt for allowing passage of a fluid directly into or out of said first chamber; - first control means (181, 182) for controlling movement of said piston in axial direction along its longitudinal axis; - second control means (181, 182) for controlling movement of the piston in angular direction (φ) around its longitudinal axis; - sensing means adapted for providing a first signal related to the axial position (p) and a second signal related to the angular position (φ) of the piston relative to the housing; - a digital control unit configured for controlling the first and/or the second control means (181, 182) for rotating the piston around its longitudinal axis nd/or for moving the piston along its longitudinal axis, based on at least the first and the second signal, in a manner wherein the axial movement is synchronized with the longitudinal movement such that the first skirt opening is in fluid connection with the first wall opening at a first moment in time when the piston is in a first axial position, and such that the first skirt opening is in fluid connection with the second wall opening at a second moment in time when the piston is in a second axial position different from the first axial position. - a housing having a cylindrical inner wall defining a cylindrical cavity, the cylindrical inner wall having a first wall opening connectable to a first channel and a second wall opening connectable to a second channel; - a cylindrical piston arranged in said cylindrical cavity and being movable in axial direction and being rotatable around its longitudinal axis; - the piston comprising a central element, and a first skirt having a cylindrical wall defining a first cylindrical space closed at one end by a first face of said central element, the first face and at least part of the cylindrical wall of the first skirt and a transverse wall section of an element mounted inside the housing or a transverse wall section being part of the housing, said transverse wall section being positioned inside the cylindrical space of the first skirt, forming a first chamber inside said first skirt, said first skirt having at least a first skirt opening in the form of a first hole through the cylindrical wall of the first skirt for allowing passage of a fluid directly into or out of said first chamber; - first control means (181, 182) for controlling movement of said piston in axial direction along its longitudinal axis; - second control means (181, 182) for controlling movement of the piston in angular direction (φ) around its longitudinal axis; - sensing means adapted for providing a first signal related to the axial position (p) and a second signal related to the angular position (φ) of the piston relative to the housing; - a digital control unit configured for controlling the first and/or the second control means (181, 182) for rotating the piston around its longitudinal axis nd/or for moving the piston along its longitudinal axis, based on at least the first and the second signal, in a manner wherein the axial movement is synchronized with the longitudinal movement such that the first skirt opening is in fluid connection with the first wall opening at a first moment in time when the piston is in a first axial position, and such that the first skirt opening is in fluid connection with the second wall opening at a second moment in time when the piston is in a second axial position different from the first axial position.