The invention refers to a device, which includes a combustion engine (1) with a piston (2), which is mechanically freely movable in a housing (3). The device is arranged to permit combustion of a fuel mixture in order to produce a pushing force to the piston (2). The device includes an electromagnetic energy transducer (21, 22) and an external current circuit (34, 41), which is connected to the energy transducer for exchange of effect in a direction to or from the energy transducer. A control unit (12) is arranged to control the direction of the effect, which is exchanged between the energy transducer (21, 22) and the external current circuit, during operation of the device. The invention also refers to a use of such a device for generating electric energy, and a vehicle with such a device.