This invention relates to a method and controller for controlling cycle scheduling. Both a foreground / background
system and a real-time
operating system are located within the controller. The method includes: S1, the foreground / background
system receives data from an input module connected to the controller and performs
sequential logic execution
processing on the data until the
data processing is complete, obtaining the corresponding execution result; S2, performing context switching
processing between the foreground / background
system and the real-time
operating system to switch from the foreground / background system to the real-time
operating system within the controller; S3, the real-time operating system processes user program tasks until a preset time period is reached; S4, performing context switching
processing between the real-time operating system and the foreground / background system to switch from the real-time operating system to the foreground / background system within the controller; S5, the foreground / background system outputs the execution result to an output module connected to the controller.