Abstract:As modern control systems demand increasingly higher real-time performance and precision, microsecond-level sampling real-time control technology has become a research hotspot. To address the reliance on foreign platforms in existing solutions, this paper presents a microsecond-level sampling real-time control system based on the STM32 microcontroller, designed with independent intellectual property rights. The system addresses key challenges, including the real-time performance of control tasks, the efficiency of communication tasks, and the complexity of automatic code generation. It employs the FreeRTOS real-time operating system for task scheduling, hardware timers for high-priority execution of control tasks, and the LwIP protocol for low-latency network communication, enabling efficient data uploading and command reception. Furthermore, the paper proposes a graphical block diagram-based approach for control algorithm parsing and automatic code generation, where a server parses user-designed block diagrams and generates optimized control code tailored for STM32 hardware. Experimental validation using the field-oriented control of a permanent magnet synchronous motor demonstrates the system′s excellent real-time performance and control capability under microsecond-level sampling. This system effectively overcomes the constraints imposed by foreign technological barriers, significantly enhancing the development capabilities of domestic control systems. The proposed solution offers a viable approach to addressing critical “bottleneck” issues in key technologies and holds great potential for wide-ranging applications and scalability.