A method for position sensorless control of a permanent magnet machine, the method comprises the following steps: - measuring a stator current of the permanent magnet machine, - determining a stator flux of the permanent magnet machine from the stator current, - computing a total rotor position error from at least the stator flux and the stator current, characterised by: - computing a stator flux-related position error, and a stator current-related position error, - deriving a speed-dependent offset compensation angle for the position error, and - computing the total rotor position error from the stator flux-related position error, the stator current-related position error and the speed-dependent offset compensation angle, - determining an estimated raw speed signal from the total rotor position error, including the steps: - PI regulation of position error function to get the estimated speed error signal, - obtain a speed feed forward signal by low pass filtering of the speed signal applied in the generator control of previous control sample, and - obtain the estimated raw speed signal by summing up the estimated speed error signal and speed forward signal, - integrating the raw speed signal so as to derive an estimated angular rotor position of a rotor of the permanent magnet machine, and - applying the estimated angular rotor position to control the permanent magnet machine. - measuring a stator current of the permanent magnet machine, - determining a stator flux of the permanent magnet machine from the stator current, - computing a total rotor position error from at least the stator flux and the stator current, characterised by: - computing a stator flux-related position error, and a stator current-related position error, - deriving a speed-dependent offset compensation angle for the position error, and - computing the total rotor position error from the stator flux-related position error, the stator current-related position error and the speed-dependent offset compensation angle, - computing a stator flux-related position error, and a stator current-related position error, - deriving a speed-dependent offset compensation angle for the position error, and - computing the total rotor position error from the stator flux-related position error, the stator current-related position error and the speed-dependent offset compensation angle, - determining an estimated raw speed signal from the total rotor position error, including the steps: - PI regulation of position error function to get the estimated speed error signal, - obtain a speed feed forward signal by low pass filtering of the speed signal applied in the generator control of previous control sample, and - obtain the estimated raw speed signal by summing up the estimated speed error signal and speed forward signal, - PI regulation of position error function to get the estimated speed error signal, - obtain a speed feed forward signal by low pass filtering of the speed signal applied in the generator control of previous control sample, and - obtain the estimated raw speed signal by summing up the estimated speed error signal and speed forward signal, - integrating the raw speed signal so as to derive an estimated angular rotor position of a rotor of the permanent magnet machine, and - applying the estimated angular rotor position to control the permanent magnet machine.