Configuration of Ethenet Port 1 of APC810-AR A4.34 as Modbus server

Good Morning, I’ve configurated ethernet port 1 of my APC810 - AR A4.34 as modbus server, but when I connect (ETH 1 mapping) a variable UINT to a channel IR Input Register defined in the configuration, automatically this the PV is “forced” and I can’t write it in my code.
Same for Holding register: only a Modbus Master simulator can write a HR, not possible if I try to manage it in the code. Any idea? I don’t use external libraries but only native AS tools. Thank You in advance for any help - Massimo Q

NB: The AS version is 4.3

Hi Massimo, welcome to the Community!

I may be misunderstanding, but it sounds like you’re trying to write to a variable (via code) that you have mapped to an I/O input? This is not possible because the input will be overwritten with the physical input value every cycle. If I’m misunderstanding, let me know! Maybe if you explain a little more about your use case, we can help you find a different solution.

Hi Marcus, thank you for your reply.

I try to explain my situation:

ETH1 → Configuration (as modbus server)

  1. I define an Input Register Channel, address 4500, type UINT.

I can write this value by changing the mapped variable (but the PV used for
mapping must be defined as local to program, if it is defined in Global Variables
it results always forced and the code can’t affect it)

With Modbus Client simulator i can see the value at address 4500 that changes.

  1. I define an Holding Register Channel, address 4501, type UINT.

The mapped PV appears always “forced”, the code doesn’t affect it.
This, indipendently if I have the MOdbus Client simulator connected or not.

The simulator changes the PV mapped to this Holding Register channel without problems.

But there are cases like this: for example, you have possibility to change a temperature threshold
from HMI (Modbus Client), but sometimes, it is necessary to adjust it automatically (via code),
and this second way doesn’t change the PV vlue.

Also in Watch Monitor enviroment, if I want to change a PV mapped on a Holding Register,
the only possibility is to force its value.

Thank You in advance,

Massimo Quaglianello

Hi Massimo,

Sorry for taking so long to reply on this. I must have missed the notification and didn’t see your reply until now. Do you still need help with this topic?

I’m still a little confused what’s happening here, but it sounds like you’re attempting to change a variable in code, and that variable is also mapped to an input register via Modbus. In my example below, the code will not be able to modify TestVar or TestVar2 because their values will be overwritten when the I/O is updated:

image

If you want to use a different value, then I would recommend creating a separate variable that you are able to write to. This variable could then take on the I/O input value, or something else.

Hi Marcus

Thank you for your reply.

To update our discussion: i gave up the option to use native Modbus Server Configuration for a series of problems

(this option is available with AS Runtime from A4.34 or more recent versions, now I work with V4.02 version).

I just change my question: I need to exchange 292 words – START ADDRESS 4500 on Ethernet port 2 (“IF..”) of our APC810 configurated as Modbus Server.

I try with a library (see file attached MBTCP_V0.0.1.0), it works on a simple test, but I don’t understand how to address Eth port number 2,

how to set the start address to 4500 and how to manage the number of words object of Modbus exchange.

There is another library that would let us indicate the Eth Port 2 (for example: “IF5”) but I can’t get it to work (see ModbusTCP library AS4).

Any help from your side would be very appreciated (for example, a very simple project about configuration of eth port2 and exchange of registers as indicated),

Thank You very much

Massimo Quaglianello

(attachments)

MBTCP_V0.01.0.zip (198 KB)
Description modbusTCP library AS4.x.pdf (629 KB)
modbusTCP-Automation-Studio-2.1.zip (987 KB)

Hi Massimo,

Happy to help where I can!

I’m not very familiar with this library, but just from glancing at the source code you provided, it uses the AsTCP library for opening ports and communicating. The first step in using this library is to call the TcpOpen function block. This function block lets you specify the interface that should be used for communication via an input (pIfAddr). If this value is left at zero, then the listener will listen at all available interfaces. I don’t see this input used anywhere in that library, so I think you have two options:

  1. Any available interface can be used without modification, or
  2. You can modify the source code to specify a particular interface and then pass that value to TcpOpen

Just a quick note, I don’t think it’s a good idea to downgrade yourself so far software version wise if you don’t have to, especially if this is a new project. It becomes harder to support software the older it gets. It’s good that you have documentation and the source code for this library, but it’s possible you will run into compatibility issues in the future.

1 Like