Real-time identification of PMSM losses through a novel past-time averaging method