MSG Instruction Size in Elements - Part 1
I just wanted to make my contribution to this topic as I've seen it asked in various forms before and felt it needed some expansion/clarification...
Leeroy said:
Quick question on the message command in a SLC 5/03. Is it possible to read/write to multiple addresses that aren't adjacent to one another?
Quick answer - no.
Because you can only set a start address and a length in a MSG instruction, it will only read/write consecutive addresses from the start address, and only addresses from within the same Data File.
Leeroy said:
For example lets say I want to write a few values to another PLC, let's say the addresses are F8:0, N7:0 and N7:10. Is this possible with one message command or would I need to do 3 separate commands to do this?
Again, as F8 is in a different Data File to N7:0 and N:10, you would have to use one write MSG for F8.
You refer to N7:0
and N7:10. They are in the same Data File, but not consecutive. I would say two separate MSG instructions would be required here, as I don't know what N7:1 to N7:9 are doing in the destination PLC, or the source for that matter.
So, "3 seperate commands" would be required to write these 3 addresses from one PLC to another.
Ken Roach said:
So to read F8:0, N7:0, and N7:10, you would need one MSG instruction to read the F8:x file, Length 1, and another MSG instruction to read the N7 file, length 11.
Ken,
I know you were just giving a quick example of how to
read the N7 Data File in one MSG. While that's clever to achieve it by using a length of 11, I'd just like to point out something that may require further consideration if doing so.
Leeroy's example question was to
write N7:0
and N7:10, not
read N7:0
to N7:10. Regardless of whether you are using a read or write MSG, the following would need consideration if setting a length of 11 elements in the MSG instruction. A length of 11 will read or write 11 consecutive elements(words) from the starting address N7:0. So obviously that's N7:0
to N7:10.
If we look at a write MSG required to go to N7:0
and N7:10 - depending on what the addresses are doing in the destination PLC, you may not want to write to N7:1 to N7:9. If those addresses were doing something different to the source PLC, you may overwrite important data while setting a length of 11.
Likewise with a read MSG - if you didn't want to overwrite N7:1 to N7:9 in the PLC you are reading into, you could not use a length of 11. You would have to use two separate MSG instructions for N7:0 and N7:10 to avoid this.
Consider even further...if the source and destination PLCs
are sharing consecutive addresses N7:0 to N7:10 - depending on the structure of your logic, it may, or may not be required to read or write to all of that range of addresses at the same time.
Example:
If logic condition A - write N7:0
and N7:1 only (1xMSG,L=2)
If logic condition B - write N7:0
and N7:10 only (2xMSG,L=1)
If logic condition C - write N7:0
and N7:2
and N7:4 only (3xMSG,L=1)
If logic condition D - write N7:0
to N7:10 inclusive (1xMSG,L=11)
Any manner of logic could be possible.
If logic condition B applies - you have to use two seperate MSG instructions with a length of 1 each.
If logic condition D applies - you may use one MSG instruction with a length of 11.
Again, this is just to clarify that using a certain length in a MSG instruction, to reach non-consecutive addresses within the same Data File, may not always be ok.
Ken Roach said:
What you're describing would be a 'data table scattered read". It's something that exists, just not in the SLC-500 family controllers.
Ken, in a funny sort of way, if the inclusive addresses do
not matter while using your short-cut method, you actually demonstrated a scattered read within the same Data File.
more to come...