With the rapid development of edge computing, industrial automation has evolved a two-layer distributed computing architecture, including local controllers communicating through wired networks and edge controllers communicating wirelessly. The edge controllers in existing studies use WIFI, which has a limited working distance and requires independent network deployment, so they are unsuitable for future large-scale complex industrial production. At present, 5G technology is undergoing rapid development in the field of industrial automation, with wide coverage and excellent mobility, gradually becoming suitable for future large-scale and complex industrial production scenarios. Therefore, this paper proposed an SW5G method based on 5G, which combined the local controller with the edge controller. The controllers were switched according to the constantly changing 5G network transmission delay, thereby optimizing the overall system control performance. Finally, simulation experiments demonstrated good control performance of SW5G in various network scenarios.