Internet PLC Forum
General => Technical support => Topic started by: EDGAR on October 03, 2009, 02:12:11 PM
-
I understand that the plc F1616 can receive 5 simultaneously Modbus Server TCP connections,now how many client connections can be created?
-
Client connection is under the program control, and you can only open one client connection at a time to any server. In order to make another connection to a different server you will need to close the first connection.
-
That's what i thought. I have the plc polling data from 2 boilers and writing it to a cabinet as follows.
PollBoiler1() // in this function I start by opening the TCP connection polling the Modbus data and end by closing it with a delay of 5 seconds.
PollBoiler2() // in this function I start by opening the TCP connection polling the Modbus data and end by closing it with a delay of 5 seconds.
WriteToCabinet() // in this function I start by opening the TCP connection writing the Modbus data received from boiler 1 and 2 and then end by closing it with a delay of 5 seconds.
When I close the connection I need a delay of 5 seconds before I can reconnect it this true? what would you say is the min time?
ConnectTCP()-----------------------------
PRINT #4 "<MBTCPCONNECT "+ D$ +":502>" 'CONNECT TO MOORE PAC
CALL GetTCPStatusC4
IF STRCMP(A$,"<CONNECTED>")<> 0 ' did not received "CONNECTED" message
SETLCD 2,1,"Not Connected "
else
SETLCD 2,1,"Connected "
ENDIF
RETURN
-----------------------------------------------
CloseTCP ----------------------------------
Print #4 </CLOSE>
DELAY 5000
RETURN
-----------------------------------------------
Thank you
Ed
-
On Connection close, I replaced the 'delay 5000' for a 'for next' as follows.
FOR I = 0 TO 2000
REFRESH
NEXT
Is this ok, can i use the REFRESH this many times? or do you have an alternate method?
-
When you close a connection with one server you probably don't need to wait very long before you connect to another server. But if you want to reconnect back to the same server it is a good idea to wait a few seconds for the last connection to close properly before making another connection. You can do some trial and error to determine the best delay to insert.
It is not efficient use of CPU time to put a delay 5000 or with a big loop of refresh. There is no problem using REFRESH but it will not let you execute other ladder program or custom function anyway so it is not serving much purpose.
What you can do is to start a timer and when the timer times out you can trigger another action.
E.g. You can start a timer #1 with label T1 as follow:
CLRIO T1 ' make sure the bit is cleared.
TIMERPV[1] = 50 ' 50 x 0.1s = 5s.
so the contact of T1 will be used to start another connection. This way the PLC can continue to execute other ladder programs.