Modbus TCP slave & mapping

Hello,

Could anyone help me to figure out how to configure Portenta Machine Control as modbus tcp slave using Arduino PLC IDE.
Ethernet Configuration window shows
image
But... what means:
"Modbus TCP Slave always enabled"? Does it mean that modbus server always running in background?
What is "Unit identifier: 255"?
Is there some Portenta modbus register mapping info?

I've tried to connect Portenta by QModMaster, connection is ok but every read/write operation causes error.

Many thanks in advance for any information regarding this issue!

1 Like

Hi,

I'm trying to find the same type of information for an Opta WiFi device and I'm using PLC IDE 1.0.3 (the first version to support Opta). There seems to be some default mapping already in place, at least in the Opta, and this is what I've found so far by some quick trial and error (using QModMaster):

  • Coils 5, 6, 7, 8 correspond to the Status LEDs 1, 2, 3, 4, respectively. You can read from and write to those coils (Modbus function codes 0x01, 0x05).

  • Discrete Input 9 corresponds to the User Button and you can read its status (Modbus function code 0x02).

  • I tried to read/write Holding Registers and read Input Registers to no avail (I tried different starting addresses 0, 1, 30000, 30001, 40000, 40001, etc.), but this doesn't surprise me since I didn't find any way to actually map variables to ModBus addresses.

Have you found anything else on how to configure a ModBus slave through the PLC IDE?

Nicolas

Hello,

Have anyone found out what is the modbus mapping for a slave device?

Guillermo

This post may be of some use to you: ArduinoModbus (RS485) with Portenta Machine Control - Basic guide. This is not for the PLC IDE but you might be able to glean some information from it or switch to the Arduino IDE and program a solution.

Hello, [gguereque4]: I have already found how to map variables to modbus address for a slave device: When I create a global variable (on your code) then you go to Resources --> Parameter (non-volatile) Then add a new variable then asign the Global variable and that all. I found that on OPTA the Holding start on an specific value (16384) but it works for me. The only thing that I couldn't do is to store the variable on an specific address, because when I power off and then power on the OPTA the value start in 0 again.

Thank you!

So are you saying that parameters are holding registers in Modbus? Does this apply for both RTU and TCP?

I think you can make a variable retentive if you check the retain checkbox, so the value does not initialize in 0?

Have you been able to handle booleans the way you commented?

Hello, gguereque

Yes, only if you are trying to use as slave device. For master device es using the configuration for RS485 or Ethernet and adding the Modbus device.

I haven't tried with RTU but let me check it. Actually if you use the Satus Variables (bottom of Parameters) you should watch MOdbus registers too, Input Register in that case.


I couldn't found the retain checkbox, can you tell me where to find it? For example I programmed many counters and when I restarted the PLC I lost the data.

Using booleans for Modbus registers or to retain?

Hello rcortez95,

So, on the global variables there is an attribute column. You can select RETAIN in that column and link the variable in the parameter (I guess??).

Do you know how to handle booleans as parameters (because i think they are holding registers, right)?

Hello gguereque4,

Ah, perfect, I already reviewed that attribute and I set on my project, thank you, yes and then link the variable to the parameter

And related to booleans, I haven't found how to work with them, yes if you use parameters or status you will work with holding and inputs registers.

Thank you! cortez95 for this confirmation about the Register Mapping. I made a simple script using pymodbusTCP and It works

If you need to connect to an OPC server via modbus this can also help you mapping the Tags

https://forum.arduino.cc/t/connecting-arduino-opta-to-scada-platform-like-ignition-using-modbus-tcp/1162394/2