Search FAQs

{"searchBar":{"inputPlaceholder":"Search by keyword or ask a question","searchBtn":"Search","error":"Please enter a keyword to search"}}

M340 specific system words, %SW138 to %SW141

Goals and Symptoms

To facilitate the migration from LL984 to M340, four new System Words have been added to offset the starting address of variables which are accessed by Modbus requests.
If this functionality is being tested in the simulator, it is important to note that it was not added to the simulator until Unity Pro version 13.1.

Facts and Changes

System WordModbus request impactedFirst accessed variable
when Starting Address = 0
Modbus Discrete Input Offset
FC02 Read Discrete Inputs%M[%SW138]
Modbus Coil Offset
FC01 Read Coils
FC05 Write Single Coil
FC15 Write Multiple Coils
Modbus Input Register Offset
FC04 Read Input Registers%MW[%SW140]
Modbus Holding Register Offset
FC03 Read Holding Registers
FC06 Write Single Register
FC16 Write Multiple Registers
FC22 Mask Write Register
FC23 Read/Write Multiple Registers

The base address is the number of %M or %MW which correspond to Modbus address 0000.
    • %SW140 contains 1000. When the Modbus server receives a Read Input Registers request (code 04) with starting address equal to 0000, it returns values from %MW1000.

      %SW138 contains 0001. When the Modbus server receives a Read Discrete Inputs request (code 02) with starting address equal to 0000, it returns values from %M1.

Warning : it is mandatory to set the value of those 4 words with Initial value mechanism, rather than writing in an application section. Otherwise, upon PLC Init command or setting %S0 to 1 or downloading application, the 4 system words are set to 0000 and the behavior of Modbus server is wrong.

Causes and Fixes

This information is included in the Unity Pro help on line documentation as of version 7.0

Did this answer your question?

Explore more
Explore more
Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.