02.09.2014 Views

ISPSoft User Manual

ISPSoft User Manual

ISPSoft User 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.

Chapter 7 Function Block<br />

The principles of using a symbol whose data type is POINTER, T_POINTER, C_POINTER, or<br />

HC_POINTER are as follows.<br />

1. Only AH500 series CPU modules support a symbol whose data type is POINTER, T_POINTER,<br />

C_POINTER, or HC_POINTER.<br />

2. The symbols whose data types are POINTER can only be declared in the function blocks in a<br />

project, and they must be symbols of VAR_IN_OUT class.<br />

3. The pointers and the restrictions are described below.<br />

Pointer<br />

Restriction<br />

Maximum 16 symbols whose data types are POINTER can be<br />

number declared in a function block.<br />

General pointer<br />

Symbol whose data type is<br />

POINTER<br />

Reference WORD/DWORD/LWORD/INT/DINT/LINT, data register, link<br />

register, or X/Y device (e.g. X0/Y0)<br />

Maximum 8 symbols whose data types are T_POINTER can be<br />

Pointer for a timer<br />

number declared in a function block.<br />

T_POINTER<br />

Reference Timer or symbol whose data type is TIMER<br />

Maximum 8 symbols whose data types are C_POINTER can be<br />

Pointer for a counter<br />

number declared in a function block.<br />

C_POINTER<br />

Reference Counter or symbol whose data type is COUNTER<br />

Pointer for a<br />

Maximum 8 symbols whose data types are HC_POINTER can be<br />

high-speed counter<br />

number declared in a function block.<br />

32-bit counter or symbol whose data type is COUNTER and<br />

HC_POINTER Reference<br />

to which a 32-bit counter is assigned<br />

• Example of using a symbol whose data type is POINTER<br />

The function block FB0 has three input pins. The data types and the classes are in the red<br />

frame in the local symbol table below. D0, D1, and D2 in the POU (caller) are assigned to the<br />

three pins. (The initial values in D0, D1, and D2 are 0.) The execution of the program is as<br />

follows.<br />

‣ D0 is assigned to VAR_IN. VAR_IN is a symbol of the VAR_INPUT class, and the data type<br />

of VAR_IN is WORD. When the function block is called, the present value in D0 is copied<br />

into VAR_IN. After the operation inside the function block is performed, 4 will be added to<br />

the value of VAE_IN. The operation result does not affect D0, and therefore the value in D0<br />

is always 0.<br />

‣ D1 is assigned to VAR_IO. VAR_IO is a symbol of the VAR_IN_OUT class, and the data<br />

type of VAR_IO is WORD. When the function block is called, the present value in D1 is<br />

copied into VAR_IO. After the operation inside the function block is performed, 4 is added to<br />

the value of VAR_IO. Owing to the fact that VAR_IO is a symbol of the VAR_IN_OUT class,<br />

the value of VAR_IO is copied into D1 after the function block is executed. The value sent<br />

from D1 to VAR_IO is an accumulated value. The value in D1 accumulates during the<br />

execution of the function block.<br />

‣ D2 is assigned to pVAR. Owing to the fact that the data type of pVAR is POINTER, the sum<br />

7-9

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

Saved successfully!

Ooh no, something went wrong!