the present invention relates to a method for determining the existence of an earth - fault on - the - fly and thereby protecting a motor controller having a high - and a low - side dc - link , and having high - and low - side switching elements , the high - and low - side switching elements being operatively connected to the high - and low - side dc - link buses , respectively , the method comprising the steps of generating a fault signal , generating at least one test vector in response to the fault signal by switching at least one of the switching elements on , and measuring , while the at least one switching element is on , the magnitude of a current flowing in that dc - link operatively connected to the conducting switching element in order to detect an earth - fault . the present invention further relates to additional methods for on - the - fly determination of earth - faults .