Author Topic: modbus tcp to modbus rtu converter  (Read 3778 times)

muratguenduez

  • Newbie
  • *
  • Posts: 22
    • View Profile
modbus tcp to modbus rtu converter
« on: May 15, 2019, 02:30:07 AM »
hi there,
im working on a converter modbusTCP toMOdbusRTU. i have couple of problems and a bit confusion. i can read my rtu plc connected to converter modbus rtu port via Modbuspool without any problems. modbuspool provide me to setup connection parameters "ip, port, unitID(for rtu), and reg address". however i cant find any unitID in the AHMI except modbusTCPcom Properties. yes it is exist but nothing changes by changing it. how to solve this problem? GODRA, ARCHI or another knowlegefuly forumer =) im using c#

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #1 on: May 15, 2019, 07:06:53 AM »
What about StationAddress on ModbusRTUCom ?

muratguenduez

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: modbus tcp to modbus rtu converter
« Reply #2 on: May 15, 2019, 10:05:31 AM »
i dont use modbusRTUcom, i use modbusTCPcom.  converter has a static ip for modbusTCP and has a rtu port connected rtu devices. i have one on the rtu bus its a plc id adsressed by 3. for example i found a tcp class

this for connection,
Code: [Select]
public Master(string ip, ushort port, bool no_sync_connection)
        {
            connect(ip, port, no_sync_connection);
        }
and this for write single coil,
Code: [Select]
public void WriteSingleCoils(ushort id, byte unit, ushort startAddress, bool OnOff)
        {
            byte[] data;
            data = CreateWriteHeader(id, unit, startAddress, 1, 1, fctWriteSingleCoil);
            if (OnOff == true) data[10] = 255;
            else data[10] = 0;
            WriteAsyncData(data, id);
        }

i downloaded from https://github.com/stephan1827/modbusTCP-DotNET

working well but i cant find like this control in ahmi.
« Last Edit: May 15, 2019, 10:14:22 AM by muratguenduez »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #3 on: May 15, 2019, 02:14:43 PM »
Do a Wireshark capture and check the frame. I'm quite sure the UnitID is embedded in the packet.

muratguenduez

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: modbus tcp to modbus rtu converter
« Reply #4 on: May 16, 2019, 02:08:14 AM »
of course it should be in the packet  =) problem is how to put it into the packet with AHMI ? this is modbuspool tx rx page.
000026-Tx:00 11 00 00 00 06 03 01 05 02 00 01
000027-Rx:00 11 00 00 00 04 03 01 01 02
its "read single coil"

and

this is a explanaiton the packet,

Summary

The equivalent request to this Modbus RTU example

                 11 03 006B 0003 7687

in Modbus TCP is:

  0001 0000 0006 11 03 006B 0003

0001: Transaction Identifier
0000: Protocol Identifier
0006: Message Length (6 bytes to follow)
11: The Unit Identifier  (17 = 11 hex)
03: The Function Code (read Analog Output Holding Registers)
006B: The Data Address of the first register requested. (40108-40001 = 107 =6B hex)
0003: The total number of registers requested. (read 3 registers 40108 to 40110)

http://www.simplymodbus.ca/TCP.htm

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #5 on: May 16, 2019, 03:31:28 AM »
And when you change the UnitID property does your packet you see in Wireshark change? What version of AdvancedHMI are you using?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #6 on: May 16, 2019, 03:43:34 AM »
I tried it with ModRSim2 and changed the UnitID property. It changes it in the packet just as I thought it would.

muratguenduez

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: modbus tcp to modbus rtu converter
« Reply #7 on: May 16, 2019, 08:35:45 AM »
its 3.99x. i think your time out is not working or limited ? when i change it every time get a connecton error in 3sec why?

request is same but reasult is different.

upper is modbuspool and bottom is AHMI. both are have same requests but output doesnt on with AHMI.
i setted time ut same 5000ms, there is a response timeout in modbuspool, AHMI has just timeout, is there any way to set it in AHMI?
« Last Edit: May 16, 2019, 08:40:04 AM by muratguenduez »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #8 on: May 16, 2019, 07:47:19 PM »
Does your device really take more than 3 seconds to respond?

muratguenduez

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: modbus tcp to modbus rtu converter
« Reply #9 on: May 17, 2019, 03:02:34 AM »
its gprs and you need more time  then cable connection. it about traffic, its very alternative. as your answer, yes 3 sec some times give me a timout error. actually as you see the packages are same anly differenses are probably times.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #10 on: May 17, 2019, 06:36:31 AM »
I don't have a device that delays that long to respond, so I can't fully test it. But I did put in an incorrect IP address which makes it only wait 3 seconds for connection irrelevant of the TimeOut value. This has been fixed and will be part of the beta release.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #11 on: May 18, 2019, 12:42:03 AM »
Would you mind the exact hardware you are using so that I can make sure I am giving you the right solution?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #12 on: May 18, 2019, 12:46:39 AM »
Also try 3.99y Beta because I know the timeout works correctly once it successfully connects.

DougLyons

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
modbus tcp to modbus rtu converter
« Reply #13 on: May 18, 2019, 10:53:25 AM »
Archie,
The ModRSsim2 program provides an option for delays which is shown as "Responsiveness" under the "Settings" popup. See the attached PNG for an example. It can be set for up to 10 seconds of delay. Thanks.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: modbus tcp to modbus rtu converter
« Reply #14 on: May 18, 2019, 11:36:44 AM »
Thanks Doug! I was not aware of that setting. I am going to set that up right now and test it.