Modbus RTU Communication Details for Drives and generic Modbus Devices
This application note show communication details and FB execution order of modbus RTU communication between the IC92xx and a Yaskawa Drive or generic Modbus Device with I Cube Engineer >=V2023.6
1. Supported Components
| Component Name | Version |
|---|---|
| iC9200 series | ≥ 2023.6 |
| iCube Engineer | ≥ 2023.6 |
| GA700 | ≥1034 |
| GA500 | ≥1017 |
2. Libraries
-
Y_DataTypes_Toolbox
(
≥ 2023.6)
-
Y_PLCopenPart1_Toolbox
(
≥ 2023.6)
-
Y_IOModule_Toolbox
(≥ 2023.6)
3. Solution details
3.1 Bus cycle time, Task cycle time and SliceBus Settings
Bus cycle time:
-
The Drive's standard Baud rate setting 9600 should be increased to 115200 Bit/s if possible
(depending on cable length,number of slaves etc.). - To minimize the number of telegrams to the slaves
Y_MotionAxisDriver uses FC103 (Reading / Writing Non-Consecutive Registers).
POU Task cycle time:
Some words about Performance:
- The task cycle time setting for the POU containing Y_IM_MainRTUDriver and Y_MotionAxisDriver / Y_IM_GenericDeviceRTUDriver is essential for the communication performance. It means that if these FBs are called in a low task interval, then the communication will be low performance.
- The task cycle time setting for the POU containing the MC_Power etc. FBs is also important but it generates only delay in commands ('Execute') or feedbacks ('Done').
-
It is recommended to execute the FB's in the same task interval.
SliceBus Settings:
- SliceBus setting General - Synchronization Mode is not required - but can be used (e.g. for proper communication timing for EtherCAT devices). Cycle Time 1ms is recommended.
- The Modbus Input/Output Variables are defined as Local Port variables. Therefore it is not necessary to connect Update task - System and global variables to the Cyclic Task containing Y_IM_MainRTUDriver.
- Check that modifications of SliceBus settings - required for other SliceBus Modules - do not have a bad impact on the Modbus RTU communication to the Drives and Devices.
Recommended Settings (Typical):
- The optimum settings depend from the application, the number of inverter axes, reaction time on running the Drive (velocity modifications, start/stop) and the reaction on alarms or feedback velocity). The settings below show typical values,
- Bus cycle time 115200 Bit/s
- SliceBus cycle time 1ms
- POU task cycle time <= 4ms
- The FBs in Y_PLCopenPart1 toolbox provide a general solution for low and medium performance requirements running a Drive in Velocity Mode using Modbus RTU communication (legacy).
- For higher performance requirements use EtherCAT or Profinet bus communication or create your own optimized code using Modbus FCs directly with
Y_IM_ModbusMasterRTU
FB. The existing FBs in Y_PLCopenPart1 toolbox are not intended to be modified or customized.
- Proceed similar when special Timing / Performance or Motion features are required.
3.2 Y_IM_MainRTUDriver Communication to Drives and Generic Devices
As long as
Y_IM_MainRTUDriver.Enable = TRUE
Phases 1
and
2
are repeated continuously.
Phase 1:
Communicating to Drives
Y_IM_MainRTUDriver
FB checks in ascending order the
g_PM_VFD_AxisData.AxisArray:
-
Defined Axes in g_PM_VFD_AxisData.AxisArray:
g_PM_VFD_AxisData.AxisArray[?].AxisInfo.AxisType = Yt_AxisType#VFD .
-
The Axis
Y_MotionAxisDriver.Enable = TRUE and there is a telegram request from PLCopen Part1 FBs
Phase 2:
Communicating to Generic Devices
- Defined Devices in g_PM_VFD_AxisData.DeviceArray: g_PM_VFD_AxisData.DeviceArray[?].Number.
- The Device Y_IM_GenericDeviceRTUDriver.Execute has a rising edge and is sending a telegram.
3.3 Drive Parameter Settings
The following parameters must be set in the inverter before starting operation.- H5-01 - Drive Node Address
- H5-02 = 8 (for 115200 Bit/s) - Communication Speed Selection
During the initialization of the Y_MotionAxisDriver Functionblock, which occurs when Enable set to TRUE, the values of the following parameters are checked:
- H1-01 = 40 [2-Wire init] or F [3-Wire Init] to be sure that Reg 0001 bit 4 & 5 are linked to ComRef & ComCtrl
- H1-02 = 41 [2-Wire init] or F [3-Wire Init] to be sure that Reg 0001 bit 4 & 5 are linked to ComRef & ComCtrl
- E1-04 Maximum Frequency
- E1-09 Minimum Frequency
- D2-01 Frequency Reference Upper Limit
- C1-01 Acceleration Time
- C1-02 Deceleration Time
And the following parameters get transferred:
- H5-11 = 1 Comm ENTER Command Mode - (1:= ENTER Command Not Required)
- H5-06 = 0 Drive Transmit Wait Time (0 := 0 ms)
- O2-02 = 0 STOP Key Function Selection (0:= Disabled)
Note: The axis will be stopped during initialization.
3.4 Communication to Drives with Y_MotionAxisDriver
- Execution Order of FB Commands:
MC_Power (highest priority)Reading Status (lowest priority): One Telegram for
- An active Command with higher Execution Order will be sent before other active Commands with lower Execution Order.
-
Active command means the FB is Enabled / Executed and sends one Telegram to the Drive.
e.g. MC_Stop.Execute has rising edge: Send Forward Run = Reverse Run = FALSE and the Deceleration Ramp C1-02 to the Drive. - When no other Commands are active Reading Status will be executed continuously.
3.5 Examples for Modbus RTU communication to Drives and Devices
- 2 Drives: AxisArray [1] and AxisArray[4]
- 1 Generic Device: DeviceArray[3]
Example 1:
- Drives: No FBs executed -> Reading only Axis Status
- Generic Device: no Read or Write requests
Example 2:
- Drives: No FBs executed -> Reading only Axis Status
- Generic Device: One Request FC3 Address 100 Size 2 Words
Example 3:
- Drives: Run request MC_MoveVelocity.Execute = TRUE
then MC_Stop.Execute = TRUE
Drive is already enabled MC.Power.Status = TRUE - Generic Device: no Read or Write requests
Example 4:
- Drive (AxisArray[1]): Permanent Requests with higher priority prevent Reading Status
- Drive (AxisArray[4]): no FBs executed -> Reading only Axis Status
- Generic Device: no Read or Write requests
Every rising edge at the Execute FB Input will generate a Telegram to the Drive. The Drive Status is read only when no higher prioritized Telegrams are requested by the FBs.
The Drive Status monitors the Drive Status like Alarm State, Drive Ready, Output Frequency. This should be checked regularly - depending on your application requirements.
This will happen e.g. Alternating call of Y_ReadDriveParameter and Y_WriteDriveParameter -> There is always a new Telegram request with higher priority active than Read Status.
How to allow reading Drive Status:
Create a sequence that waits at least one POU task cycle after Y_ReadDriveParameter1.Done = TRUE and Y_WriteDriveParameter1.Done = TRUE.
See this example:
See this example:
When Y_WriteDriveParameter1.DONE = TRUE there is one POU cycle when Y_ReadDriveParameter1.Execute = FALSE and Y_WriteDriveParameter1.Execute = FALSE.
Telegram sequence: