Motion Control Tasks
The XMC supports up to 256 programs that are the motion programs and NC programs.
-
The motion programs for the XMC reside in the main task, periodic task, and initialization task.
-
The Main Task time can be set to 0.5/1/2/4 ms.
-
The maximum time is 4 ms to ensure smooth motion control.
-
If the main task time is set incorrectly, an error 0x0260 will occur.
-
If the Periodic Task time is not set to a multiple of the main task, an error 0x0261 will occur.
Main Task
-
Performs I/O refresh.
-
Processing of programs assigned to main task and motion control.
-
Performs within the Main Task Time.
-
Has a higher priority than the periodic task.
-
It is used for programs that require synchronized control and high-speed operation processing with short cycle time.
-
Period can be set to 0.5 ms, 1 ms, 2 ms, or 4 ms.
Periodic Task
-
Performs processing of programs assigned to it.
-
Programs are processed in the remaining time after the execution of the main task in each main task period.
-
Programs can be processed over multiple main task periods.
-
Has a lower priority then the Main task.
-
Should be used for processing monitoring data and control of devices that don’t require high-speed processing.
-
Period can be set to 1 ms ~ 100 ms (Set to a multiple of the main task time).
Initialization Task
-
The XMC executes the initialization tasks before starting the execution of the main tasks and periodic tasks after the XMC turned in RUN mode.
-
If an initialization task is written with LD, the extension function INIT_DONE must be executed to complete the initialization with the task.
-
If an initialization task is written with ST, the INIT_DONE_EN function must be executed to complete the initialization with the task.
-
The execution of the main task and periodic task starts after all initialization tasks are completed.
Task Time Setup Location
The Task time parameters are setup in the Basic Parameter screen of the XMC project.
-
Make sure to properly configure the Main Task Time and Periodic Task Time for your application.
-
Periodic Task Periodic Error is the Periodic Task Time Error.
Task operation is composed of the main task and periodic task within the main task period. Main Task performs I/O refresh, processes programs, and motion control during the main task period. The periodic task is performed in the main task periods remaining time after the main task is completed and it can take many control periods.
The main task must be performed within the Main Task time. If the performance of the main task exceeds the main task time, a warning occurs and the XMC stays in RUN mode. If the performance of the main task exceeds the Main Task Time Error setting in the basic parameters of the XMC project, an error occurs and the XMC turns in STOP mode by indicating the error condition.
The periodic task is executed in the remaining time un each main task period. The periodic task may be executed over several main task periods depending on the performance time of the task. If the execution of the periodic task exceeds the set periodic task time, a warning will occur. If the execution of the periodic task exceeds the Periodic Task Time Error time in basic parameter setup, an error occurs and the XMC turns in STOP mode by indicating the error condition.
The execution of motion function blocks in the main task begins with the I/O refresh. I/O refresh updates the input values from the EtherCAT slaves and other system inputs. Motion control is performed in the main task based on this information update. The output to the slave modules is executed in the next I/O refresh time of the next control period.
Motion function blocks in the periodic task are executed after the motion control is executed in the main task. The I/O refresh at the beginning of the periodic task cycle is used when starting the execution of programs in the periodic task. The output to the slaves will occur in the I/O refresh of the next main task period after the execution of the periodic task is completed. If the periodic task program is executed within several main task periods, the motion control result of the main task is reflected in the periodic task program.
LM106