How to work AC and DC motor?