I have some Modbus addresses that I would like to apply within OPC tags, but I am not sure what they would be referenced as in the tags’ OPC Item Path. My three address and their corresponding function codes in parathesis are:
According to this link: Modbus Addressing , It seems like my addresses are respectively: input coil, output coil, and holding register.
Is this correct? The tag values seem fine, but I would like to be certain given that I have never delt with addresses that are 6 digits, and also the middle address only being 5 digits.
Yes, this is generally correct for one-based addressing. Your offsets would be off by one for zero-based addressing (as actually used in the binary protocol).
Note, you use HRI with your INT variable. HRI indicates a 32-bit integer that occupies two addresses. You might want just the HR prefix.
Also note that Ignition's driver defaults to unit zero, where some devices expect some non-zero unit number (slave address). Your addresses for unit #2 would be like [PLC]2.HRI1.
I used one-based addressing because this is what Ignition defaults to. Should I consider switching to zero-based? Looking at the doc for my PLC, I doesn’t specify which one to use.
I use HRI1 for address 400002 because there are 5 digits after the ‘4’. I thought therefore that there are 65,535 available registers, thus 32-bits. Interestingly, I made an additional tag with the OPC Item path being [PLC]HR2, and the value is reading the same as HRI1. Not sure if this is expected or what insights it provides.
You should use whichever makes the addresses actually line up. I've never seen it explicitly specified by device documentation, but it should be implicitly obvious after you've addressed a few tags correctly.
HRI1 mapping to 400002 is almost certainly a mistake. You are probably getting half of a 32-bit value or something. 400002 will either be HRI2 or HRI3 depending on 0- or 1-based addressing.
All (standard) Modbus registers are 16-bit. When you use one of the 32-bit or 64-bit address syntax you are combining 2 or 4 contiguous 16-bit registers to create that value.