01. Preliminary Preparations
Software: Sysctrl Studio (PLC programming software)
Hardware: M-series controller (taking M511S as an example)
Servo (taking HN-Y7FB040A-S as an example)
02. Communication Connection
This tutorial uses the M controller HCM511S-32MT4-D and the servo HN-Y7FB040A-S, and the connection method is shown in the figure below.
03. Sysctrl Studio Project Configuration
Basic settings
Step 1: Add slave station
Double-click to open the software Sysctrl Studio and create a new project. Click on [Network Settings] >> [EtherCAT] >> [Add Slave] >> select the servo slave to add >> [Add]
Step 2: Add servo axes
Open [Motion Control] >> [Axis Settings] >> Right-click in a blank area and select [Add Servo Axis]
Step 3: Connecting Devices
Click on "Associate with device...", select the servo you want to associate, and click "OK".
Step 4: Mechanism Parameter Configuration
[1] Number of pulses per revolution of the motor
Determined by the motor encoder resolution
[2] Work mileage per revolution
For example, if the lead screw pitch is 10mm, then the mechanism lead is 10mm, and "unit" means mm. In motion commands, the unit for position parameters is mm, and the unit for velocity parameters is mm/s.
[3] Gearbox output speed, [4] Gearbox input speed
For example: if the speed ratio of the reducer is 10:1, then the output speed is set to 1 and the input speed is set to 10.
The parameter configuration completion interface is as follows:
MC_MoveVelocity (speed control command)
(1) Instruction Description
① Function Description
The control axis moves continuously at the specified target speed and direction.
② Pin Description
(2) Instruction Test
① Open the default POU and insert the MC_Power function block.
The software will automatically instantiate the function blocks.
Configure the input pins of the MC_Power function block
② Insert the MC_JOG function block
③ Insert the MC_MoveVelocity function block
④ Insert the MC_Halt function block
After setting up, download the project to the controller.
⑤ Perform MC_MoveVelocity function block testing.
For easier demonstration purposes, command speed and feedback speed have been added to the monitoring section.
>>How to modify instruction speed and instruction direction
a. Enable the axis and trigger the MC_MoveVelocity function block.
Result: The shaft rotates forward at a speed of 10.
b. If you need to modify the parameters of the MC_MoveVelocity function block, you need to re-trigger the function block.
(The following are sequential steps; the Execute pin of the function block needs to be retried each time the parameters change.)
·Velocity=20, Direction=mcCurrentDirection
Result: The shaft rotates forward at a speed of 20.
·Velocity=20, Direction=mcNegativeDirection
Result: The shaft rotates in the reverse direction at a speed of 20.
·Velocity=10, Direction= mcCurrentDirection
Result: The shaft rotates in the reverse direction at a speed of 10.
·Velocity=-10, Direction=mcPositiveDirection
Result: The shaft rotates in the reverse direction at a speed of 10.
·Velocity=-10, Direction= mcCurrentDirection
Result: The shaft rotates forward at a speed of 10.
• Trigger the MC_Halt instruction to pause the axis.
>>How to move when interrupting commands
First scenario:
Enable the axis and trigger the MC_JOG function block (Velocity=10, forward rotation).
Result: The shaft rotates forward at a speed of 10.
• Trigger the MC_MoveVelocity function block
(Velocity=20, Direction= mcCurrentDirection)
Result: The shaft rotates forward at a speed of 20.
The second scenario:
Enable the axis and trigger the MC_JOG function block (Velocity=10, reverse).
Result: The shaft rotates in the reverse direction at a speed of 10.
• Trigger the MC_MoveVelocity function block
(Velocity=20, Direction= mcCurrentDirection)
Result: The shaft rotates in the reverse direction at a speed of 20.
The third scenario:
Enable the axis
Result: The shaft remains stationary.
• Trigger the MC_MoveVelocity function block
(Velocity=20, Direction= mcCurrentDirection)
Result: The shaft rotates forward at a speed of 20.
【Explanation】The value of Direction is "Run in the current direction of rotation". If other commands control the axis to move in the positive direction, the speed command will continue to move in the positive direction after interrupting other commands; if other commands control the axis to move in the reverse direction, the speed command will continue to move in the reverse direction after interrupting other commands; if the axis is in a stopped state, the axis will move in the positive direction.
MC_MoveContinuousVelocity (Continuously Variable Velocity Control)
(1) Instruction Description
① Function Description
The control axis moves continuously at the specified target speed and direction.
②Instruction characteristics
Unlike MC_MoveVelocity, this instruction takes effect immediately after any changes to the input parameters Velocity, Acceleration, Deceleration, Jerk, and Direction when the execution condition Enable is TRUE.
③ Pin Description
(2) Instruction Test
① Add a network and insert the MC_MoveContinuousVelocity function block.
② Right-click and select "Automatically create input variables", then set initial values for some variables.
After setting up, download the project to the controller.
③ Perform MC_MoveContinuousVelocity function block testing (the following are sequential steps)
a. Enable and trigger the MC_MoveContinuousVelocity function block.
Result: The shaft rotates forward at a speed of 10.
b. The MC_MoveContinuousVelocity function block does not need to be triggered repeatedly.
·Velocity = -10, Direction=mcPositiveDirection
Result: The shaft rotates in the reverse direction at a speed of 10.
·Velocity = -10, Direction=mcCurrentDirection
Result: The shaft rotates forward at a speed of 10.
MC_SetOverride (Speed Ratio Adjustment Command)
(1) Instruction Description
① Function Description
Used to globally and proportionally change the target speed of an instruction. The changed target speed = the target speed of the currently executing instruction × the speed overshoot value.
② Speed overshoot value
a. The unit of VelFactor is %, "100" means "100%". The valid range of VelFactor is 0~500. If the value is outside the valid range, the execution of the instruction will result in an error.
b. During instruction execution, the value of VelFactor can be dynamically changed, and the change takes effect immediately.
c. When the instruction stops executing, the speed overshoot value is 100%.
d. This instruction continues to execute when Enable is TRUE.
③ Controlled instructions
MC_MoveVelocity (speed command)
MC_MoveRelative (Relative displacement command)
MC_MoveAbsolute (Absolute displacement command)
MC_MoveAdditive (Additional displacement command)
MC_MoveSuperimposed (Append displacement command)
④ Pin Description
(2) Instruction Test
① Add a network and insert the MC_SetOverride function block.
② Right-click and select "Automatically create input variables", then set initial values for some variables.
After setting up, download the project to the controller.
③ Perform MC_SetOverride function block testing (the following are consecutive steps)
a. Enable and trigger the MC_MoveVelocity function block.
(Velocity=10, Direction=mcPositiveDirection)
Result: The shaft rotates forward at a speed of 10.
b. Trigger the mc_setOverride function block, VelFactor=150
Result: The shaft rotates forward at a speed of 15 (10 × 150% = 15).
• Cancel triggering the mc_setOverride function block
Result: The shaft rotates forward at a speed of 10.
·VelFactor=50
Result: The shaft rotates in the forward direction at a speed of 5 (10 × 50% = 5).
·VelFactor =200
Result: The shaft rotates in the forward direction at a speed of 20 (10 × 200% = 20).