Jump to content

RS485 modbus monitor/snooper


Sandy

Recommended Posts

Hi,

I'm trying to build a snooper that works on a modbus RTU network, to test a controller built by a third party.

In this situation the Unistream is neither a master or slave, so the built-in modbus RTU configuration isn't suitable.

I'm struggling to to get messages recieved consistently using the COM Rx ladder block. (it doesn't help that this ladder function isn't documented in the help file, specifically how it determines message boundaries in the absense of STX/ETX characters).

I'd like to know that each time the "Data Arrived Bit" goes high, the first "RxLength" bytes in the "Rx Buffer" are new bytes, but that doesn't appear to be the case.

With the attached code, I get an entry in the 'Raw' Data table for almost every scan. With condition before the COM Rx removed, it works better - but not a lot - there are lots of duplicate message fragments, but occasionally  I get an unbroken and unduplicated sequence of characters which can be reassembled into a valid message.

Any recommendations on how best to use the COM Rx function for this?

Comrx.JPG

Link to comment
Share on other sites

19 hours ago, Sandy said:

Hi,

I'm trying to build a snooper that works on a modbus RTU network, to test a controller built by a third party.

In this situation the Unistream is neither a master or slave, so the built-in modbus RTU configuration isn't suitable.

I'm struggling to to get messages recieved consistently using the COM Rx ladder block. (it doesn't help that this ladder function isn't documented in the help file, specifically how it determines message boundaries in the absense of STX/ETX characters).

I'd like to know that each time the "Data Arrived Bit" goes high, the first "RxLength" bytes in the "Rx Buffer" are new bytes, but that doesn't appear to be the case.

With the attached code, I get an entry in the 'Raw' Data table for almost every scan. With condition before the COM Rx removed, it works better - but not a lot - there are lots of duplicate message fragments, but occasionally  I get an unbroken and unduplicated sequence of characters which can be reassembled into a valid message.

Any recommendations on how best to use the COM Rx function for this?

Comrx.JPG

I recently setup two Unistream 5” pro to receive serial ASCII strings from two Ohaus scales, eventually got it working as desired. You are correct on the lack of help file content on the SERIAL Com RX function. I have kindly suggested content be added for that function. 

In rung two, the second object from left, top branch, tag “ComRx”; is that supoosed to be a coil or a contact? The (P) is a coil. This seems out of context. Try -|P|- positive transition contact. These two are close together on shortcut bar and ambigitouis sometimes. 

See if that helps and please advise. The way it stands now as a coil it would pass thru a true every scan that “logging” is true. Happy coding Sir. 

Hotwires

Link to comment
Share on other sites

Thanks for catching that, I should know better than that by now. I'm not sure how it worked before - I might have been doing enough processing to slow the scan time right down.

I ended up measuring the pauses, ie. by looking at when the number of bytes waiting stops changing. a 50ms timer worked nicely for this system.

Comrx2.thumb.JPG.9be792a677f1d1ee42a789c28b199414.JPG

Link to comment
Share on other sites

The only reason I caught it so fast it that I've done it myself a few times. Only other advice most of the forum guru's would give is to break up the three lines in rung 1 into individual nets. I'm sure it works fine as coded but in some cases line stacking in a single rung (net) can give unexpected results. Something to do with the compiler, not sure... I'm loosely re quoting others. Glad you got it working to your satisfaction.

  • Upvote 1
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...