Author Topic: What is the round trip time for Modbus Read ?  (Read 991 times)

vikrant

  • Newbie
  • *
  • Posts: 3
    • View Profile
What is the round trip time for Modbus Read ?
« on: July 03, 2014, 02:28:05 AM »
I have 10 tags, they are set with values acquired using following:
Code: [Select]
while(true)
{
    List<int> addresses = new List<int> {40001,40002,40003,40004,40005,40006,40007,40008,40009,40010};
    Dictionary<string, Tuple<DateTime, int> values = new Dictionary<string, Tuple<DateTime, int>();
    ModbusTcpCom mtc = new ModbusTcpCom();
    mtc.IPAddress = "127.0.0.1";
    mtc.TcpipPort = (ushort)502;
    foreach(var addr in addresses)
    {
        var value = mtc.Read(addr.ToString());
        values.add(addr.ToString(), new Tuple<DateTime, int>(DateTime.Now(), int.Parse(value));
    }
}

With the above code, each tag gets updated only after about 5 seconds, as if like each read is taking roughly 500ms.

So please let me know, what is the inherent round trip time for Read() and how to mimimize it ?

How to make it thread-safe, because what I found was, running the above loop iterations in their own threads, causes Read() to go in error?
« Last Edit: July 03, 2014, 02:35:16 AM by vikrant »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5266
    • View Profile
    • AdvancedHMI
Re: What is the round trip time for Modbus Read ?
« Reply #1 on: July 03, 2014, 01:14:07 PM »
Because there are so many factors that affect Ethernet response time, the only way to get some idea is to use WireShark to see the time between a request a response.