A non-transitory computer-readable data storage medium storing a computer program having program codes which, when executed on a computer, performs a method for controlling an electric machine in a vehicle, wherein the electric machine is assigned an energy storage device, and wherein the electric machine is supplied with power from the energy storage device in a motor mode and energy is stored in the energy storage deice in a generator mode of the electric machine, the method comprising:
- determining a power limiting value for the electric machine, wherein the determining of the power limiting value includes:
- calculating an intermediate power value from a maximally allowable current of the energy storage device and an instantaneous voltage;
- determining a corrected intermediate power value by a pilot control unit by adding at least one power loss value to the calculated intermediate power value;
- determining a first correction value by a second control unit for reducing the absolute value of the corrected intermediate power value if the absolute value of an instantaneous power of the energy storage device is greater than the calculated intermediate power value;
- and
- determining the power limiting value by superimposing the first correction value on the corrected intermediate power value one of additively or multiplicatively.