Sandy Posted January 7, 2019 Report Share Posted January 7, 2019 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? Link to comment Share on other sites More sharing options...
hotwires Posted January 8, 2019 Report Share Posted January 8, 2019 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? 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 More sharing options...
Sandy Posted January 8, 2019 Author Report Share Posted January 8, 2019 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. Link to comment Share on other sites More sharing options...
hotwires Posted January 9, 2019 Report Share Posted January 9, 2019 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now