CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Mar 22, 2019 5:30 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Wed Dec 12, 2018 10:51 am 
Offline

Joined: Wed Aug 05, 2015 1:26 pm
Posts: 7
I'm doing some tests and I have setup Codesys Win PLC as Modbus TCP Client to read/write holding registers from a M241 PLC which acts as Modbus TCP Slave.
I'm able to read data from the PLC using touch screen HMI and qModMaster but just I can't get it to work using Codesys Windows Soft PLC.

The IP's and everything is setup correctly. When I run the program I get "Running" status on Modbus TCP slave so I guess it means that the communiction is established.

Then since I need to read %MW10 from M241 I create a Modbus channel like in the picture.

Unfortunately it doesn't work and I don't know what I'm doing wrong.


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Wed Dec 12, 2018 11:42 am 
Offline
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 118
%MW is internal memory. This is not exposed by default to modbus TCP.

On your TCP server instance (slave), you had to define buffers for 1x,2x,3x and 4x function code areas. Just fill them correctly to expose your data.

using IL_ModbusTCPServerType02 FB from RIL_ModbusTCP with codesys 2.3/3.5, I had these parameters :
arbyBitData
arbyDiscreteInputs
RegisterData
InputRegisters


Top
   
PostPosted: Wed Dec 12, 2018 11:59 am 
Offline

Joined: Wed Aug 05, 2015 1:26 pm
Posts: 7
The thing is that Modbus TCP and RTU Servers are enabled by default on M241 so I'm sure that there is no problem with the Modbus Server.
I have absolutely no problem accessing Modbus registers using other clients like HMIs or Windows Modbus TCP clients.
There only problem is that I can't access them using the Modbus Client of Codesys runtime on Windows or actual hardware.


Top
   
PostPosted: Wed Dec 12, 2018 12:56 pm 
Offline
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 118
kallileo wrote:
The thing is that Modbus TCP and RTU Servers are enabled by default on M241 so I'm sure that there is no problem with the Modbus Server.
I have absolutely no problem accessing Modbus registers using other clients like HMIs or Windows Modbus TCP clients.
There only problem is that I can't access them using the Modbus Client of Codesys runtime on Windows or actual hardware.


So I bet you have double checked your access type (3x,4x), and addressing (Modbus base address is 0, but often you may see a +1 offset because of Jbus addressing).

Can you issue a ping from your win PLC to your M241 ?


Top
   
PostPosted: Wed Dec 12, 2018 2:20 pm 
Offline

Joined: Wed Aug 05, 2015 1:26 pm
Posts: 7
I can ping the M241 PLC (slave).

The communication seems to be ok.
Also as it shown in the screenshot qModMaster is reading the data in the holding register %MW10 without any problem but Codesys Win control reads nothing.


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Wed Dec 12, 2018 3:28 pm 
Offline
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 118
By issuing a ping, I mean, from your runtime. Cause this would validate the lP stack settings.

Does M241 supports multiple connections from different hosts on port 502 ?
Could you post your ModbusTCPSlave parameters ?


Top
   
PostPosted: Wed Dec 12, 2018 5:39 pm 
Offline
Frequent User
Frequent User

Joined: Thu Mar 17, 2016 1:24 pm
Posts: 139
You need set Always update variables: Activate 2 (always in bus cycle task).
On your screenshot this setting hide under window QModMaster.


Top
   
PostPosted: Wed Dec 12, 2018 7:29 pm 
Offline

Joined: Wed Aug 05, 2015 1:26 pm
Posts: 7
OK. I replaced the M241 PLC with pyModSlave which is now running on my laptop and is used as Modbus Server my clients connect to.
Again I have no problem reading Modbus registers from QModMaster installed on the same PC as the Codesys Win control PLC.

I have set the option "Always update variables:" to "Activate 2 (always in bus cycle task)" but it still doesn't work in Codesys.
It's really driving me crazy. :shock:


Top
   
PostPosted: Thu Dec 13, 2018 9:49 am 
Offline
Frequent User
Frequent User

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 118
please make sure that QmodSlave doesn't uses port 502 with netstat -a -b command.


Top
   
PostPosted: Thu Dec 13, 2018 11:03 am 
Offline

Joined: Wed Aug 05, 2015 1:26 pm
Posts: 7
Hi,

"Always update variables:" to "Activate 2 (always in bus cycle task)"

IT WORKED.
It seems that if you don't assign Codesys variables to Modbus channels you need to have this option set to "Activate 2 (always in bus cycle task)" or else you see nothing in Codesys.

Thank you for your help guys.

It's also mentioned in the link below.
https://faq.codesys.com/pages/viewpage. ... Id=3538995


Top
   
PostPosted: Thu Jan 24, 2019 7:34 am 
Offline

Joined: Tue Jun 26, 2018 1:31 pm
Posts: 17
Hello experts ,

in codesys v3 my target is control win

i want a bit for my modbus TCP cpmunication failure .

is there any bit for this purpose ?

and yes i am trying with Modbus_TCP_Slave.xerror .


Top
   
PostPosted: Thu Jan 24, 2019 6:18 pm 
Offline
User avatar

Joined: Tue Aug 30, 2011 1:21 am
Posts: 96
kallileo wrote:
The thing is that Modbus TCP and RTU Servers are enabled by default on M241 so I'm sure that there is no problem with the Modbus Server.
I have absolutely no problem accessing Modbus registers using other clients like HMIs or Windows Modbus TCP clients.
There only problem is that I can't access them using the Modbus Client of Codesys runtime on Windows or actual hardware.


@Kallileo not sure if you got the M241 modbus working but it could have been the Node ID you where using. With M241 it response differently depending on Node ID. See pic below

Attachment:
M2x1 MODBUS TCP SLAVE.png


You do not have the required permissions to view the files attached to this post.

_________________
The Original SoMachine Ninja


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 12 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited