User Tools

Site Tools


mycnc:global_variables_description

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mycnc:global_variables_description [2020/03/26 13:41] ivanmycnc:global_variables_description [2022/08/04 10:58] (current) ivan
Line 1: Line 1:
 ===== Global Variables Description ===== ===== Global Variables Description =====
 +
 +
 +^ Related articles ^ 
 +| [[mycnc:global_variables|Global Variables]] |
  
 A global variable is a variable which is used by the myCNC application to store some information about a particular process, flag or setting. A full list of global variables is available [[mycnc:global_variables|here]]. A global variable is a variable which is used by the myCNC application to store some information about a particular process, flag or setting. A full list of global variables is available [[mycnc:global_variables|here]].
Line 5: Line 9:
 The values stored in these global variables are defined in the myCNC profile that is being used, within the cnc-variables.xml file. This file contains a list of CNC and global variables that the program utilizes, as well as their values and minimum/maximum possible values. The values stored in these global variables are defined in the myCNC profile that is being used, within the cnc-variables.xml file. This file contains a list of CNC and global variables that the program utilizes, as well as their values and minimum/maximum possible values.
  
-These min/max values are useful to set up once during the machine setup to provide realistic bounds for the range of a certain global variable. +The myCNC program auto-updates the ''cnc-variables.xml'' file when the program is closed, to save the current state of the global variables. 
 + 
 +//**NOTE**: Only the files that are already in the ''cnc-variables'' list are updated. When writing a variable (via the ''gvarset'' command, for example) from the Software PLC, the variable is added to the global variables list. If the variable is simply being read, or used to display some value changes on the screen, it will not be added to ''cnc-variables.xml'' file and the value will be lost on program restart - this is highly relevant for custom gvariables (#3500-3900).// 
 + 
 +The min/max values are useful to set up once during the machine setup to provide realistic bounds for the range of a certain global variable. 
  
 The syntax then is the following: The syntax then is the following:
Line 17: Line 25:
   * in this example, **1000** represents the current value of the aforementioned variable   * in this example, **1000** represents the current value of the aforementioned variable
  
 +{{youtube>M4oQrq4BXkw?large}}
  
 ==== List of global variables ==== ==== List of global variables ====
Line 31: Line 40:
 <code>G10 L80 P5525 Q0 (Write 0 to #5525)</code> <code>G10 L80 P5525 Q0 (Write 0 to #5525)</code>
  
 +Writing a value larger than 2 will initialize a timer after the macro containing Global Variable #5525, delaying the subsequent turning on of Software Limits control. This is useful in situations where a prolonged procedure requires a longer time within which the Software Limits are turned off than the macro containing P5525 Q1 itself.
 +
 +Example of code: 
 +
 +<code>G10 L80 P5525 Q15 (15 sec timer)</code>
  
 ===  60010 === ===  60010 ===
Line 62: Line 76:
 Read from this register will send read inquiry to Modbus device (PLC controller will be in till Regiter value received from Modbus device). Writing to this register will send ready inquiry to Modbus device. The value written is used as Register address to read  Read from this register will send read inquiry to Modbus device (PLC controller will be in till Regiter value received from Modbus device). Writing to this register will send ready inquiry to Modbus device. The value written is used as Register address to read 
  
 +=== 64200 ===
 +
 +Writing an ID number to this register (specified in the XML files as id=“NUMBER”) will show a widget. Similarly, the global variable 64201 allows the user to hide a widget by using a specific ID number. 
 +
 +An example of such a widget can be controlled via a Software PLC:
 +
 +<code C>main()
 +{
 +
 +v5528=gvarget(5528);
 +
 +do
 +{
 + 
 +  v=gvarget(5528);
 +  if (v!=v5528)
 +  {
 +    if (v!=0)
 +    {
 +      gvarset(64200,200);
 +    }else
 +    {
 +      gvarset(64201,200);
 +    };
 +    v5528=v;
 +  };
 +
 +}while(1);
 +
 +exit(99);
 +};</code>
 +
 +In the example above, the system will continuously monitor (through a usage of a do-while loop) the state of global variable #5528 (Simulation Mode), and will open/hide a widget on the screen whenever the state of that global variable changes. The widget is then described by the following lines in an .xml file within the profile folder:
 +
 + <code XML><gitem where="xp" name="x-trial-speed" id="200" position="750;570" 
 + width="190" height="100" type="myitems" bgColor="##b-main"  hidden="0" /></code>
 +
 +Here, the widget (of the type ''myitems'') is given an ID in addition to a name, with the line ''id="200"'', therefore corresponding to the ''gvarset(64200,200)'' line from the earlier software PLC. 
 +
 +Video illustrating the usage of global variable 64200:
 +
 +{{youtube>SANmC5NSkSU?large}}
  
  
 [[global_variables|Global Variables Table]] [[global_variables|Global Variables Table]]
  
mycnc/global_variables_description.txt · Last modified: 2022/08/04 10:58 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki