Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SYPT PRO User Guide / SYPT PRO User Guide.doc
Скачиваний:
244
Добавлен:
03.03.2016
Размер:
17.32 Mб
Скачать

Udfb Code Sections

The code within a UDFB is split into two sections:

  • Theinitialcode section

  • Thebodycode section

The initial section is used for declaring and initialising any local variables that the UDFB will use. The initial section is run for every instance of a UDFB at start-up or reset (this occurs prior to the DPL Initial task).

Note:

The input and output arguments of a UDFB are not available in the initial section.

The body section is where the actual code of the function block exists - the part that does the work of the function. Input and output arguments only have context within the body section.

The two sections are separated by the keyword FBbody. Initial code goes before this keyword, body code after.

Remember that the actual code can consist of a mixture of DPL, LD/FBD diagrams, and LD diagrams.

Below is an example of a simple UDFB that adds two numbers and scales by a pre-defined amount (0.5):

See Also

  • User-Defined Function Blocks (UDFBs)

________________________________________________________________________________

Dpl (Drive Programming Language) Reference

This section is the reference for the DPL programming language. Follow the links below to find detailed information about DPL.

  • Variables, Parameters, Constants and Data Types

  • Program Structure

  • Directives

  • Operators

  • Conditional Operators

  • Comments

  • Constructs

See Also

  • Reference

  • Developing Applications

________________________________________________________________________________

Directives

Directives are instructions to the DPL compiler which control the way code is generated for the user program to be downloaded to a target. The available directives are shown in the following table.

Some directives are entered via the Node Properties dialog in the Configuration Editor and other are typed directly into the DPL view.

Some directives are entered via the Node Properties dialog in the Configuration Editor and other are typed directly into the DPL view.

See Also

  • Program Structure

  • Nodes

  • Developing Applications

  • Data Types

  • DPL (Drive Programming Language) Reference

________________________________________________________________________________

Operators

The complete list of DPL operators showing precedence and associativity, in order of precedence, is:

! - Bit (boolean) value invert

This operand inverts the least significant bit and sets all other bits to zero.

For example, if value% is 100100 then !value% will give a result of 000001.

!(value, bitfield_size) - Bit field invert

This operand inverts the least significant bits of the given value and converts all other bits to zero. The number of least significant bits that are to be converted is specified in the bit-field size value.

For example:

Result% = !(value%, 3)

If value% is 100100 binary then the result will be 000011 binary.

See Also

  • Conditional Operators

DPL (Drive Programming Language) Reference

________________________________________________________________________________

Conditional Operators

These operators can be used in conditional expressions in IF statements and WHILE loops. The complete list of conditional operators showing precedence and associativity, in order of precedence, is:

See Also

  • Operators

  • DPL (Drive Programming Language) Reference

________________________________________________________________________________