Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

EtherCAT Motion Controller PLC Programming (1) | linear Interpolation


LAD means Ladder Logic Programming Language.

It is called the first programming language of PLC, because it is the graphic programming language used very widely in PLC.

LAD uses relay control circuit, that is, it simplifies the symbol on the basis of common relays and contactor logic control. Then it is intuitive, technical staff can use it easily.

Here, Zmotion brings one series of EtherCAT motion controller PLC programming knowledge.

And take ZMC006CE EtherCAT motion controller as the example to introduce functions related to PLC programming.

Today, this article will show EtherCAT motion controller PLC programming in "linear interpolation".

As usual, there are word description, graphic displaying and video operation.

For videos about Zmotion technical support, motion control products and related all can be viewed by youtube "@Zmotioncontroller123" / "ZMOTION CONTROLLER".

Now, let's begin.


PART
01
Hardware: EtherCAT Motion Controller ZMC006CE

Zmotion ZMC006CE is a kind of high-performance EtherCAT motion controller.

ZMC006CE supports ZBasic, ZPLC and ZHMI programming.

1.png

2.png




PART
02
PLC: LAD Introduction

(1) LAD Running Logic

Through PLC programming, it starts to execute from the left bus bar. That is, it scans from the left to right, from upper to bottom. And one scan period means first line of program to END. When one period is scanned, the next program will be scanned, until final END.

While PLC is running, there are 5 phases, self-detection, communication processing, input detection, program execution and output refresh. Before scanning the program, execute malfunction detection and check the program firstly, when it is powered down abnormally, error message is shown and program edit problem is printed, then execute the communication with other devices.

3.png

For one scan cycle, it includes input detection, program execution and output refresh.

And the scan period depends on program length, instruction type and CPU execution command speed.

The time of scan period can be checked through special register D8010 (scan time), D8011 (min scan time) and D8012 (max scan time).

--Input Detection--

In the sequence of scanning, PLC reads connection status of each input terminal, and writes into corresponding input state register, that is, refresh input, the next stage is program execution. Generally, the width of input signal must be more than one scan period, otherwise, it may cause signal lose.

--Program Execution--

PLC scans each LAD commands from the left to right, from the upper to bottom, and saves related operation and processing results into output state register. In the process of program execution, if input signal has changed, but now input state in the state register hasn't changed, until next scan starts, reading input signal status again.

--Output Refresh--

When all commands are executed, write connection status of output state register into output terminal to drive corresponding output devices.


(2) PLC & BASCI

--PLC calls BASIC--

PLC calls BASIC standard commands through EXE instruction or EXEP instruction. The EXEP instruction is the pulse format of EXE instruction.

Basic standard commands only can be called when OFF of drive input became ON.

Grammar format:

"EXE  @BASIC command" equals to "BASIC   Command ".

4.png

--PLC calls BASIC & PLC--

PLC uses CALL command to call subprogram. And program files must be in the same project file (.zpj).

PLC calls PLC subprogram

After calling subprogram through CALL, jump into corresponding LBL line, then return when executed SRET instruction.

5.png

PLC calls Basic subprogram

When PLC calls Basic subprogram, it needs to add "@" before SUB function. And while calling, select whether transfers parameters according to actual situation, please refer to LV0.

6.png

PLC LAD program

7.png

called Basic program

--BASIC calls PLC--

Program files must be in the same project file (.zpj).

Basic opens PLC task

In Basic, use "run"xxx.plc", task No." to open PLC file task.  

8.png

SRET subprogram (return command) in PLC subprogram can bring with return value.

Then return value is saved into LV local register, and the return value is in floating point format, then the caller gets return value through RETURN command.

Basic calls PLC subprogram

In Basic, use "CALL   SUB_FUNC" or "RUNTASK Task No.,  SUB_FUNC" to call PLC subprogram LBL.

Please refer to below image, after Basic program executes into CALL command, then jumps into PLC program LBL subprogram to execute. When executed subprogram SRET, returned parameter LV1 is saved into RETURN.  

9.png




PART
03
Interpolation Function

(1) How Linear Interpolation Achieves

In the linear interpolation, the interpolation between two points closes to each other along the group point of line. 

Firstly, assume the real contour starting point moves a short distance in X direction (give one pulse equivalent, the axis will move a fixed distance). 

Then, find the terminal point is upper the real contour, the next segment will move s short distance in Y direction, if the terminal is also below now, continuing to move in Y, it will move a short distance in X until it is above the real contour. The motion cycles like this, until it arrives the contour terminal point. 

In this way, the actual contour is formed by splicing a segment of polylines. Although it is a polyline, each segment of the interpolation segment is very small within the allowable accuracy range, so this segment of the polyline can still be approximately regarded as a straight line, which is linear interpolation.

If the axis needs to move from point (X0,Y0) to point (X1,Y1) in the XY plane, the processing process of linear interpolation is like the below figure:

10.png

Please note the motion distance in one pulse of the axis is determined by motor, one single pulse motion distance of different axes are different.

(2) PLC LAD Interpolation Command

In Zmotion PLC programming, there are ZBasic form and PLC form for interpolation commands.

11.png

PLC uses Zbasic form

12.png

PLC uses PLC form

--Zbasic interpolation--

MOVE: Linear Motion

13.png

--PLC interpolation--

MOVE

Instruction description: MOVE command is linear interpolation relative motion.

Operands:

  S1 T,C,D,K,H,Z,V,LV,DT,@

  S2 T,C,D,K,H,Z,V,LV,DT,@

  ……

  S8 T,C,D,K,H,Z,V,LV,DT,@

If operand uses word register, values in register need to floating instruction to assign.

Programming example:

14.png

use MOVE directly in PLC




PART
04
PLC Linear Interpolation Example

PLC & Zbasic Routine

15.jpg

video

16.png

main loop

17.png

axis initial  

18.png

interpolation

19.png

20.png

When S curves of axis 0 and axis 1 are set, smooth time is 100ms, SRAMP=100, 100, the speed curve is shown below:

21.png

22.png

PLC Related Instruction List

23.png

Corresponding ZBasic Program







ABOUT ZMOTION

That's all, thank you for your reading -- EtherCAT Motion Controller PLC Programming (1) | linear Interpolation

For more information, please pay close attention to "Support"  and   "Download" , and there are other platforms about Zmotion - Youtube   &   LinkedIn   &   Twitter    &   Tiktok    &   Facebook including technical information (development environment, routine code), product showing, company development, etc.

Hope to meet you, talk with you and be friends with you.  Welcome!

This article is edited by ZMOTION, here, share with you, let's learn together.

ZMOTION: DO THE BEST TO USE MOTION CONTROL.

Note: Copyright belongs to Zmotion Technology, if there is reproduction, please indicate article source. Thank you.

Zmotion Technology focuses on development of motion control technology and general motion control products, it is a national high and new technology enterprise. Due to its concentration and hard work in motion control technology, ZMOTION already become one of the fastest growing industrial motion control companies in China, and is also the rare company who has managed core technologies of motion control and real time industrial control software completely. Here, Zmotion provides motion controller, motion control card, vision motion controller, expansion module and HMI. In addition, there is one program software developed by Zmotion -- ZDevelop. It is a good choice for you to program and compile. And program through upper computer, there is PC manual.

Zmotion Technology  provides motion control card, motion controller, vision motion controller, expansion module and HMI. ( more keywords   for Zmotion: EtherCAT motion control card, EtherCAT motion controller, motion control system, vision controller, motion control PLC, robot controller, vision positioning...)

Have a good day, best wishes, see you next time.


2013-2023 版权所有 Zmotion Corp. Copyright Reserved 粤ICP备13037187号-1