Logic Machine Forum
Modbus RTU to TCP bridging - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Modbus RTU to TCP bridging (/showthread.php?tid=3377)



Modbus RTU to TCP bridging - christian.hegland@caverion.com - 20.05.2021

Hi,

It has probably been asked before, but I can't seem to find any proper thread or answer to this,
so I'll try again Smile

Is it possible to add several RTU devices to LM5 and then bridge them to modbus TCP as well?
Making the LM5 a modbus rtu to tcp gateway.

I Have several meters connected to my LM5 over rtu, and would like to expose these to another device on my network.
I already have a template for my meters on my other PLC, so would be great if i could expose my modbus devices 
with the same register addresses, so no work on the PLC template are necessary.


Br
Christian


RE: Modbus RTU to TCP bridging - Daniel - 20.05.2021

All you need is now modbus TCP slave.
https://openrb.com/lm-as-modbus-tcp-slave/


RE: Modbus RTU to TCP bridging - christian.hegland@caverion.com - 20.05.2021

Thanks Daniel! Smile

I have tried this script, but as far as I can see, this script needs to map all modbus registers through knx before exposing them to modbus TCP again.
Wouldn't that make the original modbus addressing shift, so that I need to create new profiles on my receiving PLC?

So the first mapping defined in the list of registers, eg GA 1/3/67, would be exposed on Modbus TCP as register 0 and so on.

-- list of register mapping, starting from 0
registers = { '1/3/67' }

-- list of register data types, element count must match registers table
regdt = { dt.float32 }

I was looking for a solution were i could poll the modbus RTU devices by their actual modbus ID, and same register for each ID.

For instance:

ID: Register: Desc:
151 3019 Voltage A-B for slave #151
152 3019 Voltage A-B for slave #152
153 3019 Voltage A-B for slave #153

Is that possible?


RE: Modbus RTU to TCP bridging - Daniel - 21.05.2021

This is quite complicated.


RE: Modbus RTU to TCP bridging - admin - 21.05.2021

The LM Modbus slave supports only one ID. Another possible solution is to run Modbus slave on your PLC and make LM write values to it periodically.


RE: Modbus RTU to TCP bridging - Erwin van der Zwart - 22.05.2021

Just use a EGX150 for this task, that is why we created it (:

Connect your RTU to the Link150 and read the devices from LM over IP and you can read them from any other location as well.. No configuration and scripts needed just set the IP and RTU settings and done.


RE: Modbus RTU to TCP bridging - christian.hegland@caverion.com - 25.05.2021

Thanks guys! I bought a EGX150, and waiting for it to arrive Smile

Still interessted in a solution to send control commands to my NSX devices over RTU (trv00210).
Have you seen my PM Erwin? Seems like the script isn't working for me.


RE: Modbus RTU to TCP bridging - Erwin van der Zwart - 25.05.2021

Did you unlock the locking pad on the IFM interface? 

• protected by password where a password is required in the command
• protected by configuration: ◦ with the IFM interface, the remote control commands are enabled when the locking pad on the IFM interface is in the open position.

In sample below the used password is 0000 (ASCII 00 = 00110000 00110000 => 12336 in Decimal) 

Code:
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(1)
if event.getvalue() == true then
  mb:writeregisters(7999, 904, 10, 4353,1,12336,12336,0,0,0,0,0,0,0,0,0,0,0,8019,8020,8021) -- Open command
else
  mb:writeregisters(7999, 905, 10, 4353,1,12336,12336,0,0,0,0,0,0,0,0,0,0,0,8019,8020,8021) -- Close command
end
mb:close()



RE: Modbus RTU to TCP bridging - christian.hegland@caverion.com - 25.05.2021

Hi Erwin,

Thanks for getting back to me! Big Grin

The IFM interface is in the unlocked position. I've just tried with your password 0000, as I don't think or know if there's been set any other user password on these devices.
Could that be changed og checked with some software tools?

(25.05.2021, 08:57)Erwin van der Zwart Wrote: Did you unlock the locking pad on the IFM interface? 

• protected by password where a password is required in the command
• protected by configuration: ◦ with the IFM interface, the remote control commands are enabled when the locking pad on the IFM interface is in the open position.

In sample below the used password is 0000 (ASCII 00 = 00110000 00110000 => 12336 in Decimal) 

Code:
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(1)
if event.getvalue() == true then
  mb:writeregisters(7999, 904, 10, 4353,1,12336,12336,0,0,0,0,0,0,0,0,0,0,0,8019,8020,8021) -- Open command
else
  mb:writeregisters(7999, 905, 10, 4353,1,12336,12336,0,0,0,0,0,0,0,0,0,0,0,8019,8020,8021) -- Close command
end
mb:close()

Hi Erwin,

Since I can't fiqure out how to send an attachment in PM, i'll just try here.


RE: Modbus RTU to TCP bridging - Erwin van der Zwart - 25.05.2021

Does your NSX has the motor control add-on option(s)? A default NSX is without this option..


RE: Modbus RTU to TCP bridging - christian.hegland@caverion.com - 25.05.2021

yes, they skould be equiped with those. It goes some wiring inside the NSX breakers, and in the circuit diagram there's a circuit-breaker called Supply for NSX motors.

I've added a few more modbus registers to my profile, and I now try to read out the status registers 8020 and 8021.

I get the following response:
8020 = 905 ( command for close )
8021 = 775 ( error kode 7?, which means: Negative acknowledgment, The slave cannot perform the programming request sent by the master. )


RE: Modbus RTU to TCP bridging - cekca - 27.05.2021

i made this application with automation server and for open/close i write only the first 5 register ( from 8000 to 8005 ).