Assigning numbers
The first step in calculating numbers is assigning values to variables. In the previous chapter, we touched on the concept of initializing a variable with a value, during declaration, in the variable section of the program file. However, as stated in that chapter, it is possible to assign a value in the logic section. Typically, you’ll assign a value to a variable in the logic section of the file when you do a computation.
Unlike most other programming languages, such as Java, C++, or C#, the assignment operator is not the typic equals sign. For the IEC 61131-3 standard, the assignment operator is denoted with the following symbol:
:=
Essentially, this operator tells the PLC to assign a value to a variable. For example, this block of code will assign the number 3 to the x
variable:
x := 3;
The following block of code will assign the value in the a
variable to the b
variable:
b := a;
As we can see there is a pattern for assignments. The value...