https://dataprojectng.com/6619/DESIGN AND CONSTRUCTION OF AN AUTOMATIC PHASE SELECTOR
Check this out