Studio 5000 MSG instruction change path during runtime?

theColonel26

Lifetime Supporting Member
Join Date
Feb 2014
Location
West Michigan
Posts
785
In Studio 5000 is there any way to change the path for a MESSAGE datatype during runtime?


I want to be able to set the same Path(IP address) for a 4 MSG instructions. They access different tags but will always access the same PLC.
 
No MSG instructions

As of right now they all will be triggered with a timer. ( I just haven't gotten that far yet)

2020-10-22 16-05-51 CL-CTRLS-VM-ROC.png
 
Last edited:
You can change them during the "Runtime" of the PLC, but not the "Runtime" of the instruction. In other words, if you have it set on a timer, you can change between the time the instruction has finished/failed execution and the next start. If you have it set on the".DN" bit, I don't believe you will be able to modify the path without modifying your code.
 
You can do it, and I have done it, but I had Very Good Reasons, like 110 identical devices that all needed the same MSG in order. It's not well-supported or recommended, and there's a high risk of creating a hard-to-troubleshoot program.

I want to be able to set the same Path(IP address) for a 4 MSG instructions. They access different tags but will always access the same PLC.

That sounds contradictory. If the MSG instructions access the same PLC, why does the IP address need to change ?

It's fairly easy to change an IP address inside the CIP Path as long as the addresses all have the same number of digits. You need to carefully alter and pad if they are different.
 
Thanks 🍺


Another question. Can a 5380 do CIP Date Table Read and Writes to itself? I am getting a "Parameter error in module configuration". (this is just for testing for now)

Error code is 16#0009 and extended error code is 16#0000_000c

The path I am using is "2,192.168.58.151" which is the PLCs own IP address for Ethernet Port 1. (The 538o is configured with separate Eth interfaces)

The Tag I am trying to read is a Program level UDT instance. So I am using "ProgramName.TagName" as my Source Element
 
Someone might correct me here, but I don't think you can read/write program scoped tags via MSG, only controller scope.
 
You can do it, and I have done it, but I had Very Good Reasons, like 110 identical devices that all needed the same MSG in order. It's not well-supported or recommended, and there's a high risk of creating a hard-to-troubleshoot program.
I understands, but I think I confused the issue see below.

BTW this isn't my first rodeo with com,s I have written plenty of socket level code in C#. Believe me I know comms are complicated.

It's fairly easy to change an IP address inside the CIP Path as long as the addresses all have the same number of digits. You need to carefully alter and pad if they are different.

I guess I don't understand why the IP address needs to be the same character length. won't I be rewritten the whole Path string? If I was altering individual characters I could understand that. Can you explain?




That sounds contradictory. If the MSG instructions access the same PLC, why does the IP address need to change ?

I am creating a template program to use on many PLCs and I am trying to make it as easy to configure as possible. So really the IP address wouldn't change during runtime normally. It would probably just be set once at commissioning. I just want to be able to set it once rather than 4 or possible 8 times at commissioning.



Also this is code that we provide to our customer to communicate with our PLC. I am trying to minimize Human error on there end. Countless hours have been lost over years to customers that didn't want to follow our instruction correctly on when writing there own code to communication with our machines. I am doing this to eliminate that problem.
 
OK, that makes a little more sense. You aren't modifying the Path in between executions, you're setting it once in the context of the machine's installation. Thank you for that context and detail.

Sure, you can write to the MCTagname.Path element of a MESSAGE datatype tag. It's a STRING, with a DINT Length and a SINT[x] .Data section just like any other ControlLogix String.

A description of the gotcha for me when I was using logic to edit the MSG instruction's CIP Path programmatically:

I was writing a sequentially targeted MSG, and my String length incremented by one when I went from .9 to .10, and again when I went from .99 to .100.

Example of the MCTagname.Path STRING value for two subsequently executed messages, using the same control tag:

$02$06$12$0D192.168.21.99$00

$02$06$12$0E192.168.21.100

The .LEN element of each of those ControlLogix Strings is 18, even though the number of characters in the length of the IP address string changed from 13 (0x0D) to 14 (0x0E).

I was just changing the characters after the last dot and didn't realize that I also had to change the earlier byte for the length of that "IOI Segment", and also pad odd-numbered string lengths with a null.
 
Someone might correct me here, but I don't think you can read/write program scoped tags via MSG, only controller scope.

On 5x70 processors and earlier, this is true, because messages could only exist at controller scope. 5x80 and later permit messages to be program-scoped, so these messages can use tags within.
 
OK, that makes a little more sense. You aren't modifying the Path in between executions, you're setting it once in the context of the machine's installation. Thank you for that context and detail.

Sure, you can write to the MCTagname.Path element of a MESSAGE datatype tag. It's a STRING, with a DINT Length and a SINT[x] .Data section just like any other ControlLogix String.

A description of the gotcha for me when I was using logic to edit the MSG instruction's CIP Path programmatically:

I was writing a sequentially targeted MSG, and my String length incremented by one when I went from .9 to .10, and again when I went from .99 to .100.

Example of the MCTagname.Path STRING value for two subsequently executed messages, using the same control tag:

$02$06$12$0D192.168.21.99$00

$02$06$12$0E192.168.21.100

The .LEN element of each of those ControlLogix Strings is 18, even though the number of characters in the length of the IP address string changed from 13 (0x0D) to 14 (0x0E).

I was just changing the characters after the last dot and didn't realize that I also had to change the earlier byte for the length of that "IOI Segment", and also pad odd-numbered string lengths with a null.
So you were accessiong the Path string using the SINT
[*] right? So if you changed it from 99 to 100 you were fine but then if you changed it back to 99 you ended up with 990? Am I following you right?

My understanding is if you do a MCTagPath := NewPath the length should be changed automatically, it's only if you access a string via the SINT
[*] that you also have to changed the .LEN. Right?
 
Ah good to know, I stand corrected.

Yup. It’s pretty much standard programming practice at this point for our company. Program-scoped messages were one of the few remaining hurdles to getting some real portability rolling. There’s also no need anymore to come up with creative naming at the controller scope to distinguish which program owns what messages.
 

Similar Topics

I need assistance with writing a logic for sending data from a Station PLC using 1 MSG instruction to an AGC PLC in every cycle using a CIP Data...
Replies
2
Views
580
Can Anyone tell that How Msg Instruction comes under Unscheduled communication and How System Overhead time slice(SOTS) function connected to it...
Replies
1
Views
968
Is there any good way to send actually messages to another PLC? The MSG instruction isn't really a message it just continuously writes to a tag...
Replies
2
Views
1,797
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
2
Views
92
What is the best way to extract the hour and minute from the register that comes from Yaskawa VFD. In studio 5000 I have a register saved as INT...
Replies
3
Views
96
Back
Top Bottom