Author Topic: read string in Unitronics ModbusTCP  (Read 2484 times)

John_R

  • Newbie
  • *
  • Posts: 20
    • View Profile
read string in Unitronics ModbusTCP
« on: March 19, 2020, 10:32:49 AM »
Hey All,

Thought someone else might benefit from what I've figured out so far...

I am working on a project using 3.99y, talking to a Unitronics PLC using MODBUSTCP

I am able to read MB's (bits) and MI's (integers), but have found that the addressing is different than other brands of PLC's.

In Unitronics the MB addressing starts at 0000h, so if I want to read MB143, then I have to convert the hex to decemal, the add the offset. 0000h = 0000 dec + 143, so in the PLCAddressValue I enter 1:0143 (the 1: being modbus call #01 read coils).

Outputs start at 4000h, so if I want to read O69, 4000h = 16384 + 69 = 16453, PLCAddressValue = 1:16453

MI's start at 0000h, so MI170 would have a PLCAddressValue of 3:0170 (the 3: being modbus call #03 Read Holding Registers)


But, now I have come to an issue that I have not yet figured out, hoping someone can help....

I want to read a string from the PLC, I have seen in a couple different posts where Archie has stated that starting in 3.99y, we have the ability to read a string using something like 40001@S10 in the PLCAddressValue of a BasicLabel (where the 10 is the number of bytes in the string).

When I try this using the above addressing scheme "3:0170@S5", I get a message saying "Input string was not in a correct format".

Anyone have any thoughts?

JohnR

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
« Last Edit: March 20, 2020, 08:45:56 PM by Godra »

John_R

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: read string in Unitronics ModbusTCP
« Reply #2 on: March 21, 2020, 08:12:34 AM »
Thanks Godra,

I'm a little closer, I figured out that the string function does not work with the Forced Call I was doing (3:0170).

And I figured out that the reason the modicon style call (40001) was not working for me, Unitronics uses "0" based addressing, which is why I could use 0170 to read MI170, but the modicon style is "1" based, and I had to add the offset into my address (40171) to read MI170.

So, I can use 40171@S5 to read a string that starts at MI170, But the string is jumbled in the BasicLabel as though the bytes of the string were not assembled in the correct order.

JohnR

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: read string in Unitronics ModbusTCP
« Reply #3 on: March 21, 2020, 03:24:27 PM »
You should check the second topic in my previous post.


John_R

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: read string in Unitronics ModbusTCP
« Reply #4 on: March 24, 2020, 07:36:16 AM »
And that sounds like a reasonable fix, but that did not help

The string should come back as;

TUNNEL4

But every combination of SwapWords and/or SwapBytes returns the same result;

UTNNLE

So I have my TUNNEL in a jumble and no 4

JohnR

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: read string in Unitronics ModbusTCP
« Reply #5 on: March 24, 2020, 03:54:47 PM »
Can you try a couple of things:

1) Change 40171@S5 to 40171@S6 to see if 4 will appear

2) Do a quick test with the ModbusMaster app and your original address 40171@S5, just to see if you will get an error or any string:

     https://www.advancedhmi.com/forum/index.php?topic=2567.0