Motor speed control of compressors or fans