MELSEC iQ-R Series Motion Module (RD78G) - Reading and writing servo parameters from PLC side

MELSEC iQ-R Series Motion Module (RD78G) - Reading and writing servo parameters from PLC side

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 specific parameters from PLC
- execute writing of specific parameters from PLC
- force writing of parameters value to non-volatile memory

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. Reading servo parameters with the function block MC_ReadParameter

To read servo parameters from the PLC we can use MC_ReadParameter FB. This FB is available from the PLCopen library in Management catalog. 



To add MC_ReadParameter 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_ReadParameter function block - stParameterRead. 



Description of the inputs of the MC_ReadParameter function block



On the input side:
Execute - While is TRUE, the FB is executed (BOOL).
ParameterNumber - Indicates the objects of the slave devices (DWORD). 

Values of the parameters are sent to Motion module via network. We have access to them via device objects. 
List of all objects device for MR-J5-_G are listed in the technical documentation - MR-J5-G/MR-J5W-G User's Manual (Object Dictionary). 
The contents of Parameter No. (ParameterNumber) when setting the object of the slave device are shown below:



When setting the size of the objects of the slave devices, specify 1 byte (08H)/ 2 bytes (10H)/ 4 bytes (20H)/ 8 bytes (40H). If "00H" is specified the parameter read is performed with default size. 

The example of ReadParameter input setting for Pr. PT05 - Homing Speed: 



ParameterNumber := 24850000H 

- ReadCount Indicates the number of reading times of parameters. Carries out continuous read until Enable (Enable) becomes FALSE as 0 is set. Reload is executed at the timing which the Parameter No. is changed (WORD). 
Axis - Axis information available from AxisRef structure (AxisRef). 

On the output side:
Valid - This variable becomes TRUE when the output value is valid (BOOL).
- Busy - Indicates that the FB is in execution (BOOL). 
Error - When TRUE, it indicaes that and  error has occured in the FB (BOOL). 
ErrorID - The error code generated in the FB is returned (WORD). 
SDOErrorID - When an error occurs in SDO communication, this variable returns the response code (SDO Abort Code) (DWORD). 
Value This variable outputs the read value from the specified parameters. This value is stored as LREAL type even when the target parameters are integer data (LREAL). 
- SDOStatus - Stores the processing status of transient request (WORD). 



ReadCounter - Stores the number of reading times for the parameters (WORD). 

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

Example of a FB with defined I/O



Number of parameter we want to read is stored in D100 register. After setting i_bEnable MC_ReadParameter will start to read value of parameter we specified before. The parameter will be read as many times as specified in i_uReadCount (in this example i_uReadCount is "1"). Successful reading will be shown by high state of o_bValid. 

2. Writing servo parameters with the function block MC_WriteParameter

To write servo parameters from the PLC we can use MC_WriteParameter FB. This FB is also available from the PLCopen library in Management catalog. 
To add MC_WriteParameter 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_WriteParameter function block - stParameterWrite. 



Description of the inputs of the MC_ReadParameter function block



On the input side:
Execute - While is TRUE, the FB is executed (BOOL).
ParameterNumber - Indicates the objects of the slave devices (DWORD).
Values of the parameters are sent to Motion module via network. We have access to them via device objects. 
List of all objects device for MR-J5-_G are listed in the technical documentation - MR-J5-G/MR-J5W-G User's Manual (Object Dictionary). 
For the details description of using ParameterNumber input refer to 1 chapter of this article. 
Setting Value - Indicates a setting value of the specified parameter (LREAL). 
ExecutionMode - Indicates writing method of the specified parameter. As is set to "0: Execute immediately (mcImmediately)", writes immediately. As is set to "1: Execute at Completion of Previous One (mcQueued)", writes after the axis stops. 
 Axis - Axis information available from AxisRef structure (AxisRef). 

On the output side:
Done - Indicates that writing to the parameter is completed (BOOL).
Executing - Indicates that the FB is executing (BOOL). 
Error - When TRUE, it indicaes that and  error has occured in the FB (BOOL). 
ErrorID - The error code generated in the FB is returned (WORD).
 SDOErrorID - When an error occurs in SDO communication, this variable returns the response code (SDO Abort Code) (DWORD). 
- SDOStatus - Stores the processing status of transient request (WORD). 
For detailed description of the SDOStatus returned output value refer to to 1 chapter of this article. 
For the details description of MC_WriteParameter FB refer to MELSEC iQ-R Motion Module User's Manual (Motion Control Function Blocks). 

Example of a FB with defined I/O



Number of parameter we want to write is stored in D100 register. After setting i_bExecue MC_WriteParameter will start to write value stored in i_udParameterNumber to parameter we specified before. Successful writing will be shown by high state of o_bDone.  

3. Force writing to non-volatile memory

Values stored in the parameter changed by the MC_WriteParameter will be reset to its default values after reset of the servo system. To avoid this we have to force writing to non-volatile memory. In this case we will use MC_WriteParameter FB to write "H65766173" value to object Save all parameters 1010h: 01h which will saves all of the parameters. 



We can also read status of the saving using MC_ReadParameter. To do this the ParameterNumber input will be set as "H10100100". 
Reading can return two values: 

0: The parameters cannot be saved with the command. (The parameters are being saved.)
1: The parameters can be saved with the command. (No parameters are being saved.)

Writing can be held only when return value is "1".