M340 modbus mapping

daichi

Member
Join Date
Sep 2017
Location
Tokyo
Posts
9
Hello,

I am Japanese broken English sorry.
I am trying to create a modbus map for Modicon PLC M340. I am using UnityPro software ver11.

I am using MBP_MSTR with function code 2, and I am successful in modbus communication.
However, I selected mixed topological and state ram for extended %M register. the modbus communication with function code 2 failed.
The exception of Modbus communication is 0X02.
Just by expanding the area, the parameters of MBP_mstr have not changed.

Is there any setting missing?
 
are your sure you have the right address

exception code 2


02
(02 hex)

Illegal Data Address

The data address received in the query is not an allowable address for the slave. More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, a request with offset 96 and length 4 would succeed, a request with offset 96 and length 5 will generate exception 02.
 
Dear labeledas,

Thank you for your reply.

I am sure I have the correct address for Modbus communication.
Because before choosing "Mixed Topological and state ram" at M 340,
I succeeded in communicating with Function Code 2.

Details are shown below.

・ Modbus communication is connecting from Modicon Quntum(master) to M340(slave).
"Mixed Topological and state ram" Before selection: No Exception in Modbus communication
"Mixed Topological and state ram" After selection: Exception present in Modbus communication (0x02)

・ Quantum (MBP_MSTR) parameter
"Mixed Topological and state ram" Before selection: Function code 2, datasize 4 bit, address 10001
"Mixed Topological and state ram" After selection: same

I just changed the area of% MW (4x) from 30000 to 40000 by selecting "Mixed Topological and state ram" at M340.
The area of% M (0x) has not been changed.

I think that the setting is insufficient in M340, but what about it?
 
Dear V0N_hydro,

Thank you for your reply.

I am using modbus function code "2".
The data size is "4 bit", and the address specifies 10001 (%M10000 of M 340) for Qunatum.

In order to read the input status, i have function code 2.
 
because you have selected mixed topological and state ram, I believe the input status are now intermingled with the %M addresses.

what happens if you stop using function code 2, and use function code 1, datasize 4 bit, and address 00001 ?
 
Dear V0N_hydro,

As you said, "function code 1, datasize 4 bit, and address 00001" when I tried, Modbus communication succeeded.

I understood the symptom.
When "mixed topological and state ram" is selected, it is impossible to communicate with Modbus with Function code 2.

I am trying to make the M340 a simulator for third party equipment.
Actually, I need to communicate with third party equipment with function code 2, so I will investigate whether there is a way to communicate.

thank you.
 
If you only use topolocigal, Modbus don't show errors but I think that now modbus querys goes to %M addressing.
If you change %M values and have only topological adderssing selected, do you see changes of %M at M340 on modicon side with FC2?
 
Last edited:
Dear Lare,

Thank you for your reply.

When "only topological address" is selected, data can be acquired from%M of M340 with function code 2.

"mixed topological and state ram" is selected because I want to extend the range of %MW from 32767 to 41000.
When "B" is not selected, %MW did not become larger than 32767.
 
check system words %SW138-%SW140

It is maybe possible that you configure mixed for addressing and then with system word %SW138 tell to CPU that it answer for FC02 from %M side. But this is wild quess.

%SW138 and %SW140
Function
Modbus objects base
Initial State

Base addresses for %I (discrete input) and %IW (input register)
NOTE: The base addresses for %I and %IW are not used when State RAM is configured in the CPU (from Unity Pro V6.1 & CPU firmware V2.4). Configuring State RAM allows the Modbus server to access the %I area (for all input bit operations) and the %IW area (for all input word operations).

Examples:

  • %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.
%SW139 and %SW141
Function
Modbus objects base
Initial State

Base addresses for %M (coil address) and %MW (holding register)
The base address is the number of %M or %MW which corresponds to Modbus address 0000.
 
It would be much easier if you can use modbus fuctions 1, 3, 15,16

With mixed setting, function code 2, datasize 4 bit, address 10001 is asking status of second binary input from binary card (at default 1st card). Do you have any IO-cards configured at rack?
 
Last edited:
Dear All,

I understood the sympton.
・ When "Topological" is selected on the memory tab of M340, FC1 and FC2 acquire data from %M.
・ When "mixed topological and state ram" is selected on the memory tab of M340, FC1 acquires data from %M(0x) and FC2 from %I(1x).
・ %I can only be used with Discrete Input.

The M340 is used only for the Modbus simulator and IO module is not set in the rack.
FC1 can not be used because it is instructed to use FC 2, when "mixed topological and state" is selected,
I will consider whether I can use %SW138 or there is a way to set the value in %I (probably can not set).

Thank you.
 
you can for %I bits programmatically using the FORCE_BIT block / function as well. I use it extensively in testing PLC programs. The forced value is the one that is read over modbus.
 

Similar Topics

I have 9 field devices, three METSEPM5110 power meters and six ACE949-2 rs285 interface modules. I want to read this Modbus rtu data through rs485...
Replies
8
Views
303
I'm using M340 (Schneider Electric) as modbus master. It works fine but if there is a disconnection with the slave, it stops working even after...
Replies
2
Views
416
Hello all. I am trying to read out the values from a Carlo Gavazzi EM340 energy analyzer via Modbus communication. The S7-1200 PLC has the CB1241...
Replies
29
Views
3,767
Hello, this is a message for specialists in Schneider, I am trying to establish communication in modbus tcp between a schneider M340 (P3420302)...
Replies
2
Views
1,601
Hi, I hope everyone's week is going great. I have ADAM-6217 Analogue module which supports Modbus TCP and I am trying to get the AI values of the...
Replies
2
Views
1,620
Back
Top Bottom