PLUS+1 User Forum

PLUS+1 Tools => PLUS+1 GUIDE => Topic started by: bryantmorris on July 10, 2017, 02:32:40 PM

Title: Global Variables
Post by: bryantmorris on July 10, 2017, 02:32:40 PM
Hello all,

I've been using Plus+1 for a number of years now and as the time goes on I'm pushing plus+1 product into more complex applications. I tend to use call modules with ST in them as much as possible as I'm used to writing code on other PLC brands I use.

One thing that does annoy me in Plus+1 is the inability to use global variables that I can just reference from any ST function that I may be using. Is there any method of doing this in Plus+1?

Look forward to your response.
Title: Re: Global Variables
Post by: Marbek_Elektronik on July 12, 2017, 08:42:41 AM
I work with Plus+1, Guide only. No other language.
I put my values in busses. - It is OK.

If you have a page, you have one or more local values on input or output.
You can use more than once the "Input" and the "Output"-symbol for the same value. So, here you don't need to draw a lot of lines to connect them.
Here, you can copy the "Input"or "Output"-symbols.
If you have questions about this, I could send you an example.
Title: Re: Global Variables
Post by: bryantmorris on August 03, 2017, 02:06:46 AM
Thank you for the reply Marbek,

But your answer is basically no, it is not possible to have Global Variables as I asked about.

I understand it doesn't really fit in with the structure of the Plus+1 development environment, but it would be a nice feature to have in the future.
Title: Re: Global Variables
Post by: FluidPowerTom on August 03, 2017, 05:17:20 PM
A global variable list is possible and can be used in the Structured Text environment (possibly the other IEC 61131-3 environments too).  I've attached an image showing where you can make this list.  It's in the Project Manager tree in the program name (bottom of the tree)-->PLCFile.xml-->Global Variables.  Right click the Global Variables folder to insert the list.

Title: Re: Global Variables
Post by: bryantmorris on August 30, 2017, 06:29:18 AM
Thank you Tom,

I will try what you said and see how it works.
Title: Re: Global Variables
Post by: bryantmorris on September 18, 2017, 03:13:00 AM
Hi all,

How are global variables accessed in a POU using structured text? Is it a VAR_IN or a  VAR_IN_OUT?

Let me know
Title: Re: Global Variables
Post by: FluidPowerTom on September 25, 2017, 06:27:07 PM
I actually haven't made use of the global variable feature in GUIDE, but for other 61131-3 structured text usage the global variable is just use in the code without needing to be declared at all in the POU.  So, basically just try using it.
Title: Re: Global Variables
Post by: LBee11 on November 23, 2017, 03:13:21 PM
Var_Global - Define global variables inside the Global Variables file


In your ST code, just simply reference the name defined in the Global Variables file. Use Ctrl+Space to bring up the wizard as you are typing to select the name from.


Just FYI, you can also use "Retain" after declaring a structure so the program doesn't forget it when the Plus+1 is turned off. "Var_Global Retain" for example
Title: Re: Global Variables
Post by: Stefan on December 01, 2017, 03:04:22 PM
Hello,

The replies are correct. You declare the global variables in a list under Global Variables and then you just reference them in your code.

We have not got support for Var_Global Retain yet, sorry.

Stefan
Title: Re: Global Variables
Post by: LBee11 on January 03, 2018, 10:31:46 AM
How have we not got support for Retain? Isn't Retain a IEC function?


Any application that is IEC compliant I have ever used has the Retain function and they all work in the same way, the value is stored to memory when changed so in the event of a power off, it is remembered.


How do we achieve this in Plus+1?
Title: Re: Global Variables
Post by: FluidPowerTom on January 03, 2018, 06:25:18 PM
I believe Retain does work in the ST POU's... just not in the Global Variable List.
Title: Re: Global Variables
Post by: apachler on February 06, 2019, 11:25:01 AM
Any news on supporting retain variables in Plus+1 from the Danfoss guys?
Title: Re: Global Variables
Post by: FluidPowerTom on February 06, 2019, 05:26:33 PM
I believe retain variables do work in ST.  Are you using the latest version of GUIDE?
Title: Re: Global Variables
Post by: Nilla on February 11, 2019, 08:48:45 AM
Hi all!

VAR RETAIN works in ST in PLUS+1 GUIDE but not for GLOBAL variables.

You declare RETAIN variables by adding the keyword RETAIN behind the keyword for the type of variable (VAR) in the declaration part of programming objects.

Examples

In a POU:

VAR RETAIN
 iRem1 : INT;
END_VAR

I hope this helps!

Best regards
Nilla
PLUS+1 Helpdesk team
Title: Re: Global Variables
Post by: Nilla on February 11, 2019, 10:44:19 AM
Hi all!

Some clarification to my latest statement. As stated in the Release notes for PLUS+1 GUIDE v6.0.8;

"Limited support for RETAIN variables. Only local variables of basic integer types in function block POUs called directly from graphical code are currently supported."

Best regards
Nilla
PLUS+1 Helpdesk team