Motor Controller with global variables