17.02.2013 Views

Kuhnke Electronics Instruction Manual

Kuhnke Electronics Instruction Manual

Kuhnke Electronics Instruction Manual

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.

Thread usage<br />

Function Libraries<br />

A thread's program covers a number of tasks which are<br />

more or less detached from others. Consequently, it also<br />

allows you to separately program and run these tasks.<br />

Try wrapping non-time-critical parts of the program into a<br />

thread. This will shorten the runtime of PLC_PRG and,<br />

thus, the intervals at which the process image and online<br />

communication are refreshed.<br />

Example:<br />

You wish to turn a program module called "Thread1" into<br />

a thread and have IN_00 run it. Add the following code<br />

lines to the PLC_PRG module.<br />

VAR<br />

IN00_00 AT %IX0.0: BOOL;<br />

Index1: WORD;<br />

Tslice1: WORD;<br />

Runs1: WORD;<br />

Flag1: UINT:=255;<br />

Start_Thread1: R_TRIG;<br />

Activate_Thread1: BOOL;<br />

END_VAR<br />

Start_Thread1<br />

( CLK:=IN_00,Q=>Activate_Thread1 );<br />

IF Activate_Thread1 = TRUE THEN<br />

Flag1:=0;<br />

END_IF<br />

IF Flag1 = 0 THEN<br />

Index1:= INDEXOF ( Thread1 );<br />

Flag1:= CREATE_THREAD<br />

(Index1,Tslice1,Runs1);<br />

END_IF<br />

73

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

Saved successfully!

Ooh no, something went wrong!