12.05.2014 Views

Automating Manufacturing Systems - Process Control and ...

Automating Manufacturing Systems - Process Control and ...

Automating Manufacturing Systems - Process Control and ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

plc basic functions - 15.6<br />

store the result in memory. Figure 15.4 shows an ADD function that will retrieve values<br />

from int_1 <strong>and</strong> real_1, convert them both to the type of the destination address, add the<br />

floating point numbers, <strong>and</strong> store the result in real_2. The function has two sources<br />

labelled source A <strong>and</strong> source B. In the case of ADD functions the sequence can change,<br />

but this is not true for other operations such as subtraction <strong>and</strong> division. A list of other<br />

simple arithmetic function follows. Some of the functions, such as the negative function<br />

are unary, so there is only one source.<br />

A<br />

ADD<br />

source A int_1<br />

source B real_1<br />

destination real_2<br />

ADD(value,value,destination) - add two values<br />

SUB(value,value,destination) - subtract<br />

MUL(value,value,destination) - multiply<br />

DIV(value,value,destination) - divide<br />

NEG(value,destination) - reverse sign from positive/negative<br />

CLR(value) - clear the memory location<br />

NOTE: To save space the function types are shown in the shortened notation above.<br />

For example the function ADD(value, value, destination) requires two source values<br />

<strong>and</strong> will store it in a destination. It will use this notation in a few places to<br />

reduce the bulk of the function descriptions.<br />

Figure 15.4<br />

Arithmetic Functions<br />

An application of the arithmetic function is shown in Figure 15.5. Most of the<br />

operations provide the results we would expect. The second ADD function retrieves a<br />

value from int_3, adds 1 <strong>and</strong> overwrites the source - this is normally known as an increment<br />

operation. The first DIV statement divides the integer 25 by 10, the result is rounded<br />

to the nearest integer, in this case 3, <strong>and</strong> the result is stored in int_6. The NEG instruction<br />

takes the new value of -10, not the original value of 0, from int_4 inverts the sign <strong>and</strong><br />

stores it in int_7.<br />

www.PA<strong>Control</strong>.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!