Boolean Variables
Boolean variables have a value of TRUE or FALSE.
Integer and Float Variables
There are Integer and Float types of Numeric variables.
- Integeris used for whole numbers (i.e., 1, 2, 3)
- Floatis used for numbers with decimal points (i.e., 3.14)
Arithmetic
You can add, subtract, multiply, etc.
Comparisons and Inequalities
You can compare two numbers to get a True or False result.
Number Formatting
You can show numbers with leading zeros, a certain number of decimal places, etc.
Counting and Serial Numbers
You can create a counting variable that is stored in a file.
Text Variables
For the purposes of explanation, these expressions use the value “Some_String” in the variable, "Barcode".
Logical Text Expressions
These return a True or False value.
Barcode.equals(“Some_String”) = True Barcode.contains(“Some”) = True
Numeric Text Expressions
This returns an Integer value.
Barcode.length = 11
Text Expressions
These return Text values.
Substring(Barcode, 3) = “e_String” Substring(Barcode, 3, 2) = “e_” Barcode + “!” = “Some_String!” Barcode + “,” + Barcode = “Some_String,Some_String”
Convert Other Formats into Text
Use the ToString Function.
Trigger Variables
These are Boolean variables and can have the same kind of logic expressions that any Boolean variable has. The difference is that they will cause Light Guide to start a work instruction when they transition from False to True.
Idea
The Start value of the variable corresponds to the Program Number in the Program Linking Tab of System Settings. They can also be set in the Start of Work Instructions line of any work instructions by looking in the Format Tab.
Note: Figuring out the work instructions number can be hard. Assuming that the relevant work instructions have numbers, it is a lot easier to edit the variable using the Modify button in the variables tab because the window that will pop up will have a list of work instructions that you can choose and will automatically populate the start value based on which work instructions you choose.
Starting Work Instructions with Barcode Logic
You can number your work instructions in the Settings menu, Program Linking tab.
Then you can create trigger variables that launch these programs. Use the Modify button on a new variable to set this up.
Once in the modify menu you can select which program to start on that variable from the list to the right
Starting Work Instructions from an IO Device
If you have a bit from a PLC that you want to use to start a work instruction, do the following:
- Create a trigger variable.
- Select the Program Number.
- Write the name of the Boolean variable from the IO device in the Logic column of the trigger variable.
You can do these things using the Modify button in the variables table. This is helpful because it gives you a list of programs to choose from, instead of having to know the number associated with it. If your program does not appear in the list, add it in the Program Linking tab.
Here are some examples of Trigger variables that have already been created.
The trigger variable value will then mirror the value of the bit coming in from the PLC. When it goes True, the trigger variable will trigger a work instruction to start.
Starting Work Instructions when a File is added to a directory.
Use the steps in File Reader to set up a file reader device. The variables below will be created. But you will have to add two variables, a NewFileLoaded variable as a system trigger variable, and a LastFileCreated as a system text variable. The logic for LastFileCreated should be left blank.
The value for LastFileCreated should be the same as *FileReaderName*_Modified initially.
The logic for NewFileLoaded should be LastFileCreated <> *FileReaderName*_Created. With FileReaderName replaced with the name of the file reader you created.
Now at the start of your triggered program you should have the following set value. LastFileCreated to MES_Created. When this program is run it will set the current file created time to LastFileCreated to essentially save it. When a new file is entered into this directory with the same extension, it should trigger this program to start. (program in slot 1 of program linking)
Exceptions
If Enable Abort is not set in the General Tab of the Settings menu, then Trigger variables will not be able to abort work instructions that are currently running in order to start a new work instruction. This is disabling all trigger variables until there is no work instructions running.
IO Device Variables
IO Device variables are directly linked to a communication interface that connects to the outside world or just another software application.
Inputs
Inputs typically are controlled directly by the IO device.
Start values usually denote either an address or nothing. Length values can be number of bits in an integer, number of digits for a substring, etc. Logic values are usually used to help the system know how to format data. These are not related to the expression evaluation that normally happens in the logic column.
Outputs
Outputs are controlled either by the expression evaluator or by using Variable commands in the work instructions.
Start values usually denote either an address or nothing. Length values can be number of bits in an integer, number of digits for a substring, etc. Logic values are used by the normal expression evaluator to determine what to send to the IO device.
Built-In System Variables
How to Create Built-In System Variables
- Go to the System Settings menu, Variables Tab
- Click the Newbutton
- Right-clickon the Name of the new Spare001 variable that was created.
- Select the new variable name from the popup menu.
- Your new variable will become a built-in system variable.
Control
- Abort- Boolean- Abort’s work instructions when true. This can be set true using an expression in the logic column or by using a Variable command within a set of work instructions. The value will reset to false whenever a set of work instructions is exited. Unlike many built-in variables, this one allows you to edit the logic column.
- Pause- Boolean- Pause’s work instructions when true. Logic can be set like the Abort Status can be checked with the WI_Paused variable, but this can also indicate that the user pressed the pause button directly. This variable can resume execution when toggling from true to false, overriding the user using the pause button, but the user cannot resume operation if this variable caused it to pause.
If User presses pause button to pause executionPause variable toggles from true to false --> execution resumes.User presses the pause button again --> execution resumes. If Pause variable goes true to pause executionPause variable toggles from true to false --> execution resumes.User presses the pause button --> system remains paused.
Time
- StepTime- Float- Step time in seconds.
- WI_Time- Integer- Total seconds so far in given work instructions. This was formerly called ProgramTime.
- SecondsToday- Integer- Seconds since midnight (max = 86,400).
- MinutesThisWeek- Integer- Minutes since 12AM Sunday Morning (max = 10,080).
- DayOfWeek- Integer- Sunday = 0, Monday = 1, etc.
- DayOfMonth- Integer- Calendar Day of the Month.
- MonthOfYear- Integer- January = 1, etc.
- Year- Integer- Full year (YYYY).
Database
- $DatabaseField1- Text- Data to store for current work instruction cycle in CustomField1 column. When a set of work instructions completes or is aborted, whatever value this variable has will be stored in the database. Unlike many built-in variables, this one allows you to edit the logic column.
- $DatabaseField2- Text- Data to store for current work instruction cycle in CustomField2 column. When a set of work instructions completes or is aborted, whatever value this variable has will be stored in the database. Unlike many built-in variables, this one allows you to edit the logic column.
- $DatabaseField3- Text- Data to store for current work instruction cycle in CustomField3 column. When a set of work instructions completes or is aborted, whatever value this variable has will be stored in the database. Unlike many built-in variables, this one allows you to edit the logic column.
- $DatabaseStepField- Text- Data to store for current step. When each step completes, whatever value this variable has will be stored in the database. Unlike many built-in variables, this one allows you to edit the logic column.
Status
- ApplicationError- Boolean- True when LGS has an error.
- LGSState- Text- Status of LGS for HMI to use. Possible values listed below:
- Selected - Open in Design Mode
- Program - Running in Design Mode
- File Browser - File browser state in either Design or Run mode
- Program Selected - Open in Run mode but not running (not possible in recent versions of the software)
- Program Running - Running in Run Mode
- Paused - Paused in Run Mode
- Program Ended - Completed in Run Mode.
- WI_Name- Text- Name of the work instruction design file, minus XML extension. This was formerly called ProgramName.
- WI_Number- Integer- Number associated with the currently running work instructions. This was formerly called ProgramNumber.
- WI_Running- Boolean- Work instructions are currently running. This was formerly called ProgramRunning.
- WI_Paused- Boolean- Work instructions are currently paused.
- StepComment- Text- The comment for the currently running step.
- StepNumber- Integer- Step number.
- NumSteps- Integer- Number of steps in active work instructions.
- UserName- Text- User name that is logged in.
Mouse
- MouseLeft- Boolean- True when the left mouse button is down, it goes back false when the button is released.
- MouseCanvas- Text- Name of the canvas that the mouse is over - blank if the mouse is not over a canvas.
- MouseX- Integer- The X-coordinate of the mouse on a given canvas (relative to the left edge of that canvas).
- MouseY- Integer- The Y-coordinate of the mouse on a given canvas (relative to the top edge of that canvas).
Keyboard
- KeyDown- Boolean- True only at the instant that any key is pressed down.
- KeyPress- Text- Name of the key that was last pressed on the keyboard.
IO
- Barcode- Text- Last completed barcode scan
- $LEFT_BUTTON- Boolean- Set True by right USB footpedal (Ctrl+F8).
- $RIGHT_BUTTON- Boolean- Set True by left USB footpedal (Ctrl+F9).
- $TIMER_ADVANCE- Boolean- Set True by VDF Countdown reaching zero.
Constant Variables
- A System variable with no logic will remain constant.
- These can only be changed using the Variable command in an LGS work instruction.
- The value can be used by other variables in their expressions.
Counting Variable
With Deluxe and Unlimited software licenses, you can store a variable's value to a file and use it for counting applications.
First set up a file reader device that is for storing and retrieving variable values. You can make the file live anywhere, but we recommend leaving it in the Light Guide Systems folder.
The variables are Text by default, so you will need to change at least one to be an Integer.
You can then put these three variable commands into your LGS work instructions:
- Retrievethe latest value from the file,
- Incrementthe value, and
- Storethat new value in the file.
Here is how you set up the increment part of it.
Local Variables
Variables can be created from inside work instructions by using the Variable Command. Once a variable command is executed, that variable will be visible when setting up things in the work instruction that can reference variable values. The Visible if property, wait commands, and other variable commands can use the values of a locally created variable. These will disappear when the work instructions are exited or aborted.
Creating Local Variables
If you type in a new variable name in the Variable field, then the system will create this variable instead of assigning a value to an existing variable.
The new variable can then be seen in the IO Table. This is available in the Menu under Devices or by pressing F4.
One-time logic versus continuous logic
In the example above, a new local variable was created with a particular value. This value can be dynamic if you change the Constant selection to be Expression. In the next example, the value of the variable will be calculated based on the current Username.
Therefore, if the current user is SuperUser, then the variable value will become "Logged in: SuperUser".
Notice the Continue to run this logic" checkbox.
- If it is unchecked, the variable value will be set once, when Light Guide reaches this command.
- If it is checked, it will update every time the variables are recalculated. This is typically at least 2 times per second.
Scope of Local Variables
Once made, local variables can be used anywhere in the work instructions that executes after the point where the variable was made. They can also be used in subroutines, but it can be confusing if you open a subroutine on its own and do not see the local variables that were made by a different program that happens to call the subroutine. Local variables will automatically be removed when a program exits or is aborted.
Barcode Example
One way to use local variables is to wait for a barcode scan for a confirmation. You can set the logic as shown in the image below.
Notice that the local variable is used in the Wait command. You will not see this variable as an option until you activate the Variable command. Double-click the "Set Logic" line to create the Scan variable, then it will appear on the list of possible variables in the Wait command.