Jump to content

Recommended Posts

Hi, everybody,

We are having application where V120 connected through RS485 (port 1) to powermeter using Modbus RTU. We made in our program that PLC gets

data from power meter (4 registers) 2 times in a day. I wanted to ask if someone could advice or maybe has a simple example how to do data request of these 4 registers. We done in that way:

Data request

MB1 MB2

------[P]----------(S)

MB2 MB0(function in progress) MB2

-----[ ]-----------[ / ]--------------------------------[Read holding register 1]----------( R )

MB2 MB3

------[N]----------(S)

MB3 MB0(function in progress) MB3

-----[ ]-----------[ / ]--------------------------------[Read holding register 2]----------( R )

MB3 MB4

------[N]----------(S)

MB4 MB0(function in progress) MB4

-----[ ]-----------[ / ]--------------------------------[Read holding register 3]----------( R )

MB4 MB5 MB1

------[N]----------(S)----------( R )

MB5 MB0(function in progress) MB5

-----[ ]-----------[ / ]--------------------------------[Read holding register 4]----------( R )

At the beginning it works fine, but there are issues: data does'nt change couple days, then changes or we get answers not from all registers..

I mean we not always get data. Maybe we are doing something wrong. Thank you for your help!

Link to comment
Share on other sites

Hi, Ofir,

Thanks for quick reply!

No, they're not consecutive. Their addresses are: Register1 - 3120, Register2 - 3122, Register3 - 3124, Register4 - 3126.

And about delay: is there any sense to do delay? I think the bit conditions allow to read next register, only when previous been read? Or I understand not good?

Link to comment
Share on other sites

Hi Vidmas,

According to our expirience the slave sometimes needs short silence between the commands and this is the reason why we recommend to set a small delay between the commands.

I think first it is better to test it with the delay in order to know whether indeed this is the issue.

Link to comment
Share on other sites

Hi, Ofir,

Thanks for quick reply!

No, they're not consecutive. Their addresses are: Register1 - 3120, Register2 - 3122, Register3 - 3124, Register4 - 3126.

And about delay: is there any sense to do delay? I think the bit conditions allow to read next register, only when previous been read? Or I understand not good?

Is there any reason why you can't pull down 7 registers (3120 - 3126) and just ignore the values of the 3 you don't need?

Link to comment
Share on other sites

  • MVP 2023

I would bet they are double integers given the addressing scheme.

If he's reading them as double integers then his length needs to be 8. I'd read the table in one block from the power meter and then examine the data received to determine the actual structure. The Modbus documentation with such a device often leaves out little tidbits such as true register mapping and which words represent the HI and LO values.

Joe T.

Link to comment
Share on other sites

Hello,

Thank you for the answers! The idea to read 7 registers and etc is good, but the question was not how to make a shortcuts or workarounds, but about the principle: is my ladder code bad and what may be the reason of such behavior.. I did't get a chance to test code with dealys so far, but maybe until next week I do. Thank you!

Link to comment
Share on other sites

Hello,

Thank you for the answers! The idea to read 7 registers and etc is good, but the question was not how to make a shortcuts or workarounds, but about the principle: is my ladder code bad and what may be the reason of such behavior.. I did't get a chance to test code with dealys so far, but maybe until next week I do. Thank you!

The honest answer to that question is that your code isn't very robust. There is no error handling. There is nothing to check how successful the communications are.

If you search the topic "Modbus Wha?" in the forum you will find a discussion on modbus communication and how various users have chosen to handle it. Some guys even poseted snippets of their code. If you want your code to be robust then this thread should give you ideas on how to make it so.

Delays can sometimes help, but I have rarely seen times where it is necessary. All of the modbus I have done to date with Unitronics has not required any artificial delays inserted.

In your case as well, it would be helpful to buffer your incoming data. Set the buffer to all zeros before your read request. This way, after your read request the buffer remains zero you know that you didn't receive new data.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...