Technical Forum

OpenModbusTCP

CPU 315PN Client to 3 modbus servers

Thread Starter: RodelV   Started: 6/8/2012 3:42 PM   Replies: 9

« Previous thread Next thread »
Page 1 of 1 (10 items)
  6/8/2012, 3:42 PM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear All:

I would like to seek your help in checking if there are any mistakes in the configuration I have attached herewith. I will be using CPU 315 PN/DP as a client to get info from 3 different modbus servers. I used the simulator to verify my configuration first before proceeding to the site to install the program.

I am a new user of the modbus TCP and i used the sample included in CD we purchased. Basically I just need to read data from the 3 modbus servers starting at holding register 40100 to 40124.

I hope you can help me verify and correct my program before I proceed to the site.

Thank you so much

RodelV

Attachment: 060812_1.zip  (17 Downloads)

Top
  6/11/2012, 5:31 PM
Joined 9/22/2010
Last visit: 5/17/2013
Posts: 145
Rating:
Rated: Outstanding [3.74 out of 5 / rated 19 time(s)]. (19) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hello RodelV,

when checking your project I noticed a few things about the register adresses that you are using, runtime parameters as well as initialisation parameters in the Wizard.
You wrote that you only need to read data from holding register 40100 to 40124. When looking at the address references in the Wizard, I noticed in all 3 DB MODBUS_PARAM that you parameterized 6 different data areas. This is not needed. You only need one data area in each MODBUS_PARAM DB: Data Type: Holding Register, Start address: 100, End address: 124, DB number: XX (different DB number in each MODBUS_PARAM DB, DB has to be at least 125 Words long). Only this one data area is needed when you want to read holding registers from 40100 to 40124.
(There might be an offset of e.g. 1 between the registers on the S7 and the servers. So when being at the site, you might have to change these parameters to e.g. Start address 101 and End address 125. Keep that in mind if you see an error message about wrong data areas or anything alike.)

In OB100, in OB1 and in FC1 - FC3 I noticed that you use START_ADDRESS 800, LENGTH 5 and WRITE_READ TRUE. If you send a telegram like that it would mean to write Holding registers from 40800 to 40804. So this should be changed to START_ADDRESS 100, LENGTH 125 and WRITE_READ FALSE.
In general if you only need to send that one telegram, you don't need to load the values to the runtime parameters in every cycle. If you make sure to load the correct values in for UNIT, START_ADDRESS, DATA_TYPE, LENGTH and WRITE_READ in OB100, that would be enough. These parameters are not changed by the MODBUSPN block, so they would keep their values.


In addtition to that I noticed that telegrams are sent after DONE_NDR or ERROR is set. In general this works fine, but what is missing is the first time the ENQ_ENR is set. In the current program, no telegram will be sent because there won't be DONE_NDR or ERROR. So you have to think about where to set ENQ_ENR for the first time.

I hope this is not too much and you understand what I want to say Rnf:lblSmileyTooltip_  think

Regards
Sakura
Top
  6/12/2012, 2:01 PM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Thanks for your reply Sakura, I will make the necessary changes. This is my first time configuring Modbus TCP so I just used the example program that came with the CD.

I will try it out and hopefully everything will all go well. 
Top
  6/12/2012, 2:39 PM
Joined 9/22/2010
Last visit: 5/17/2013
Posts: 145
Rating:
Rated: Outstanding [3.74 out of 5 / rated 19 time(s)]. (19) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
It was a good idea to use the example project :) You now only have to change a few settings, but in general the program and especially  the error handling should work.

Here are some tips when you are at site:
1. If you want to know if the Modbus requests are successfull, check "CONTROL_DAT".Count_Done and "CONTROL_DAT".Count_Error. If Count_Done increases everything is fine. If Count_Error increases, there is a problem. If nothing happens, no requests are being triggered. In that case there need to be a rising edge at "CONTROL_DAT".ENQ_ENR to trigger a request.
2. If there are errors ("CONTROL_DAT".Count_Error is increasing, "CONTROL_DAT".ERROR toggles), you should check "CONTROL_DAT".Save_STATUS_CONN, "CONTROL_DAT".Save_STATUS_MODBUS and "CONTROL_DAT".Save_STATUS_FUNC. If "CONTROL_DAT".Save_STATUS_Func shows the Modbus block, you will find the error code shown at "CONTROL_DAT".Save_STATUS_CONN or "CONTROL_DAT".Save_STATUS_MODBUS in the MODBUSPN manual. If another function is shown, you can check the online help of the function.

Good luck laugh
Top
  6/15/2012, 5:53 AM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear Sakura :

  Revised already and tested the program using ModRSsim and I was able to simulate all three machines without error.

  Hopefully, same thing will happen when I download it to site tomorrow.

Thanks for the support, you have been a very big help  Rnf:lblSmileyTooltip_
Top
  6/15/2012, 5:42 PM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear All

When I downloaded my program on site, I successfully communicated with the first machine, however with the two other machines I got the error 80A1 and modbus status "TRCV".

I tested my program with ModRSSim and successfully communicated to the plc on simulation by using 3 laptops as the modbus server. However, on actual machines only one machine is communicating correctly and I got the error I mentioned above.

Is it correct to assume that I can only call  Function code 3 alternately between the 3 machines one at a time before I trigger another request? Or is it okay to trigger the request to read the holding registers simultaneously?

Thanks and I hope someone can give me an idea on this problem.

Regards

RodelV
Top
  6/15/2012, 5:47 PM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
By the way this is the program that I used.I hope you can give me an idea on what is wrong with my configuration. 

I only need to read holding register 40100 to 40125 for 3 three different machines using 10.0.0.1 to 10.0.0.3 ip add for the three machines.

Thanks..

RodelV

Attachment: 061512_3.zip  (12 Downloads)

Top
  6/18/2012, 9:43 AM
Joined 9/22/2010
Last visit: 5/17/2013
Posts: 145
Rating:
Rated: Outstanding [3.74 out of 5 / rated 19 time(s)]. (19) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi,

I quickly checked your project and to me the program looked fine.
If you upload the online instance DBs of the two machines with the error, I might be able to help better.

When getting 80A1 from TRCV, it means that the connection was established before. I assume that after the S7 sent a requests to the server, the server closed the connection. But this can only be verified by tracing the network traffic. So recording the network traffic with Wireshark would be a could idea in this situation.
If you need help with the analysis of the Wireshark trace, you can upload the recorded pcap-file here.

Regards
Sakura
Top
  6/18/2012, 10:05 AM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear Sakura

Thanks for the reply, I will record the net traffic and post here. 
Top
  6/18/2012, 4:38 PM
Joined 5/4/2012
Last visit: 9/24/2012
Posts: 7
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear Sakura:

Finally made the program to work, I found out that all three compressors respond to the program after I changed all their station ID's to 1 but with three different ip addresses.

Thank you for the help, I couldn;'t have done this one without your help.Cheers Rnf:lblSmileyTooltip_
Top
Page 1 of 1 (10 items)
Actions