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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

plc advanced functions - 16.24<br />

16.6 DESIGN CASES<br />

16.6.1 If-Then<br />

Problem: Convert the following C/Java program to ladder logic.<br />

void main(){<br />

int A;<br />

for(A = 1; A < 10 ; A++){<br />

if (A >= 5) then A = add(A);<br />

}<br />

}<br />

int add(int x){<br />

x = x + 1;<br />

return x;<br />

}<br />

Solution:<br />

MainProgram<br />

S:FS<br />

FOR<br />

function name: increment<br />

index A<br />

initial value 1<br />

terminal value 10<br />

step size 2<br />

SBR<br />

Increment<br />

GEQ<br />

A<br />

5<br />

ADD<br />

A<br />

1<br />

Dest A<br />

RET<br />

Figure 16.24<br />

C Program Implementation<br />

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

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

Saved successfully!

Ooh no, something went wrong!