Variables are the name of occupied memory area that used for write or store value, Variables are declared with a specific data type, which determines the type of data that can be stored in the variable. When we declared a variable it means we give a name to a data type where data type defines what kind of value it can hold, how it can be stored, and what operations can be performed on it. for example if we have a push button than we have generally two condition first is stop and second is start so we know push button have only one operations start or stop in plc we declared a variable for a push button named PB_start if pb_start is true it means push button is operated. in a plc you can declared any variable with same data type but you can’t declared same variable for different data type. Variable name is user defined name. Variables are used to store data that can be accessed and manipulated by the program. They can hold different types of data such as integers, floating-point numbers, characters, strings, and Boolean values. generally in plc variables are two types global and local variable.
plc variables are same as tag name for example if we declare motor1 for a motor than we declare all other variable like motor1_start, motor1_stop, motor1_current. we easily find motor1 group with the help of variable. variable are two types local variable and global variable. both variable have different uses in a program.
a local variable that is declared within a specific program it can be used only inside the program or group where variable declared. we can’t accessed same variable outside of the program. for example if we declared a variable in omron plc water_lvl inside a senction1 and the address of water_lvl is D0 and data type is real. so we can use D0 as variable water_lvl within in a section1 in other section1 we also declare same variable name with different address. if address and variable name is same than value of variable is fluctuated because we use same address for a variable.
Global variable accessed by any part or function ,instruction of the plc program. Global variables are not limited to a specific scope or function and are available throughout the entire program's execution. global variable used when values that need to be shared and used by multiple section or blocks of program. value of global variable is same across different parts of the program.
following are some tips for defining variables for a plc program: