Author Topic: Modbus/TCP ?'s  (Read 8130 times)

Kasky

  • Newbie
  • *
  • Posts: 9
    • View Profile
Modbus/TCP ?'s
« on: April 12, 2013, 01:07:48 PM »
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

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Red Binary
Re: Modbus/TCP ?'s
« Reply #1 on: April 12, 2013, 02:26:03 PM »
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: [Select]
ReadAny(startAddress, numberOfAddresses) 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: [Select]
profile_points1 = plc_clx.ReadAny(addr, 50)

Kasky

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Modbus/TCP ?'s
« Reply #2 on: April 12, 2013, 03:54:11 PM »
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!
« Last Edit: April 15, 2013, 12:57:50 PM by Kasky »

Kasky

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Modbus/TCP ?'s
« Reply #3 on: April 16, 2013, 04:11:04 PM »
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.