Author Topic: Global Variables  (Read 19067 times)

Offline bryantmorris

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +0/-1
Global Variables
« 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.

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 352
  • Karma: +8/-0
    • Marbek Elektronik
Re: Global Variables
« Reply #1 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.
Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung

Offline bryantmorris

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +0/-1
Re: Global Variables
« Reply #2 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.

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Global Variables
« Reply #3 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.

Controls Engineer
Hydra-Power Systems

Offline bryantmorris

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +0/-1
Re: Global Variables
« Reply #4 on: August 30, 2017, 06:29:18 AM »
Thank you Tom,

I will try what you said and see how it works.

Offline bryantmorris

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +0/-1
Re: Global Variables
« Reply #5 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

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Global Variables
« Reply #6 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.
Controls Engineer
Hydra-Power Systems

Offline LBee11

  • PLUS+1 Developer
  • ***
  • Posts: 26
  • Karma: +1/-0
Re: Global Variables
« Reply #7 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

Offline Stefan

  • Administrator
  • PLUS+1 Expert
  • *
  • Posts: 73
  • Karma: +0/-0
Re: Global Variables
« Reply #8 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

Offline LBee11

  • PLUS+1 Developer
  • ***
  • Posts: 26
  • Karma: +1/-0
Re: Global Variables
« Reply #9 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?

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Global Variables
« Reply #10 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.
Controls Engineer
Hydra-Power Systems

Offline apachler

  • PLUS+1 Novice
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Global Variables
« Reply #11 on: February 06, 2019, 11:25:01 AM »
Any news on supporting retain variables in Plus+1 from the Danfoss guys?

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Global Variables
« Reply #12 on: February 06, 2019, 05:26:33 PM »
I believe retain variables do work in ST.  Are you using the latest version of GUIDE?
Controls Engineer
Hydra-Power Systems

Offline Nilla

  • PLUS+1 Guru
  • *****
  • Posts: 253
  • Karma: +14/-0
Re: Global Variables
« Reply #13 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

Offline Nilla

  • PLUS+1 Guru
  • *****
  • Posts: 253
  • Karma: +14/-0
Re: Global Variables
« Reply #14 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