Andrew1

Access to program internal variables?

21 posts in this topic

I am new to Omron's NJ controller and Sysmac Studio and I was very disappointed to discover that program local variables cannot be accessed from outside the program under any circumstances.

Beckhoff's TwinCAT and Rockwell's Studio 5000 (newer versions) both have this ability. They have access modifiers for program local variables where they can be set to input or output. The variables can then be accessed from another program using the format "ProgName.VarName".

Does anyone know if there is some hidden method I am missing or if Omron are planning to add this feature?

1 person likes this

Share this post


Link to post
Share on other sites

Free phone call to Omron is good. Found the support fantastic in Oz.

Share this post


Link to post
Share on other sites

No method I am aware of, and I've never heard of it being done that way before.  

Kinda defeats the purpose of local variables.  If you want access in multiple programs, it's a global variable.

Share this post


Link to post
Share on other sites

Hi Crossbow,

I am pretty sure you are right. Just asking the question in hope.

If there is anyone from Omron reading this please consider adding it. Like I said, you can do it in TwinCAT and Rockwell's Studio 5000.

Share this post


Link to post
Share on other sites

It is very easy to convert it to a global variable and like Crossbow said, the definition of Global Variable is that any program can access it.  Just convert it to Global.

Share this post


Link to post
Share on other sites

Hi Michael,

I have had to use Global Variables just like you say. What I am trying to avoid is a massive list of Global Variables, although I have improved this by using structures. I have typically created one structure for all the variables associated with one program and that way my global variable list is manageable.

If you haven't used a system with access to local variables you won't miss it, but if you have then its frustrating.

 

Share this post


Link to post
Share on other sites

Global and Local variable declarations are defined in the IEC 61131-3 specifications. DON'T MESS WITH THIS.

The concepts are well defined across many control platforms to provide variable consistency.

Share this post


Link to post
Share on other sites

I checked IEC 61131-3 and it provides for exactly the feature I want in section 2.1.1 (see extract below), namely "interface parameters". A program is one type of POU so this does apply to both programs and function blocks. Can someone from Omron explain why this feature is not available in Sysmac Studio? TwinCAT is IEC 61131-3 compliant and it has it.

1 person likes this

Share this post


Link to post
Share on other sites

This is section of IEC 61131-3 I was referring to above:

"Variables have different forms. They can be defined (declared) outside a POU and used program-wide, they can be declared as interface parameters of a POU, or they can have a local meaning for a POU."

Share this post


Link to post
Share on other sites
11 hours ago, Andrew1 said:

This is section of IEC 61131-3 I was referring to above:

"Variables have different forms. They can be defined (declared) outside a POU and used program-wide, they can be declared as interface parameters of a POU, or they can have a local meaning for a POU."

As stated in your quote IEC 61131-3 offers suggestions for how variables can be declared. It doesn't say they they MUST have all the attributes in the specification.

OMRON has decide to make LOCAL variables only available to each specific POU and GLOBAL variables available everywhere.

Personally I prefer this approach bu apparently you do not. :-)

 

Share this post


Link to post
Share on other sites
On 3/11/2017 at 9:21 AM, Andrew1 said:

This is section of IEC 61131-3 I was referring to above:

"Variables have different forms. They can be defined (declared) outside a POU and used program-wide, they can be declared as interface parameters of a POU, or they can have a local meaning for a POU."

Dear Andrew1.

Regarding IEC-61131-3 please be aware that interface variables are  not local variables. By definition local variables exist and are accessible inside the POU only.

Sysmac defines the interface variables of a program as "External Variables", and are indeed one to one global variables.

Following standards allows higher compatibility  with other systems, reduces programming mistakes, and learning curve.

Some times standards are not the 'perfect' solution, but... usually are the result of a consensus of experts and the result of deep expert discussions. Bypassing standards or making an 'open' interpretation of the standard... can be 'cool', but... it's in general a potential source of problems.

1 person likes this

Share this post


Link to post
Share on other sites

Hi MotionControl.CAT,

OK, I take your point about the semantics of what I want. So my question now is why doesn't Sysmac Studio support interface parameters? It's compliant with IEC-61131-3 so that's not a valid argument against it. Does anyone on the inside at Omron who might know read this forum?

Share this post


Link to post
Share on other sites

Local variables are accessible only within each POU. Global variables are accessible from every POU. Couldn't be a simpler concept. What exactly IS your gripe with this concept?

Share this post


Link to post
Share on other sites

I would recommend contacting OMRON help desk directly for support. They are a great bunch of guys and unlike some manufacturers DO NOT require a service contract to ask them questions. That being said, I think what you may be looking for is a selection in the Global Variable table to Publish a variable which makes it available via interfaces such as Ethernet/IP. I use this for robot, HMI, and vision systems. By default Global variables are set to Do Not Publish.

Global.thumb.jpg.45820182f77647f2fe0bda1

Share this post


Link to post
Share on other sites

PLCSteam, that's not even close to what he is asking.  Publish is for Ethernet/IP access.

And Andrew1, interface variables are the inputs and outputs to/from function blocks.  Not local variables.

The standard is pretty clear that local variables are inside a program and global variables are outside.

Share this post


Link to post
Share on other sites
On 05/03/2017 at 8:10 PM, Andrew1 said:

I am new to Omron's NJ controller and Sysmac Studio and I was very disappointed to discover that program local variables cannot be accessed from outside the program under any circumstances.

Beckhoff's TwinCAT and Rockwell's Studio 5000 (newer versions) both have this ability. They have access modifiers for program local variables where they can be set to input or output. The variables can then be accessed from another program using the format "ProgName.VarName".

Does anyone know if there is some hidden method I am missing or if Omron are planning to add this feature?

Hi and hear hear!  I know this is a long time since your inquiry but this is spot on - I too have used that exact feature in Logix5k - once you use it, it makes perfect sense.  Just wondered if you ever managed to get anywhere with it in the Omron or did you have to relent and just use Globals? 

Obviously this now 4 yrs on and Omron still haven't caught on. I'm using their newer NX1 PLC - still the same!  Next I would ask Omron to consider the magic of an "ALIAS" tag.

For those still trying to think why - just think of 2 or more indentical machines in the same PLC.  Clearly each one in will be in a separate program.  But there are still many reasons why you might want to access some of the other machines tags, without making them global.  That way the 2 programs are absolutely identical!

Share this post


Link to post
Share on other sites

Keep in mind there are standards in use here, and while I have not read the standard word for word, a local variable is supposed to only be usable in one program.  I would venture to guess the IEC 61131-3 standard makes no mention of using local variables in other programs.  Omron followed the standard when designing Sysmac, and other vendors have varied from the standards over the years.

Share this post


Link to post
Share on other sites
On 06/07/2021 at 5:28 AM, Crossbow said:

Keep in mind there are standards in use here, and while I have not read the standard word for word, a local variable is supposed to only be usable in one program.  I would venture to guess the IEC 61131-3 standard makes no mention of using local variables in other programs.  Omron followed the standard when designing Sysmac, and other vendors have varied from the standards over the years.

Sure - as far as I'm aware, Rockwell's Logix 5k series software is all IEC 61131 compliant.  That said it's low bar.  Using the similarly configured statements that are present in the standard, a shopping trolley could be considered a "car"  It has four wheels and can steer.  Most other functions are considered "additional".

I know I'm stretching it but it's along those lines.

Anyway - If you have ever used the functions, I can tell you for sure the penny will drop - believe me it does make perfect sense. 

Share this post


Link to post
Share on other sites
15 hours ago, Graemek25 said:

Sure - as far as I'm aware, Rockwell's Logix 5k series software is all IEC 61131 compliant.  That said it's low bar.  Using the similarly configured statements that are present in the standard, a shopping trolley could be considered a "car"  It has four wheels and can steer.  Most other functions are considered "additional".

I know I'm stretching it but it's along those lines.

Anyway - If you have ever used the functions, I can tell you for sure the penny will drop - believe me it does make perfect sense. 

I've used that line about the grocery cart having 4 wheels myself before.  I get it.  I've used other IEC packages before.  But the standards don't say local variables should be accessible from other programs, so at this point, they are not. You can access them in the watch windows by writing program.variable, but I do not see then changing that any time soon for access in another program...

Share this post


Link to post
Share on other sites

Hi, so I'm not as up-to-speed on the standards as I can see you clearly are so I'll take your advice there.  Still remains that their software is compliant and it can do this..

Var.  Pgm1:  MyLocalTag1 - set as as "Public"

Var.  Pgm2: MyLocalTag1 - set as "Public" (or Local Only) if only one direction required

Now, in Pgm2 a line of ST code can be...

If \Pgm1.MyLocalTag1 > MyLocalTag1 Then..  whatever logic.. 

Note the backslash "\".  I don't see an issue.  The tag is still registered in the Pgm1 program local tags, but since it's "Public", it can be accessed from other Programs.  It keeps the code "cleaner" IMO.  Anyway,  we won't see that anytime soon - I do agree. 

Cheers

 

Share this post


Link to post
Share on other sites

Hey I agree with you on that.  As I said, I have done it before on other platforms.  Not trying to argue it...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now