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. Today, let's continue, the second part, that is, basic motion control instructions of Zmotion motion controller .
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. Motion Status of Common Axis Motion
Axis running states can be viewed through axis parameter window, or through reading return values of corresponding command.
(1) MTYPE - Current Motion Type
Read the type of motion instruction currently in progress. It belongs to read-onlyparameter. It gets the instruction returned value form, then checks the current axis motion type.
Grammar: VAR1 = MTYPE
When the interpolation is linked, the slave axis always returns to the motion command type of the master axis.
(2) NTYPE - Motion Type of Next Motion
Read the type of the first instruction following the currently running motion instruction. It belongs to read-only parameter, check from the form after getting the return value of the command.
Grammar: VAR1 = MTYPE
When the interpolation is linked, the slave axis always returns to the motion command type of the master axis.
(3) IDLE - Current Motion Status
The IDLE command is used to judge whether the motion command added to the axis is completed, and returns 0 during motion, and returns -1 when motion ends.
It is a read-only parameter, and the WAIT IDLE (axis No.) statement is generally used in the program to judge the state of the axis.
When the axis is associated with a robotic arm, using CONNFRAME for inverse kinematic, the joint axis will always return 0, if using CONNREFRAME for forward kinematic, the virtual axis will always return 0.
For example:
RAPID STOP(2)
WAIT IDLE
BASE(0,1,2)
ATYPE=1,1,1
UNITS=100,100,100
SPEED=100,100,100
ACCEL=1000,1000,1000
DECEL=1000,1000,1000
DPOS = 0,0,0
OP(0,OFF)
TRIGGER
MOVE(100,100) 'axis 0 and axis 1 do linear interpolation
MOVE(200) AXIS(2) 'axis 2 movement
WAIT UNTIL IDLE(0) AND IDLE(1) AND IDLE(2)
'wait for axes 0, 1, and 2 to stop
OP(0,ON)
(4) MSPEED - Actual Measured Speed
It is the axis measurement feedback position speed, the unit is UNITS/S, also it belongs to read-only parameter.
When in interpolation motion, sub-speed of each axis is read.
(5) VP_SPEED - Current Motion Speed
It is the speed of current axis, the unit is UNITS/S, also it belongs to read-only parameter.
When multi-axis is in motion, what the main axis returns is the speed of the interpolation motion, not the sub-speed of the master axis. The non-spindle returns the corresponding sub-speed, which is consistent with the effect of MSPEED.
By default, VP_SPEED is designed to display multi-axis composite speed, and it has no negative value. Unless the value of bit0 of the SYSTEM_ZSET command is set to 0, it can be used to display the single-axis command speed, which can be positive or negative.
For example:
BASE(0,1)
ATYPE=1 ,1
DPOS=0 , 0 'coordinates are cleared to 0
UNITS=100,100 'pulse amount
SPEED =100,100 'main axis speed
ACCEL=1000,1000 'acceleration
DECEL=1000,1000 'deceleration
TRIGGER 'automatically trigger the oscilloscope
MOVE(100,100) 'each axis moves 100
Running result:
In interpolation motion, axis 0 is the main axis, and VP_SPEED(0) returns the composite speed of interpolation motion.
(6) AXISSTATUS - Axis Status
Check the various states of the axis, display the value in decimal, and judge the state by the corresponding bit in binary, please note multiple errors can occur at the same time.
However, the axis parameter window is displayed in octal, it can be converted into decimal system through PRINT command.
For example:
?AXISSTATUS(1) 'check the status of axis 1, printed result: 576, which means that the positive soft limit is exceeded when finding the origin, and the displayed value in the axis parameter window: 240h
(7) AXIS_STOPREASON - Axis Stop Reason
Latch axis history stop reasons, write 0 to clear, latch bit by bit automatically. Attention, the information of AXISSTATUS is latched.
3. Common Motion Control Commands
(1) VMOVE - Continuous Motion
Grammar: VMOVE (motion direction) [AXIS (axis No.)]
Movement direction: -1 negative, 1 positive
After VMOVE is executed, unless CANCEL or RAPIDSTOP is used to clear the motion buffers, otherwise it will keep running.
When the previous VMOVE movement does not stop, the following VMOVE command will automatically replace the previous VMOVE command and modify the direction, so there is no need to CANCEL the previous VMOVE command.
For example:
BASE(0) 'select axis 0
ATYPE=1 'axis type is pulse axis
DPOS=0 'clear the coordinates to 0
UNITS=100 'pulse amount
SPEED=100 'main axis speed
ACCEL=1000 'acceleration
DECEL=1000 'deceleration
TRIGGER 'automatically trigger the oscilloscope
VMOVE(1) AXIS(0) 'axis 0 moves forward at the SPEED speed, same effect as FORWARD command.
VMOVE(-1) AXIS(0) 'axis 0 moves inversely at the SPEED speed, same effect as REVERSE command.
DELAY(1000)
CANCEL(2) AIXS(0) 'cancel AXIS(0) current motion
WAIT IDLE(0) 'wait for axis 0 motion to stop
(2) FORWARD - Continuous Forward Motion
Grammar: FORWA RD [AXIS (axis No.) ]
Make the axis move forward at the speed of SPPED , and switch to REVERSE only after CANCEL.
(3) REVERSE - Continuous Reverse Motion
Grammar: REVERSE [AXIS (axis No.)]
Make the axis move inversely at the speed of SPPED, and switch to FORWARD only after CANCEL.
For example:
BASE(0) 'select axis 0
ATYPE=1 'pulse axis type
DPOS=0 'the coordinates are cleared to 0
UNITS=100 'pulse equivalent
SPEED =100 'main axis speed
ACCEL=1000 'acceleration
DECEL=1000 'deceleration
TRIGGER 'automatically trigger the oscilloscope
FS_LIMIT=200 'set positive soft limit to 200units
FORWARD AXIS(0) 'make axis 0 always move forward at the speed of SPPED
FS_LIMIT=200 'forward soft position limit 200
FORWARD AXIS(0) 'forward motion
RS_LIMIT=300 'reverse soft position limit -300
REVERSE AXIS(0) 'negative motion
(4) DATUM - Find the Origin For Single-axis
Grammar: DATUM (mode value)
Single-axis homing movement. When multiple axes return to zero, it needs to call this command multiple times. There are several modes that can be selected.
Adding 10 to the mode value means reverse search after encountering the limit, and will not stop when encountering the limit. For example, 13 = mode 3 + limit reverse search 10, which is used when the origin is in the middle.
Add 100 to the mode value (modes 100+n and 110+n correspond to n and 10+n respectively) , ATYPE=4 or 65, which means that MPOS can be automatically cleared after connecting to the encoder (only for 4 series), other modes MPOS can only be cleared manually.
For more modes description, please refer to Motion Controller Homing Configuration .
(5) CANCEL & RAPIDSTAOP - Axis Stop
Grammar: CANCEL (mode)/RAPIDSTOP (mode)
Both CANCEL and RAPIDSTOP have four modes. The difference between the two is that CANCEL is a single axis/axis group stop command, and RAPIDSTOP is to stop all axes.
The deceleration of mode 2 is the maximum value among FASTDEC fast deceleration and DECEL deceleration. After using the instruction, if you want to call the absolute position movement, you must first wait for the stop to complete with WAIT IDLE.
When the axis No. is added, then target axis will be stopped, for example, CANCEL A XIS (1) . If needs to stop the motor rapidly, it is recommended to use RAPIDSTOP(2) or CANCEL(2) .
In addition, CANCEL command can be used to stop main axis in interpolation axis or and axis in BASE axis list.
For example:
BASE(0)
DPOS=0
SRAMP=0
ATYPE=1
UNITS=100
SPEED=500
ACCEL=1000
DECEL=1000 'deceleration
FASTDEC=10000 'fast deceleration
TRIGGER
MOVE(1000) 'current movement
MOVE(-1000) 'buffer movement
'DELAY(1000) 'delay
CANCEL(0)
Take the CANCEL command as an example, the execution effects of the four modes are shown in the figure below.
CANCEL (0)
CANCEL (1)
CANCEL (2)
CANCEL (3)
(6) MOVE - Linear Interpolation
Grammar: MOVE(distance1 [,distance2 [,distance3 [,distance4...]]])
There are single-axis linear motion or multi-axis linear interpolation motion, in relative motion distance. For absolute linear interpolation, it uses the MOVEABS instruction.
Actually, interpolation is a real-time data densification process. According to the given information, digital calculation is carried out, and the feed amount of each coordinate axis participating in the movement is continuously calculated, then the corresponding execution parts are respectively driven to produce coordinated movement, so that the controlled mechanical parts move according to the desired route and speed.
During interpolation motion, only the master axis speed parameter is valid. The spindle is the first axis of BASE. And the motion refers to the parameters of this axis. Then the interpolation motion command enters the motion buffer of the main axis.
What's more, it supports different types of axis hybrid interpolation.
Interpolation movement distance:
Interpolation motion speed: SPEED is set to main axis speed V0, each sub-axis speed Vn=V0×Xn/X.
For example:
BASE(0,1)
ATYPE=1,1
UNITS=100,100
SPEED=100,100
ACCEL=1000,1000
DECEL=1000,1000
SRAMP=100,100
DPOS=0,0