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

Numbers

The following number formats are supported:

  • Decimal Numbers

  • Hexadecimal Numbers

  • Floating-point Numbers

Decimal Numbers

Decimal numbers are specified in the format:

[-]NNNNNNNNN

where N is a decimal digit (0 to 9). Examples are:

1

-1

345

The range for decimal numbers is -2147483648 to 2147483647.

Hexadecimal Numbers

Hexadecimal numbers are specified in the format:

0xCCCCCCCC

where C is a hexadecimal digit (0 to F). Examples are:

0x01

0xFFFFFF

The range for decimal numbers is 0x0 to 0xFFFFFFFF.

Floating-point Numbers

Floating-point numbers are specified in the format:

[-]NNN.NNN[eE][+/-]NNN

where N is a decimal digit (0 to 9). Examples are:

1.0

-1.3

1234.456789e12

1.34E12

32.0e-4

The range for double-precison floating-point numbers is approximately +/-1.7976931348623158e+308. The range for double-precison floating-point numbers is approximately +/-3.402823466e+38F.

Note:

DPL programs can access Predefined Variables giving the numeric limits of integer and floating-point variables.

See Also

  • Variables, Parameters, Constants and Data Types

  • Data Types

________________________________________________________________________________

Variable and Parameter Scope

Each kind of data has a defined scope (or visibility) within a programs. The different kinds of scope are:

  • Local Variables

  • Global Variables

  • Parameters and PLC Registers

Local Variables

Local variables are used only in user defined function blocks (UDFB). They are copied for each function block instance and exist 'local' to that particular instance. As such, the same symbol can be used for local variables in different function blocks. User defined function blocks cannot access variables defined in tasks and subroutines.

Global Variables

A global variable is one which has 'global' scope with all the tasks within a node program. All variables used in a DPL program with the exception of user defined function blocks are global. For example, this means that if a variable called MyVar% is used in the background task then the value of MyVar% can be read or changed in any other task, e.g. the clock task, or in a subroutine. MyVar% cannot be accessed by a user-defined function block.

Parameters and PLC Registers

All parameters (#MM.PP) and PLC registers are globally accessible in a user program. For example #1.21 can be accessed in the background task, a subroutine and in a user-defined function block.

Note:

The use of parameters and PLC registers inside user-defined function blocks is discouraged since it may make the function block less portable to another program on another platform.

See Also

  • Variables, Parameters, Constants and Data Types

  • Variables

  • Parameters

  • PLC Registers

  • Program Structure

________________________________________________________________________________

Aliases

Within the DPL language, a program can contain one or several 'List of Aliases' sections. Each one contains $define directives that define correspondence (alias) between symbols and user-defined text. The naming conventions for aliases are the same as those for variables.

In node DPL programs, aliases are used to replace various expressions:

  • A numerical constant expression.

  • The address of a register.

  • A DPL expression or statement.

The following example shows each type of alias representation:

$define NULL

0

(integer expression)

$define EPSILON

0.01

(floating point expression)

$define SPEED

#3.02

(register address)

$define TOTAL

(#3.02 + Offset)

(DPL expression)

$define WAIT

do while (#3.02 < 0) loop

(DPL statement)

An alias must be defined before it is used. It is recommended that aliases are placed at the top of a program. To improve the readability of a program, it is recommended you should type alias names in upper case letters and place them within an Alias section as follows:

In this example, the code in the Background task is equivalent to:

Note:

Aliases are non-recursive, i.e. one alias cannot contain a reference to another alias.

See Also

  • Variables, Parameters, Constants and Data Types

  • Variables

  • Program Structure

_______________________________________________________________________________