23.11.2012 Views

2 Visual Components Manuals

2 Visual Components Manuals

2 Visual Components Manuals

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.

Introduction to <strong>Visual</strong> <strong>Components</strong> 2.3<br />

The input field for the recipe no. is connected to the static PV (see code). Input fields for<br />

elements 1 − 5 are connected to the dynamic PVs to (see code).<br />

The contents of the fields for elements 1 − 5 can now be controlled using the recipe number. A change in the<br />

recipe number in the code causes the dynamic PV to 'transfer' to the array element with the index<br />

. Both the array (with 5 elements) and the dynamic PV are of type which<br />

contains 5 UDINT (unsigned long) elements (elem1 − elem5).<br />

4.12.7.3 Code in Automation Basic<br />

4.12.7.3.1 Initialization Section<br />

In the initialization section, 5 array elements of type are initialized with values, the current recipe<br />

number is set to recipe 1, and the old recipe number is set to 0. The control<br />

variable is set to 1 if the new recipe number differs from the old number; it is set to 0 at the<br />

beginning.<br />

(* init program *)<br />

loop i = 0 to 5 do<br />

rec_arr[i].elem1 = 100 * i + 1;<br />

rec_arr[i].elem2 = 100 * i + 2;<br />

rec_arr[i].elem3 = 100 * i + 3;<br />

rec_arr[i].elem4 = 100 * i + 4;<br />

rec_arr[i].elem5 = 100 * i + 5;<br />

endloop<br />

recipeNrAct = 1;<br />

recipeNrOld = 0;<br />

recipeChanged = 0;<br />

4.12.7.3.2 Cyclic Section<br />

The cyclic part checks whether the current recipe number is different from the old recipe number<br />

if the user selects a new recipe number using an input field. In this case, the new recipe number<br />

4.12.7.3 Code in Automation Basic 431

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

Saved successfully!

Ooh no, something went wrong!