XPLC006E is a kind of multi-axis economical EtherCAT bus motion controller developed by ZMotion Technology, and XPLC series motion controllers can be applied in all kinds of occasions that need offline or online operation.
XPLC006E has 6 motor axes itself, and motion control of 12 axes at most can be achieved (including virtual axes). Also, it supports 12-axis linear interpolation, electronic cam, electronic gear, synchronous follow, virtual axis setting, etc.
In addition, XPLC006E cost-effective controller supports multi-task run synchronously. At the same time, it can do simulation on PC directly. There are several valid programming methods, such as, Basic / PLC ladder diagram / HMI configuration in ZDevelop software and commonly used upper computer software.
For PC upper computer API programming, following interfaces are supported: C#, C++, LabVIEW, VB, matlab, Qt, Linux, .Net, iMAC, Python, ROS, etc.
→Actually, according to different axis numbers, there are XPLC004E, XPLC006E and XPLC008E
There is one note: XPLC006E belongs to bus motion controller, which means it only supports EtherCAT bus axes, pulse axes and encoder axes are invalid. Then, it uses EtherCAT bus and drive to communication with refresh cycle of 1ms.
Let's see XPLC864E2, it is upgraded on the basis of XPLC006E, which means, it supports all functions of XPLC006E mentioned above, and usages are basically the same. However, some resource spaces are better than XPLC006E. What's more, XPLC864E2 supports 32 inputs, 32 outputs, 2 ADs and 2 DAs in hardware level, pulse axis and bus axis can be hybrid used. The number of real axes is 8 totally. Except EtherCAT interface, in hardware of output, signal output of 8 axes in pulse direction can be configured, and be with 2 encoder inputs set by input configuration.
Same, XPLC864E2 supports PLC, Basic and HMI configuration programming methods. For PC upper computer API programming, following interfaces are supported: C#, C++, LabVIEW, VB, matlab, Qt, Linux, .Net, iMAC, Python, ROS, etc.
1.1 What is the Task ?
Task is the function to execute I/O refresh, user program and process a series of instructions.
1.2 What the Task No. is for ?
Task No. is used to distinguish tasks,
actually there is no special meaning. The range of task No. must be in the number of tasks that controller support.
1.3 Task Type
No need to assign the task type, there are 2 types users can use,
they are self-defined task and interrupt task. Self-defined task means it is opened by users, and task No. is assigned by users, and then codes in task also are edited by users. Interrupt task means it will be used after interrupt that controller supports is triggered. When interrupt program executed, interrupt task will stop, and it does not need to assign task No. for interrupt task, just run as default task No.
1.4 Task Priority
No priority for task by default. If one task needs to be executed preferentially, which can be achieved through "PROC_PRIORITY". High priority means it is executed preferentially in one system period, then other tasks can be executed.
1.5 Multi-Task
Multiple tasks represent multiple program modules execute at the same time, especially, they can run synchronously and they won't bother each other. Tasks are distributed by users, but the number must be less than max tasks that is supported by controller.
1.6 To Know Task Numbers
XPLC006E supports multiple tasks. Different controllers support different task numbers, to know the exact numbers, connect to controller -- "State the controller" in ZDevelop, or send "?*max"in online command. Please see below image, it represents user can customize 22 tasks for this controller, the task No. should be 0-21.
Multi-task can divide a complex program into several parts and execute tasks at the same time separately. The tasks of each part are independent, which makes the complex motion process of the equipment simple and clear, and makes the programming more flexible. For example, parameter updating, processing, emergency stop, IO scanning and so on can be divided into different task modules. If there is no multi-task, the execution efficiency of the program will be very low.
Within a control period, different tasks will take different time according to the difference of the current instruction. The task does not have the same priority by default. The PROC_PRIORITY command can be used to set the priority of a task.
As shown in the following figure, set the priority of task 5 to 3, and the priority ranges from 1 to 10, and 10 is the highest.
3.1. Each motion control cycle (Servo Period) of the motion controller includes the operation of MC, SS, and user multi-task program, as shown in the following figure.
(1) Motion Control: achieve Motion Control, EtherCAT communication and interruption.
(2) Motion Control includes single-axis motion control, multi-axis interpolation motion, robot positive and negative algorithm. EtherCAT communication includes PDO communication and SDO communication.
(3) System Service includes RS232, RS485 serial communication, CAN communication, EtherNET communication (MODBUS RTU master and slave communication and ZDevelop corresponding software service).
(4) TASK0, …, TASK21: relate to operation of each task, task No. starts from 0, from task 1 to task 21.
3.2 Task Execution Rule of Different Types Files
All tasks of Basic scan and run once, then will stop immediately (unless there is an infinite loop "WHILE" in the program). A Basic file under one project supports multiple auto-running tasks at the same time. And auto-run tasks start simultaneously after powered on, which means there is no sequence.
PLC programs are scanned automatically and cyclically, therefore, it is recommended to set one main task cycle under one project item. Exactly, give one Auto-Run Task No. for PLC file, or open one PLC task in other tasks, then this PLC task is the master task of PLC.
For HMI program, it needs one task to start. Otherwise, HMI file can't run after program is downloaded. And the initialization function only scans and executes once, the periodic function scans cyclically. One HMI file is supported under one project, and the configuration program can run only by setting AutoRun Task No. for the HMI file.
The controller processed 4 tasks at the same time, like the above figure. Task 0, 1, 2 and 3 run parallelly, which means they will not disturb each other. After controller downloaded the program, 4 tasks start simultaneously, and while file task is executing, SUB subprogram task or marking task can start by using task instruction. Once SUB subprogram task or marking task are opened, they become no relation with main program. And tasks can be triggered again after task operated.
3.3 Advantages of Controller Multi-Task
(1) Program modular: user can write several small and specific programs to achieve assigned functions that are consistent with customer's equipment
(2) Concurrency: every task can run independently. When task starts, it won' t be influenced by other tasks
(3) Simplify error process: error processing become easier when multi-task run, only the wrong task will be processed.
(4) Command interaction: when program is running, users can do command interaction in any time, such as, online modify motion parameters, send commands in online command bar, etc. But other programs don't be affected.
Task has three states, they are
Running, Stopped and Paused. Followings are 3 ways to see the state.
4.1 Task instruction
PROC_STATUS: check the task status, parameter only can be read. Return value: 0-task stops, 1-task is running, 3-task pauses.
PRINT PROC_STATUS(0) 'print status of task 0
?*PROC_STATUS 'print status of all tasks supported by controller
Like below image, Basic task 0 and task 1 had stopped, and PLC task 2 is running.
4.2 Task window
Open task window through “Debug” – “Start/Stop Debug”, like the below figure. Task number and running status of started task, current file and operation line number can be viewed through this window, but tasks that don't start can't be known.
When Basic tasks finished scanning in the program, the task will become Stopped state. But PLC main task is always the Running state because it scans round.
4.3 Open menu bar “Debug” – “Bus state diagnosis” window
Status of all task numbers, current file and running line number all can be checked. This window also shows all tasks error information.
5.1 Multiple tasks operation instructions
(1) END: the current task ends normally.
(2) STOP: stop the running task of assigned file.
(3) STOPTASK: stop assigned task.
(4) HALT: stop all tasks.
(5) RUN: start a new task and run a file.
(6) RUNTASK: start a new task and run one SUB or one program with labels.
(7) PAUSETASK: pause assigned task.
(8) RESUMETASK: resume assigned task, then task will execute from that pause position.
Task operations in Basic and PLC both use above instructions.
5.2 ON Multi-task
There are 3 methods, they are auto-running task number configuration, RUN instruction and RUNTASK instruction. When using instructions to start task, task will be opened after this instruction is scanned by program.
Pay attention to the task number writing when starts task, tasks can’t be opened repeatedly.
(1) Auto-running task number:
set auto-running task number through "FileView" window. After the controller is powered on, the file with the auto-running task number will be executed first. Basic file can set several AutoRun task numbers, but only one PLC file and HMI file are supported. The auto-run files are run in parallel, and they are turned on at the same time after power-on.
(2) The file as one task is turned on through RUN instruction
Example:
RUN "TuXing_001.bas",2 'set the file TuXing_001.bas as task 2, and start
(3) SUB subprogram or signed program are set as one task and are turned on through RUNTASK instruction. Start global SUB subprogram through cross-file, and the label program that needs to start task only can exist in this file.
Example:
RUNTASK 1,task_home	 'set as task 1 to start the task_home subprogram
5.3 OFF Multi-task
Instructions to stop multi-task: STOPTASK, STOP, HALT.
Task stops, then restarts it, it will execute from the beginning.
When starts task, usually use STOPTASK to stop the task firstly. Then start through RUNTASK for avoiding errors caused by start repeatedly.
(1) STOPTASK supports stop file task SUB subprogram task and labelled task.
Example:
STOPTASK2 'stop task 2
(2) STOP instruction supports stop Basic file task. It is recommended to use STOPTASK instruction, because the operation is simpler.
(3) HALT instruction stops all tasks.
Example:
HALT ‘stop all tasks in project
Also “Emerge Stop” button can be used to stop all tasks rapidly.
Example:
There are 2 tasks in project, after they are downloaded, task 0 and task 1 are running.
-- Send online command: STOPTASK 0
-- stop task 0
When restarts the task, program can be downloaded again.
The above program cannot use the RUN command to start the auto-running file task 0, because the automatically opened task 1 in task 0 is still running. If the command is used to start task 0 again, it will cause task 1 to be opened repeatedly. If task 1 is stopped, start task 1 independently through RUNTASK instruction.
5.4 Pause and Resume Task
Use PAUSETASK command to pause task, and use RESUMETASK command to resume task. After resuming, the task continues to execute from where it was suspended. And paused tasks support stopping.
(1) PAUSETASK: pause assigned task
Example: PAUSETASK 1 'pause task 1
(2) RESUMETASK: resume assigned task
Example: RESUMETASK1 'continue to running task 1
Example: there are 2 tasks in project, after they are downloaded, task 0 and task 1 are running.
-- Send online command to control task is paused or resumed.
-- Send: PAUSETASK 0
Task 0 is paused.
-- Send: RESUMETASK 0
Task 0 resumes the operation state.
6.1 Basic call PLC tasks
(1) Basic file uses RUN instruction to call PLC file.
(2) Basic file uses RUNTASK instruction to call subprogram defined by LBL instruction in PLC.
6.2 PLC call Basic tasks
For PLC, using EXE or EXEP (pulse execution) instructions to call Basic task, then calling Basic file task or subprogram task.
For more information, please pay close attention to "Support" and "Download" , and there are other platforms about ZMOTION -- Youtube &