<

Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

Economical EtherCAT Motion Controller (5-2) -- How Multi-Task Programming Of Motion Controller Is ?



XPLC006E Function Introduction

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.


image XPLC006E.png

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.

image 1.png

→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.




XPLC864E2 Function Introduction

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.

XPLC864E2.png


image 2.png









07   Multi-Task Calling Routine

It is valid for XPLC864E motion controller to program through three kinds of methods of ZDevelop, at the same time, it supports multiple interpolation functions. Here, 2 different multi-task routines can be referred.

Program is downloaded to run, firstly start the file with AutoRun Task No., and several or one auto-run task No. can be set. Then, other file tasks use "RUN" instruction to open.

Next, in files that run automatically, add "RUN" or "RUNTASK" instruction to call other tasks for execution,according to the place where the program to be called is.

At last, while programming, depend on functions, each module assigns one task No. to run. Task will be called and executed when modular program block is needed. In this way, program scanning time can be reduced, and execution efficiency of controller can be promoted.

7.1 Basic Multi-Task Program

There are 2 Basic files, "Main" file will run as task 0 when powered on. For other tasks, use instruction to open, see below image.

image 23.png

image 24.png


(1) File 1: Main.bas

RAPIDSTOP(2)

WAIT IDLE

GlobalInit      'parameter definition

AxesInit        'axis parameter initialization

WHILE 1

   IF  SCAN_EVENT(IN(0))> 0 THEN     'start main motion

      STOPTASK 2 

      'Basic open task, call Basic file

      RUN "TuXing_001.bas",2      'as task 2 to run main motion program

   ENDIF

   IF  SCAN_EVENT(IN(1))> 0 THEN      'stop

      sub_stop

   ENDIF

   IF  SCAN_EVENT(IN(2))> 0 THEN      'homing

      RUNTASK 1,task_home            'as task 1 to start homing

   ENDIF

WEND

END                                    'main program ends

 

'''parameters definition

GLOBAL SUB GlobalInit() 

   'main program

   GLOBAL CONST AXISNUM = 3        'axes in all

   GLOBAL g_state                               'controller status

   g_state = 0                                      '0--initail state, 1--standby, 2--homing, 3--running

   GLOBAL deal_home                         'homing mark

   deal_home = 0   

END SUB

 

'''axis parameters and IO definition

GLOBAL SUB AxesInit()

   BASE(0,1,2)

   DPOS=0,0,0

   MPOS=0,0,0

   UNITS = 100,100,100  'pulse amount

   ATYPE = 1,1,1            'step method

   SPEED=100,100,100

   LSPEED=0,0,0             'initial speed

   CREEP=10,10,10         'inverse speed while homing

   ACCEL=1000,1000,1000

   DECEL=1000,1000,1000

   SRAMP = 20,20,20      'S curve time setting

   DATUM_IN=8,9,10      'origin input configuration

   REV_IN=-1,-1,-1         'negative position limit, which is connected to origin

   FWD_IN=-1,-1,-1        'positive position limit

   ALM_IN = -1,-1,-1

   'special IO reverse is changed into commonly-opened input

   INVERT_IN(8,ON)

   INVERT_IN(9,ON)

   INVERT_IN(10,ON)

   MERGE = ON  'main axis 0 is configured as continuous interpolation by default

   CORNER_MODE = 2    'start corner deceleration

   DECEL_ANGLE = 15 * (PI/180)   'initial deceleration angle: 15

   STOP_ANGLE = 45 * (PI/180)     'decrease to the lowest angle: 45

END SUB

 

GLOBAL SUB task_home()

   g_state = 2   'in the homing

   FOR i = 0 TO AXISNUM - 1

      BASE (i)  'select the axis to join in motion

      CANCEL(2)  'stop

      WAIT IDLE

   NEXT   

   FOR i=0 TO AXISNUM-1

      SPEED(i)=50      'homing speed

      HOMEWAIT(i)=100    'reverse find waiting time

      DATUM(3) AXIS(i)  'homing method

   NEXT

   WAIT UNTIL IDLE(0) AND IDLE(1) AND IDLE(2)

   WA 10

   PRINT "homing finished..."   

   BASE(0,1,2)   

   DPOS=0,0,0

   MPOS=0,0,0   

   g_state = 1    'homing finished, back to standby state

   deal_home = 1   'homing end mark

END SUB

 

GLOBAL SUB sub_stop()    'stop

   STOPTASK 2       'stop main program motion

   STOPTASK 1  

   RAPIDSTOP(2)

   WAIT IDLE

   g_state = 1    'axis stops, back to standby state

END SUB



(2) file 2: TuXing_001.bas

IF deal_home = 1 THEN        'judge whether homing is done or not, execute main program module

   g_state = 3     'in motion

   PRINT "start to move..."

   TRIGGER

   BASE(0,1,2)

   MOVEABS(0,0,0)

   MOVE(100) AXIS(2)

   MOVECIRC(200,0,100,0,1)    'draw half-circle at 100 radius in clockwise

   MOVE(0,-200)

   MOVECIRC(-200,0,-100,0,1)

   MOVE(0,200)

   WAIT IDLE(0) 

   WAIT IDLE(2)

   PRINT "end motion..."

   g_state = 1     'motion finished

ELSE

   PRINT "if axis doesn't homing, please homing firstly..."

ENDIF

END


Position curve of each axis and resultant trajectory under XY mode captured by oscilloscope

image 25.png

Position curve

image 26.png

Resultant trajectory under XY mode


7.2 Basic and PLC multi-task hybrid program

It is recommended to only set one PLC file task. If two PLC file tasks run at the same time, there will be alarm information: Warn file:"PLC2.PLC" line:1 task:2, can not set PLC main task, task:1 already be set.

PLC has one master task 1, task 2 also can run normally.

image 27.png

PLC subprogram task started by "RUNTASK" in PLC file or Basic file only can run once, the effect is same as open PLC subprogram in PLC.

--Use RUNTSAK instruction in Basic file to open PLC subprogram task.

image 28.png

--Use RUNTASK instruction in PLC file to open PLC subprogram task

image 29.png

For example, Basic file is used to do parameter initialization, and PLC file is used as condition to control axis motion. Basic file is opened by auto-run task 0, and PLC file is opened by RUN instruction in Basic file, then scan circularly.

image 30.png

 

Routine Cases:

(1) Basic File Program

RAPIDSTOP(2)

WAIT IDLE(0)

WAIT IDLE(1)

'parameters initialization

BASE(0,1)          'select XY

DPOS = 0,0

MPOS = 0,0

ATYPE=1,1       'pulse stepper or servo

UNITS = 100,100    'pulse amount

SPEED = 100,100

ACCEL = 500,500

DECEL = 500,500

FASTDEC=2000,2000

SRAMP=100,100      'S curve

MERGE = ON         'open continuous interpolation

RUN "PLC1.PLC" ,1  'call PLC file task

 

(2) PLC file ladder diagram program, below shows how the effect is using PLC to achieve above Basic program

image 31.png

 

(3) PLC ladder diagram corresponds to the statement table program (note: the PLC ladder diagram and the statement table can be switched mutually)

// linear interpolation

LD M8002

ZRST M0 M10

LDP X0

DEMOV K300 D0

DEMOV K400  D2

// IN1 rising edge starts and runs, IN2 is pressed, motion stops rapidly.

LDP X1

OR  M0

ANI  M1

ANI  X2

OUT M0

EXEP    @TRIGGER

MOVE D0 D2

LD M8100

PLS M1

END

 

(4) Linear interpolation motion effect -- position curve + resultant trajectory under XY mode

image 32.png

image 33.png







That's all, thank you for your reading -- Economical EtherCAT Motion Controller (5) --  Multi-Task Running

For more information, please pay close attention to   "Support"  and

Copyright © 2013-2024 Shenzhen Zmotion Technology Co.,Ltd Design by Zmotion    粤ICP备13037187号 Motion Controller-Motion Control Card

Contact Us-Youtube