Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

Motion Control Quick Start (15-1) | Motion Buffer Function


Motion Control Quick Start Knowledge keeps moving.
Before, we had learned: 
quick start (1) -- firmware update
quick start (2) -- ZBasic program development
quick start (3) -- ZPLC program development
quick start (4) -- Communicate with HMI
quick start (5) -- IO Input & Output 
quick start (6) -- Data Storage
quick start (7) -- ZCAN Expansion Module
quick start (8) -- EtherCAT Expansion Module
quick start (9) -- Oscilloscope
quick start (10)--Multiple Task Operation
quick start (11)--Interrupt Application on Zmotion motion controller
quick start (12)--How To Use U Disk Interface For Zmotion Motion Controller
quick start (13)--How To Use ZDevelop Programming Software
quick start (14-1)--Zmotion Programming Axis Parameters Introduction

Hi, everyone, nice to meet you.

In last "Motion Control Quick Start" article, we talked about ZMotion motion controller programming axis parameters and basic motion control instructions. Today, let's see motion buffer, which can process multiple instructions without blocking.



1. Material Preparation

One computer that is installed ZDevelop V3.10 or above versions

One controller

One 24V DC power supply

A series of bus driver + motor / stepper driver + motor

A series of controller wiring terminals

A series of network cables

A series of connecting cables

(According to actual requirements, select input and output devices, expansion module, hmi, etc.

2.png

            




2.   What is Motion Buffer?

When running multiple motion instructions, there is one buffer area provided by the motion controller to save the motion buffer queue entering the motion buffer, in this way, prevent the program from being blocked. Then, this function is called "motion buffer" , so that the program can scan normally without blocking.

Generally, Zmotion motion controller has multilevel motion buffer. When the motion buffer is turned on, and when the program scans and recognizes the first motion instruction of the program task, it will assign the motion instruction to the motion buffer of the specified axis, and the motor starts to move. At this time, the program continues to scan, when the second motion command is scanned, which is saved into motion buffer, and while the motion instructions are continuously scanned and stored, the motion commands are sequentially taken out from the motion buffer and executed.

And motion instructions of any program can enter motion buffer of any axis, which is assigned by axis No., in addition, motion buffer areas of each axis are independent, which means they don't bother each other.

1.png

Notes:

  1. MTYPE is the current running motion instruction and NTYPE is the first buffer motion instruction.

  2. When buffering multiple motion instructions, in order to judge the current executing motion instruction, there are MOVE_MARK motion label and MOVE_CURMARK current motion label instructions to check. MOVE_MARK motion label will add one when scanned one motion instruction, and MOVE_CURMARK instruction is the current motion label, indicating which motion instruction the current motion reaches, and -1 after all motions are completed.

  3. When the current motion finished, it will automatically execute the next motion of motion buffer. And when all instructions are executed, the motion buffer is blank, or use CANCEL/RAPIDSTOP instruction to clear motion buffer.

  4. SP also belongs to motion instruction, when SP motion commands (directly add "SP" behind instructions, such as, MOVESP, MOVECIRSCSP, etc.) are used, SP speed FORCE_SPEED, ENDMOVE_SPEED and STARTMOVE_SPEED will follow SP motion commands to enter motion buffer area.

  5. The difference between SP motion command and motion command:

    Speed of MOVE(100) is SPEED = 100.

    Speed of MOVESP(100) is FORCE_SPEED = 200.

2.jpg


(1) Motion Buffer Blocking

Even though motion buffer can prevent program from being blocked, the motion buffer area of each axis is also limited, when too many motion instructions are scanned into the motion buffer, the multi-level motion buffer will be full. If the program continues to scan more motion instructions, the program will also be blocked , until the motion commands are completed and exited in sequence, then there will be a vacancy in motion buffer, motion commands will continue to enter the motion buffer.  

For example:

Take V3.10 version simulator as an example, the default is 4096 motion buffers. The routine in the following figure shows that the motion buffer of the controller can store up to 459 circular interpolation instructions, and the value of i is 485 after downloading the program, which means that the current FOR loop has not been executed and the program is blocked.

3.png

As shown in the figure below, when some motion commands are taken out from the motion buffer and are executed, the buffer has the space , FOR loop continues to execute, then saves the motion commands into the motion buffer. After the instruction is executed and exits the motion buffer, as long as there is enough space in the motion buffer, new motion instructions will be stored in the motion buffer one by one.

4.png

Each axis' motion buffer is separate, they don't influence each other, and they are with same buffer area. The remaining valid buffers of one certain axis can be checked through REMAIN_BUFFER(MTYPE) AXIS(n).

ZMC4XX series motion controller each axis can be up to 4096 motion buffers (different controllers are with different buffer numbers, for details, please refer to hardware manual or using ?*max instruction). In addition, LIMIT_BUFFERED motion buffer limit can be set manually.

What's more, the motion command is more complex, the buffer space is more.

For example, ZMC432, it has 4096 motion buffer areas. But the number of MOVE linear interpolation instructions and MOVECIRC circular interpolation instructions are different that can be buffered once in buffer area.

Buffer in interpolation is in main axis' motion buffer.

5.png

6.png


(2) Motion Buffer Routine

7.png

8.jpg

Interpolation motion buffer is in master axis axis 0, so no command for axis 1 motion buffer, the remain buffer is only 3. And each MOVE command occupies one buffer.

9.jpg


(3) Ordinary Output VS Output in Motion Buffer

Ordinary output: when this line command is scanned, it will execute outputting.

Output in Motion Buffer: when this line command is scanned, it is saved into motion buffer area firstly, then the motion buffer takes out the instructions in the order of first-in-first-out for execution, and the output will not be executed until the output instruction is fetched.

10.png  

In this example, after delay 1s, program scans to OP command, OUT0 executes immediately. IO operation command is filled into motion buffer by MOVE_OP, so after run MOVE(100), OUT1 outputs.

11.jpg






3. Motion Buffer Related Commands

(1) MOVE_OP -- Output in Buffer

Grammar: MOVE_OP (output No., output state)

This command enters the motion buffer together with other motion commands, and only operates the OP output when it is taken out of the motion buffer for execution.It can control an output port to output signals individually, or output them in batches, without interrupting the continuity of interpolation motion.

12.png

In this example, the motion instructions in lines 11-15 are stored in the motion buffer in sequence, and executed in the order of first-in-first-out. After MOVE (100) is finished, MOVE_OP operates OUT0 to output, and continues to execute the second MOVE (100), and then use MOVE_OP to close OUT0, the last control OUT1-3 to output in batch.

13.jpg


(2) MOVE_OP2 -- Output in Buffer 2

Grammar: MOVE_OP2 (output No., output status, invert after output n ms)

The BASE axis motion buffer adds an output operation, and after the specified time, the output state is reversed.

Also, this command enters the motion buffer together with other motion commands, and the OP output is operated only when it is taken out of the motion buffer for execution, and the output is turned off after a certain period of time.

A single axis only supports one pulse output at a time, and the second MOVE_OP2 command will automatically turn off the pulse of the previous command.The continuity of the interpolated movement is not interrupted.

14.png

15.jpg


(3) MOVE_DELAY -- Delay in Buffer

Grammar: MOVE_DELAY (delay n ms)

A delay is added to the BASE axis motion buffer.

This command does not perform any movement during buffer execution, but only delays for a specified time.

The delay will automatically reduce the speed to 0 when the previous motion command ends, which will interrupt the continuity of the interpolation motion.  

16.png

17.jpg


(4) MOVE_AOUT -- Output Analog in Buffer

Grammar: MOVE_AOUT(DA number, output value)

Add an AOUT command to the BASE axis motion buffer.

This command buffer does not perform any movement during execution, only modifies the AOUT value, and will not interrupt the continuity of the interpolation movement.

18.png

19.jpg


(5) MOVE_PAUSE -- Pause the Motion

Pause axis motion, it is only valid for single axis or multi-axis interpolation motion. When in multi-axis linkage, pause all together.

When the axis has paused or is not in motion, there will be a "warning"when calling this command, but it will not affect the program running.

Actually, some motions do not support pause, such as VMOVE, synchronous motion instructions, etc.AXISSTATUS can be used to check whether there is a pause. When in pause, theIDLE state of the axis is 0.

Grammar: MOVE_PAUSE(mode value)

20.png

Example for Mode 0: MOVE_PAUSE (3) execution effect is the same as MOVE_PAUSE(0).

21.png

Example for Mode 1:the effect of mode 2 is similar with mode 1 when motion label No. MOVE_MARK is automatically numbered, because each motion label is different. After one command is moved, motion label will change. When MOVE_MARK(2) takes effect, pause immediately.

Mode 2 is different from Mode 1 when setting MOVE_MARK manually.

22.png

23.jpg

MOVE_PAUSE(1) or MOVE_PAUSE(2)

Example for Mode 2: set MOVE_MARK manually, pause at different MARK border through MOVE_PAUSE(2).

24.png

25.jpg

MOVE_PAUSE(2)


(6) MOVE_RESUME -- Resume the Motion

When the BASE axis pauses, continue motion from where it paused.

You can check whether there is a pause through AXISSTATUS. AXISSTATUS displays 800000h, indicating that the axis has entered the pause state.

26.png

27.jpg


(7) MOVE_TABLE -- Output TABLE in Buffer

One TABLE is added into BASE axis motion buffer.

No movement is made during the execution of the instruction buffer, only the TABLE is modified, and the continuity of the interpolation movement will not be interrupted.

Grammar: MOVE_TABLE(TABLE No., value to be modified)

28.png

29.jpg


(8) MOVE_PARA -- Parameters in Buffer

Modify parameters in BASE axis motion buffer.

This command does not perform any movement during buffer execution, only modifies the parameters, and will not interrupt the continuity of the interpolation movement.

Grammar: MOVE_PARA(parameter name, parameter No., parameter value)

The parameter name must be a non-read-only parameter in ?*set.

30.png

31.jpg


(9) MOVE_PWM -- PWM in Buffer

Operate PWM in BASE axis motion buffer.

There is no movement during instruction buffer execution, only PWM is operated.

Please note PWM can only be turned off by setting the duty cycle to 0, but not by setting the PWM frequency to 0. And the PWM frequency must be adjusted before the PWM is turned on.

Grammar: MOVE_PWM(No., duty cycle[, frequency])

The number is the output port No. that supports the PWM function, it can be checked from hardware manual.

The duty cycle refers to the ratio of the active level to the entire cycle, the range is 0-1, and the pwm is turned off when it is set to 0.In one cycle, the active level is output firstly, and then the inactive level is output.

The default frequency is 1KHz,the hardware maximum is 1MHz, and the software maximum is 2KHz.

32.png

Example running effect: Initialize and turn off PWM output, after MOVE(10) is finished, operate PWM0 to output, when it remains 100ms, modify the duty cycle and duty frequency of PWM0, and then run MOVE(20) to turn off PWM output. And when the WHILE loop is running on axis 0, it prints the duty cycle and frequency of the PWM output every 30ms. After the axis 0 stops, exit the WHILEloop without printing.

33.png


(10) MOVE_SYNMOVE -- Trigger Other Axes in Buffer

In the BASE axis motion buffer, trigger the movement of other axes, and the current axis waits for the other axes to complete the motion, then the current axis continues to move.

Grammar: MOVE_SYNMOVE(axisnum,dis[,ifsp])

axisnum: axis No. that needs synchronous motion

dis: relative movement distance

ifsp: whether to use SP movement, the default value 0 is not used.

34.png

35.jpg

The effect after using SP movement is as follows. Set the last parameter to a value other than 0. At this time, the triggered movement speed of axis 1 is FORCE_SPEED=200.

36.jpg


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