Tuesday, October 22, 2019

Mathematical functions PLC

We studied some functions of data handling and today we continue with it. Here We study mathematical function of data handling.

As we know mathematical functions like Addition, Subtraction, Multiplication, Division and many more takes vital role in our operations. It helps programmer to write simple program for complex systems.

Here is an example shown below which can clear the statements.





We should take a NO switch (i0.0) and use application instruction and write the instruction as shown above. Here I write the address of memory words as N7:0 … but in Siemens we use MW0 as we studied before. Here we have two sources for the addition, A and B. The operation is addition and in Siemens we should write like

MW0 + MW1 == MW2

Means memory word 0 and memory word 1 is added into memory word 2.

As both are integers so result is also an integer. There is no floating value.


What if we get floating number in division or we should increment our values???

There are various functions which carry such operations so we should use memory bit which can use floating number. For increment process we can add 1 directly on our desired result as shown below…

MW0 + 1== MW1

Means memory word 1 is added with integer 1 and result is stored in memory word 1.



To clear it more we go with an example shown below…





ADD (value, value, destination) – Add two values. Here we have two types of addition.

first one is addition of two memory words. Memory words are space allocated in plc for memory storage. We can put value in those memory words online(after running program) and the data will be added at destination.
Second one is addition of integer directly to memory word and result will store at destination.
We can also add two integer and result can be stored in memory words

 SUB (value, value, destination) – Subtract two values. In this process a value in memory word is subtracted from value in another memory word and stored in third memory word.
All types and functions are similar to ADD.

MUL (value, value, destination) – Multiply two values. In this function we can multiply two values and result will be stored in memory word.

DIV (value, value, destination) –  Division of value by another. It divides one value by another and result stored in memory words.
There are three types of division.
First is division of two integer and result is also integer.
Second division is for both floating value and result is floating value so all memory words are capable for floating storage.
Third one is for two integer value which makes floating result so it should be stored in floating capable memory word.

NEG (value, destination) –  reverse sign from positive to negative and vice versa.

CLR (value) – clear the memory location 

   These are basic mathematics instructions. For detail you can send me your queries. 

No comments:

Post a Comment

Logical Gate, Symbols, Truth Table and functions

Electric Logic •Logical values can easily be expressed by electrical circuits. •“True” or “1” can be defined as voltage on a wire whil...

Smart Chapter