Design and Implementation of a Novel Model Predictive Control Algorithm for Permanent Magnet Synchronous Machines