MELSEC iQ-R Series Motion Module (RD78G) - Speed and torque control mode from the PLC side
MELSEC iQ-R Series Motion Module (RD78G) - Speed and torque control mode from the PLC side
MELSEC iQ-R Series Motion Module (RD78G) - Speed and torque control mode from the PLC side
It is the article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide.
In this part you will learn how to:
- controlling the speed of the axis using MC_MoveVelocity function block
- controlling the torque generated on the axis using MC_TorqueControl
- MC_Stop function block funcionalities
- controlling the position of the axis in incremental mode using MC_MoveRelative
- activate continous operation to torque control on the example of the capping application
This article requires an established and pre-configured project. For a description of how to do this, see the first and second article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - System start-up and Drives configuration and programming from the PLC side.
1. Speed control
To switch to speed control mode we will use MC_MoveVelocity function block. This FB is available from the PLCopen library in Operation-individual catalog.
To add MC_MoveVelocity FB drag it over worksheet and drop it.
After dropping FB you have to assign the corresponding variables to inputs and outputs of the FB. It is useful to create variables on which we will operate. The most effective way to do this is to use structures.
The method of creating the structure is shown in the other article from the MELSEC iQ-R Series Motion Module (RD78G) series - Drive configuration and programming from the PLC side.
Below the created structure with variables that operate the MC_MoveVelocity function block - stSpeedControl.
Description of the inputs of the MC_MoveVelocity function block
On the input side:
- Execute - When TRUE, it executes the FB (BOOL).
- ContinuousUpdate - During TRUE, it can continuously change the velocity, the acceleration and the deceleration (BOOL).
- Velocity - Sets the commanded velocity. When the velocity is negative, the axis moves to the negative direction. When 0.0 is set, the axis does not operate, however, Axis Status (AxisName.Md.AxisStatus) changes to "6: During continuous operation (ContinuousMotion)" (LREAL).
- Acceleration - Sets the acceleration (LREAL).
- Deceleration - Sets the deceleration (LREAL).
- Jerk - Sets the jerk (LREAL).
For the detailed description of Jerk functionality refer to last chapter of the second article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - Programming from the PLC side.
- Direction - Sets the direction selection. MC_DIRECTION definition can be used.
1: Positive Direction (mcPositiveDirection)
2: Negative Direction (mcNegativeDirection)
When selecting "2: Negative Direction (mcNegativeDirection)" and Velocity (Velocity) is negative, the movement direction of the motor will be positive.
When this setting is omitted, the error "Out of Direction Selection Range" (error code: 1A37H) occurs.
- BufferMode - Selects the buffer mode.
0: Aborting (mcAborting)
1: Buffered (mcBuffered)
For the detailed description of the BufferMode setting refer to technical documentation MELSEC iQ-R Motion Module User's Manual (Application) → 2 MOTION CONTROL → 7 DIRECT CONTROL → 7.1 Velocity Control → BufferMode.
- Options - Sets a function option with bit specification (DWORD, Hex):
- Axis - Axis information available from AxisRef structure (AxisRef).
On the output side:
- InVelocity - Indicates that the set velocity that is calculated by the motion system has reached the target velocity. When the target velocity has been changed due to change at Continuous update (ContinuousUpdate) TRUE, it becomes FALSE until the set velocity reaches changed target velocity (BOOL).
- Busy - Indicates that the FB is in execution (BOOL).
- Active - Indicates that the FB is controlling the axis (BOOL).
- CommandAborted - Indicates that execution has been aborted because of other FBs. Becomes TRUE when this FB is stopped by an error or this FB is started during an error occurence. Becomes FALSE when Execute command (Execute) is FALSE (BOOL).
- Error - When TRUE, it indicates that an error has occured in the FB (BOOL).
- ErrorID - The error code generated in the FB is returned (WORD).
Example of a FB with defined I/O
Before we execute the FB by setting i_bExecute it is required to set values of velocity, acceleration, deceleration and direction in the i_leVelocity, i_leAcceleration, i_leDeceleration, i_wDirection. When the defined velocity is reached by the axis o_bInVelocity will be set to high state.
MC_MoveVelocity (Speed Control) switches the driver control mode to the csv (cyclic synchronous velocity mode) and executes control. This function controls the set velocity based on the specified acceleration ,deceleration, and jerk. To finish this FB, start MC_Stop (Forced Stop) (chapter 3 of this article).
For the details description of MC_MoveVelocity FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
2. Torque control
To switch to torque control mode we will use MC_TorqueControl function block. This FB is also available from the PLCopen library in Operation-individual catalog.
Description of the inputs of the MC_TorqueControl function block
On the input side:
- Execute - When this variable is TRUE, executes MC_TorqueControl (Torque Control) (BOOL).
- ContinuousUpdate - This variable sets whether to enable or disable continuous change of Target torque (Torque), Torque positive direction ramp (TorquePositiveRamp), Torque negative ramp (TorqueNegativeRamp), Limit velocity (LimitVelocity), Acceleration (Acceleration), and Deceleration (Deceleration) (BOOL).
・FALSE: Disable
・TRUE: Enable
- TargetTorque - This variable sets the set torque. Sets the ratio as a percentage to the rated torque of the servo motor used. The number of significant digits after the decimal point differs depending on the ID assigned to the slave object map. Values less than the number of significant digits are truncated. To output the set torque in the positive direction (address increasing direction), set a positive value. To output the set torque in the negative direction (address decreasing direction), set a negative value.
- TorquePositiveRamp - This variable sets the positive direction target torque. The setting value used until the target torque is reached differs depending on the setting of Torque ramp function selection (Options: Bit 16, 17) (LREAL).
- TorqueNegativeRamp - This variable sets the negative direction target torque. The setting value used until the target torque is reached differs depending on the setting of Torque ramp function selection (Options: Bit 16, 17) (LREAL).
- LimitVelocity - This variable sets the velocity limit value for the cyclic torque mode. The maximum velocity cannot exceed velocity limit value of the motor (LREAL).
- Acceleration - This variable sets the acceleration used until the limit velocity is reached (LREAL).
- Deceleration - This variable sets the deceleration used until the limit velocity is reached (LREAL).
- Jerk - This variable sets the jerk used until the limit velocity is reached (LREAL).
For the detailed description of Jerk functionality refer to last chapter of the second article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - Programming from the PLC side.
- Direction - Set this variable to "0"; If value other than "0" is set, "Out of Direction Selection Range" (error code: 1A37H)" occurs.
- BufferMode - Selects the buffer mode.
0: Aborting (mcAborting)
1: Buffered (mcBuffered)
For the detailed description of the BufferMode setting refer to technical documentation MELSEC iQ-R Motion Module User's Manual (Application) → 2 MOTION CONTROL → 7 DIRECT CONTROL → 7.2 Torque Control → BufferMode.
- Options - This variable sets the function options for MC_TorqueControl by specifying the bit (DWORD, Hex):
- Axis - Axis information available from AxisRef structure (AxisRef).
On the output side:
- InTorque - This variable becomes TRUE when the target torque is reached. When the target torque has been changed due to change at ContinuousUpdate TRUE, this variable remains FALSE until reaching the post-change target torque (BOOL).
- Busy - This variable becomes TRUE when MC_TorqueControl is executed (BOOL).
- Active - This variable becomes TRUE while MC_TorqueControl is controlling the axis (BOOL).
- CommandAborted - This variable becomes TRUE when execution of MC_TorqueControl is aborted. This variable becomes FALSE when Execute command becomes FALSE.
- Error - This variable becomes TRUE when an error occurs (BOOL).
- ErrorID - When an error occurs, this variable returns the error code (WORD).
Example of a FB with defined I/O
Before we execute the FB by setting i_bExecute it is required to set values of torque, limit velocity, acceleration, deceleration and direction in the i_leTorque, i_leLimitVelocity, i_leAcceleration, i_leDeceleration, i_wDirection. When the defined torque is reached by the axis o_bInTorque will be set to high state.
MC_TorqueControl switches the driver control mode to cst (cyclic torque mode) and executes control. This function controls the set torque based on the specified Torque positive direction ramp (TorquePositiveRamp) and Torque negative direction ramp (TorqueNegativeRamp). To finish MC_TorqueControl, start MC_Stop (Forced Stop) (chapter 3 of this article).
For the details description of MC_TorqueControl FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
3. Forced stop using MC_Stop function block
To finish MC_MoveVelocity FB (speed control) and MC_TorqueControl (torque control) we will need MC_Stop FB which activates the forced stop function.
Description of the inputs of the MC_Stop function block
On the inputs side:
- Execute - When TRUE, it executes the FB (BOOL).
- Deceleration - Sets the deceleration (LREAL).
- Jerk - Set "0.0" (If value other than "0.0" is set, the error "Out of Jerk Range" (error code: 1A13H) will occur) (LREAL).
- Options - Set "0H". (If value other than "0H" is set, the error "Out of Options Range" (error code: 1A4EH) will occur) (DWORD, HEX).
- Axis - Axis information available from AxisRef structure (AxisRef).
On the output side:
- Done - Indicates that the velocity has reached 0 (BOOL).
- Busy - Indicates that the FB is in execution (BOOL).
- Active - Indicates that the FB is controlling the axis (BOOL).
- CommandAborted - Indicates that the execution has been aborted because of other FBs (BOOL).
- Error - When TRUE, it indicates that an error has occured in the FB (BOOL).
- ErrorID - The error code generated in the FB is returned (WORD).
Example of a FB with defined I/O
To execute the FB set i_bExecute in a high state. The axis connected to the Axis input will be forced stop with deceleration set in i_leDeceleration. Successful stop of the axis will be displayed in high state of o_Done. If error occurs o_bError will be set in a high state and it will be possible to chech the error code via o_uErrorID.
Timing chart for MC_Stop FB:
For the details description of MC_Stop FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
4. Position control using MC_MoveRelative
To switch to position control mode we will use MC_MoveRelative FB. This FB is available from the PLCopen library in Operation-individual catalog.
Description of the inputs of the MC_MoveRelative function block
On the input side:
- Execue - When this variale is TRUE, executes MC_MoveRelative (BOOL).
- ContinuousUpdate - This variable sets wheter to enable or disable continuous change of movement amount of Distance, Velocity, Acceleration and Deceleration (BOOL).
- Distance - This variable sets the relative position from the current position at start to the end point (LREAL).
- Velocity - This variable sets the velocity (LREAL).
- Acceleration - This variable sets the acceleration (LREAL).
- Deceleration - This variable sets the deceleration (LREAL).
- Jerk - This variable sets the jerk (LREAL).
For the detailed description of Jerk functionality refer to last chapter of the second article in the Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide series - Programming from the PLC side.
- BufferMode - This variable sets the buffer mode:
・0: Aborting (mcAborting)
・1: Buffered (mcBuffered)
・2: BlendingLow (mcBlendingLow)
・3: BlendingPrevious (mcBlendingPrevious)
・4: BlendingNext (mcBlendingNext)
・5: BlendingHigh (mcBlendingHigh)
- Options - sets the the function options (DWORD, HEX).
- Axis - Axis information available from AxisRef structure (AxisRef).
On the output side:
- Done -The variables becomes TRUE when the relative position is reached (BOOL).
- Busy - Indicates that the FB is in execution (BOOL).
- Active - Indicates that the FB is controlling the axis (BOOL).
- CommandAborted - Indicates that the execution has been aborted because of other FBs (BOOL).
- Error - When TRUE, it indicates that an error has occured in the FB (BOOL).
- ErrorID - The error code generated in the FB is returned (WORD).
Example of a FB with defined I/O
For the details description of MC_MoveVelocity FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks).
5. Continuous operation to torque control in capping application
In the capping application, you first quickly rotate the axis over several thread turns using incremental positioning (rotation of the axis by a predefined number of degrees corresponding to the path through several thread turns) and then switch to torque control mode to properly tighten the cap.
The continuous operation to torque control mode is a mode to switch to the continuous operation to torque operation smoothly without stopping from the cyclic position mode in positioning or the cyclic velocity mode in velocity command. This allows you to switch from positioning mode to torque control mode without the characteristic axis stop that is detrimental effects on the application.
The application is divided in 3 main parts:
1. Incremental positioning - to quickly screw first thread turns.
2. Torque control with continuous operation to torque control - to tighten the cap with defined torque.
3. Forced stop - to stop ContinuousMotion mode.
1. Incremental positioning
To start the application set M100 in a high state. It will start the positioning with values defined in Distance, Velocity, Acceleration and Deceleration input. In this example motion is started with velocity of 5000 deg/s over 720 deg distance (2 turns of the axis). After 720 deg rotation M200 will be set in a high state and the program will go to the next line (torque control).
2. Torque control with continuous operation to torque control
After the axis goes to the end of the thread the torque control starts. In this example we will defined the torque as 50% of the rated torque os the motor with velocity limit 100 deg/s (very slow motion - just to tighten the cap).
To start MC_TorqueControl with Continuous operation to torque control it is necessary to set Options bit 19 on "1" which in hex will be 80000.
3. Forced stop
After the cap is tightened application needs to be stopped. To do so we will use MC_Stop FB.
First, we checks if the cap is tightened - one way to do this is to check that the axis velocity is not close to zero (due to position oscillations do not check the 0 equal condition).
If the velocity of the axis is less than 0 and the specified torque has reached defined value (o_bInTorque) M300 will be set in high state. We will use this bit to start MC_Stop FB.
Axis will be stopped with deceleration of 10 deg/s2 . When the stop is done the MC_Stop FB and application execution bit will be reset.
The video showing how the application works is inserted below:
MELSEC iQ-R Series Motion Module (RD78G) - Reading and writing servo parameters from PLC side It is the article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide. In this part you will learn how to: - execute reading of ...
MELSEC iQ-R Series Motion Module (RD78G) - Drives configuration and programming from the PLC side It is the article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide. In this part you will learn how to: - connect the limit ...
MELSEC iQ-R Series Motion Module (RD78G) - Homing from the PLC side It is the article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide. In this part you will learn how to: - connect sensor to the DOG signal - set sensor ...
MELSEC iQ-R Series Motion Module (RD78G) - System start-up It is the first article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide. In this part you will learn how to: - create the PLC project, - add the Motion Module to ...
MELSEC iQ-R Series Motion Module (RD78G) - Single-axis positioning from PLC side It is the article from the series Melsec iQ-R Series Motion Module (RD78G) Quick Start Guide. In this part you will learn how to: - position an axis in incremental mode ...