Skip to main content

2.1 Variable Segment and Valid Range

warning

The maximum allowed memory for variables in a variable declaration block is 64KB for T3 and 512KB for T4

2.1.1 GVS

  • According to the figure below,the variable segments in GVS are GOBAL VARIABLE and GLOBAL CONSTANT
  • Variables in the global variable table can be accessed by any program unit. "Namespace.Variable name" is valid for any program unit. Duplicate names are not allowed in each GVS table under the same namespace
  • For specific usage, please refer to Add Global Variable

alt text

2.1.2 PU

  • For information on adding and using program units, please refer to Add Program Unit
  • According to the figure below,the variable segments in PU are VAR, TEMP and LOCAL CONSTANT
  • Non-TEMP variables in PU can be read by other program units alt text

2.1.3 FB

  • According to the figure below,the variable segments in FB are INPUT, INOUT, OUTPUT, STATIC, TEMP and LOCALCONSTANT
  • FB instance variables are declared in GVS and are global variables. The FB instance can be called and accessed in PU, FB, and FC

alt text

2.1.4 FC

  • According to the figure below,the variable segments in FC are WITH RETURN, INPUT, INOUT, OUTPUT, TEMP and LOCALCONSTANT alt text
tip
  • Variables declared in GVS and non-temp variables declared in PU are global variables and can be accessed by any program unit
  • Any variables declared in the program unit can be accessed without namespace in this program unit
  • FB instance variables in Baosky IDE cannot be declared in PRG
  • When a FB instance is called from other FBs, it is recommended that the FB instance be declared as a STATIC variable or INOUT variable in other FBs
  • When a FB instance is called from other FCs, it is recommended that the FB instance variables be declared as INOUT variables in other FCs