MELSEC iQ-R Series Motion Module (RD78G) - Single-axis positioning from PLC side

MELSEC iQ-R Series Motion Module (RD78G) - Single-axis positioning from PLC side

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
- position an axis in absolute mode
- create compounds motions with smooth transition between movements 

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. Incremental mode positioning using MC_MoveRelative function block 


Description of the inputs of the MC_MoveRelative function block





On the input side: 

Execute - 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)



Detalied explanation of the BufferMode funcionalities is given in chapter 3 of this article. 


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




The FB is started by setting i_bExecute. The axis will travel by the distance defined in i_leDistance with velocity, acceleration, deceleration and jerk defined in i_leVelocity, i_leAcceleration, i_leDeceleration, i_leJerk in the direction specified in i_wDirection. After target position is reached o_bDone will be set to high state. When positioning will not start or will be interupted an error occurs and o_bError will be in high state. The code of that error will be stored in o_wErrorID

For the details description of MC_MoveRealtive FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks). 

2. Absolute mode positioning using MC_MoveAbsolute function block


Description of the inputs of the MC_MoveAbsolute function block





On the input side: 

Execute - 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). 

Position - This variable sets the target position of the absolute position (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.

Direction - When software stroke limit is disabled, this variable sets the direction used to move from the current position to the target position.

・1: Positive direction (mcPositiveDirection) - performs positioning from the current position to the target position in the positive direction (address increasing).
・2: Negative direction (mcNegativeDirection) - performs positioning in the negative direction (address decreasing) from the current position to the target position.
・3: Shortest path (mcShortestWay) - based on the current position, positioning control is performed in the direction closest to the target position (the direction in which the absolute value of the movement amount is shortest). If the distance is the same in both the positive direction and the negative direction, control is performed using the current direction. 

When this setting is omitted, "Out of Direction Selection Range (error code: 1A37H)" occurs.

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)

Detalied explanation of the BufferMode funcionalities is given in chapter 3 of this article. 

Options - sets the the function options (DWORD, HEX). 



Axis - Axis information available from AxisRef structure (AxisRef).


On the output side: 

Done - This variable becomes TRUE when the target 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




The FB is started by setting i_bExecute. The axis will travel to the position defined in i_lePostion with velocity, acceleration, deceleration and jerk defined in i_leAcceleration, i_leDeceleration, i_leJerk in the direction specified in i_wDirection. After target position is reached o_bDone will be set to high state. When positioning will not start or will be interrupted an error occurs and o_bError will be in high state. The code of that error will be stored in o_wErrorID

For the details description of MC_MoveAbsolute FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks). 

3. BufferMode funcionalities - compound motions with smooth transitions between movements


BufferMode is used to permofrm multiple start operation on axis being controlled. The maximum of two motion FB can be buffered after multiple start in one axis. Below are shown and discribed all of available buffer mode types. 

To test the BufferMode types simple program with single-axis positioning was used: 



The testing procedure is as follows:

Firstly, MC_MoveRelative_2 is started and after a 1 second delay MC_MoveRealitve_3 is executed. Velocity and distance of the first movement is set as 100 deg/sand 360 deg. For the second movement velocity is 1000 deg/s and the distance is 720 deg. 

For each execution of this program the BufferMode type is changed to another one by setting proper value in the i_wBufferMode.

The waveform shown below is the chart of axis velocity (given in revolution per minutes) and position (given in pulses) over time in ms. The blue line marks the moment when the first FB reaches the target distance. The second FB starting moment is marked by AB cursor (one second time). Each rectangle of the grid represents one revolution of the motor. 

0: mcAbortiong (aborting) - aborts (cancels) the FB being executed and executes the next FB immediately. 




When the second FB is started the first movement was cancelled and axis traveled with new parameters immediately. Axis could not reach the distance specified by the first FB. 

1: mcBuffered (buffered) - Buffers the next FB on the FB being executed. If the FB being executed already has an FB buffering on it, subsequent FBs are buffered consecutively. Buffering FBs are executed in order after completion of the FB being executed.



Second FB was executed in the first period of first movement but due to buffering its motion stopped only after reaching target position. Because there was rapid axis speed change axis first decelarated and only then started the proper movement definied by the second FB (drop in the graph). 

2: mcBlendingLow (blending low) - Buffers the next FB on the FB being executed. If the FB being executed already has an FB buffering on it, subsequent FBs are buffered consecutively. Buffering FBs are executed in order after the FB being executed reaches the target position. The lower target velocity between the FB being executed and the buffering FB is used as the switching speed.



Using this buffer mode type smooth movement is generated. 

3: mcBlendingLow (blending previous) - Buffers the next FB on the FB being executed. If the FB being executed already has an FB buffering on it, subsequent FBs are buffered consecutively. Buffering FBs are executed in order after the FB being executed reaches the target position. The switching speed changes to the target velocity of the FB being executed.



Using this buffer mode type smooth movement is generated. Because the first executed FB has also a lower target speed this and previous waveform are identical. 

4: mcBlendingNext (blending next) - Buffers the next FB on the FB being executed. If the FB being executed already has an FB buffering on it, subsequent FBs are buffered consecutively. Buffering FBs are executed in order after the FB being executed reaches the target position. The switching speed changes to the target velocity of the buffering FB. 




5: mcBlendingHigh (blending high) Buffers the next FB on the FB being executed. If the FB being executed already has an FB buffering on it, subsequent FBs are buffered consecutively. Buffering FBs are executed in order after the FB being executed reaches the target position. The switching speed changes to the higher target velocity value between the FB being executed and the buffering FB.



Because the second executed FB has also a higher target speed this and previous waveform are identical. 

4. Example of two axis being buffered

This time also simple program was used: 



Firstly, the axis travels 360 deg with 100 deg/s velocity then after one second the next FB is started buffered with mcBlendingLow . This time axis travels 720 deg with 1000 deg/s velocity. The last FB is started one second after second FB with mcBlendingNext. Axis travels to the absolute position of 2160 deg with 1500 deg/s velocity. 



Each blue line represents reaching target distance/position by the each FB. The first switiching speed is a speed of first FB (becasue blending low is used). The second switiching speed is a speed of third FB (because blending next is used).