AMarks95
Member
What's the best way to use lots of MSG instructions in the same program? Both multiple messages with the same device, and other devices. I've read the manual a bit and I think I have a decent understanding of the Connected/Cached Connections. Basically, if you have multiple messages with the same device you want to only have one active per scan, and use the Connected/Cached Connection option to keep the connection open between messages. You can also have up to 32 open connections with different devices (in general, with modern hardware. I think this is actually hardware dependent).
What I've seen in some programs is a super short timer (100ms) with the EN rung consisting of an XIC(MSG.EN) for each MSG instruction used. Then, a CTU every time the timer elapses, and each MSG instruction has an index, in addition to the XIC(MSG.EN). Like so:
https://imgur.com/a/i6LuNjL
My only issue with that approach is that the TON rung becomes super long and has to be maintained as messages are added/removed, as well as the CTU preset.
I tested another method the other day, and it seems to work. Instead of using a counter and an index, the next message, just references the previous message. As soon as one is done, it moves on to the next one, and then eventually restarts when it gets to the end of the list. Like so:
https://imgur.com/a/lgPKKTZ
This way, each message has it's own line that's identical, there's no timer so the MSGs execute as fast as possible, adding a message to the end is relatively simple and intuitive, removing a message is not too bad either.
Does anybody have thoughts on the pros/cons of each? Any other approaches people use?
What I've seen in some programs is a super short timer (100ms) with the EN rung consisting of an XIC(MSG.EN) for each MSG instruction used. Then, a CTU every time the timer elapses, and each MSG instruction has an index, in addition to the XIC(MSG.EN). Like so:
https://imgur.com/a/i6LuNjL
My only issue with that approach is that the TON rung becomes super long and has to be maintained as messages are added/removed, as well as the CTU preset.
I tested another method the other day, and it seems to work. Instead of using a counter and an index, the next message, just references the previous message. As soon as one is done, it moves on to the next one, and then eventually restarts when it gets to the end of the list. Like so:
https://imgur.com/a/lgPKKTZ
This way, each message has it's own line that's identical, there's no timer so the MSGs execute as fast as possible, adding a message to the end is relatively simple and intuitive, removing a message is not too bad either.
Does anybody have thoughts on the pros/cons of each? Any other approaches people use?