General Category > Support Questions

Modbus/TCP ?'s

(1/1)

Kasky:
First question, is there a way to poll a memory location without the use of one of the controls?
For example I would like to poll a memory location and just place the result in a variable.

Second question, is there away to poll a memory location for a double word value?
Or is polling two single locations and combining values for double word result the only way to make this work?

Thank you

RedBinary:
I've not used the modbus driver so I couldn't help with the double, but you can retrieve a memory location programmatically using
--- Code: ---ReadAny(startAddress, numberOfAddresses)
--- End code ---
through the driver instance.

As an example in my own usage I'm getting 50 addresses starting at addr from an instance of EthernetIPforCLXComm driver named plc_clx

--- Code: ---profile_points1 = plc_clx.ReadAny(addr, 50)
--- End code ---

Kasky:
thank you, I'll give it ab shot.

I found it to work just fine.

However it took me a moment or two to realize that if I only wanted to read a single register I needed to drop the second
parameter altogether rather than reading a an array value of one.

For example:
ModbusTcpCom1.ReadAny(addr, 20) 'reads 20 consecutive registers
ModbusTcpCom1.ReadAny(addr) 'reads a single register
Notice I omitted the second parameter rather than using a value of 1 to read a single register.

Thank you for your help!

Kasky:
Another note about modbus addressing I just learned using AdvancedHMI - Modbus/TCP and a Koyo PLC.

One thing I had been missing is the types of data you are polling and "prefixes" that are associated with the types:

    0xxxx - Coils.
    1xxxx - Discrete inputs.
    3xxxx - Input registers.
    4xxxx - Holding registers.

Note that there is no 2xxxx address prefix.

The above was taken from this article.

So when addressing C1 I found the address to be 3074, but because it is a "Coil" I had to include the prefix "0" to make the correct address 03074.

Navigation

[0] Message Index

Go to full version