Design and implementation of a novel model predictive control algorithm for permanent magnet synchronous machines