Jump to content
AlexV

Trouble with Modbus TCP. The cycle do not perform correctly

Recommended Posts

Hello,

I'm having an issue with the modbus communication over TCP. I can start and connect with the device without problems but at the time I try to get more than 1 value, the program asks the first request, gets a response and jumps to another device without asking the other requests. In segment 5 at start, I've the start contact (MB26) and the realimentation from the last device (MB121). At the end of the same segment i have the activation of segment 6 and the desactivation of the segment 5.

The VisiLogic PLC I'm using is a V1210 model.

Please find some images attached showing the problem.

Thanks,

 

Alex

ModbusTCP.JPG

Share this post


Link to post
Share on other sites

Add a delay timer. You are trying to do the second read on the very next PLC cycle. Perhaps the MODBUS slave cannot respond to multiple requests that quickly. Try giving it a 100ms or so between reads.

Share this post


Link to post
Share on other sites
6 hours ago, Flex727 said:

Add a delay timer. You are trying to do the second read on the very next PLC cycle. Perhaps the MODBUS slave cannot respond to multiple requests that quickly. Try giving it a 100ms or so between reads.

I've tryied to add a 3 sec delay and after a 5 sec delay and I have the same problem. Tried with the SB3 and I have the same problem as the delays. I have tryed to add a counter to control the requests from the modbus but counter do not increment with SB3 pulse. The subroutine is loaded in the main routine. Something strange happens. Any idea?

Thank you,

Alex,

Share this post


Link to post
Share on other sites

EDIT  Ignore this one....Flex's next answer alerted me that I had missed the length of vector, even though I looked carefully!)  Please explain MI 2507  in rung 6.  Should this perhaps be 2506?

 

But do answer this one......How are you transitioning all your calls?

cheers, Aus

Share this post


Link to post
Share on other sites

It looks like you're trying to read two vectors each of length 2 in two separate reads. The two vectors are only 8 registers apart. Why not simplify by reading it as a single vector of length 12? Block out MI 2508 through MI 2515 as "Do Not Use" and move your current use of MI 2508 - MI 2509 to MI 2516 - MI 2517.

Share this post


Link to post
Share on other sites
On 3/2/2020 at 10:04 PM, Ausman said:

EDIT  Ignore this one....Flex's next answer alerted me that I had missed the length of vector, even though I looked carefully!)  Please explain MI 2507  in rung 6.  Should this perhaps be 2506?

 

But do answer this one......How are you transitioning all your calls?

cheers, Aus

Hello Aus,
The device I'm reading holds values in 2 registers. The value I want it's always placed on the second register so that's the reason I pick the MI 2507 instead MI 2506. I use a set/reset cycle for the serial comunication.
Cheers,
Alex

Share this post


Link to post
Share on other sites
On 3/2/2020 at 10:20 PM, Flex727 said:

It looks like you're trying to read two vectors each of length 2 in two separate reads. The two vectors are only 8 registers apart. Why not simplify by reading it as a single vector of length 12? Block out MI 2508 through MI 2515 as "Do Not Use" and move your current use of MI 2508 - MI 2509 to MI 2516 - MI 2517.

Hello,

I've done what you say and now reading a longer vector I can read the values without problems. Thank you!

Which is the max number I can put in a vector lengh?

Cheers,

Alex

Share this post


Link to post
Share on other sites
4 hours ago, AlexV said:

Which is the max number I can put in a vector lengh?

123 for MODBUS TCP (16-bit holding registers).

Share this post


Link to post
Share on other sites

OK on all of that AlexV.  You might want to also have a look at this entire thread, just for some other tips and ideas that you might find useful.

cheers, Aus

 

Share this post


Link to post
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...