Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
159
Добавлен:
11.10.2020
Размер:
2.81 Mб
Скачать

Appendix B: - Operands in CoDeSys

END_STRUCT

END_TYPE

Declaration in POU:

VAR x:stru1; END_VAR

Bitaccess:

x.enable:=true;

This will set TRUE the 42. bit in variable x. Since bvar has 8 bits and rvar has 32 bits, the bitaccess will be done on the second bit of variable wvar, which as a result will get value 4.

Attention: If a variable, which does a bitaccess on a structure variable with the aid of a global constant, should be displayed correctly in the input assistant, at monitoring in the declaration window and in the intellisense function, please use pragma {bitaccess} as shown in the example. Then in addition you get displayed the global constant beyond the respective structure variable during monitoring in the declaration window:

10.12 Addresses

Address

The direct display of individual memory locations is done through the use of special character sequences. These sequences are a concatenation of the percent sign "%", a range prefix, a prefix for the size and one or more natural numbers separated by blank spaces.

The following range prefixes are supported:

I Input

Q Output

M Memory location

The following size prefixes are supported:

X Single bit

None Single bit

B Byte (8 Bits)

W Word (16 Bits)

D Double word (32 Bits)

CoDeSys V2.3

10-29

 

Appendix B: - Operands in CoDeSys

Examples:

 

%QX7.5 and

Output bit 7.5

%Q7.5

 

%IW215

Input word 215

%QB7

Output byte 7

%MD48

Double word in memory position 48 in the memory location.

%IW2.5.7.1

depending on the PLC Configuration

The current PLC Configuration for the program determines whether or not an address is valid.

Note: Boolean values will be allocated bytewise, if no explicit single-bit address is specified. Example: A change in the value of varbool1 AT %QW0 affects the range from QX0.0 to QX0.7.

see also Chapter Appendix A: IEC Operators and additional norm extending functions, address operators

Memory location

You can use any supported size to access the memory location.

For example, the address %MD48 would address bytes numbers 192, 193, 194, and 195 in the memory location area (48 * 4 = 192). The number of the first byte is 0.

You can access words, bytes and even bits in the same way: the address %MX5.0 allows you to access the first bit in the fifth word (Bits are generally saved wordwise).

see also Appendix A: IEC Operators and additional norm extending functions, address operators

10.13 Functions

In ST a function call can also appear as an operand.

Example:

Result := Fct(7) + 3;

TIME()-Function

This function returns the time (based on milliseconds) which has been passed since the system was started.

The data type is TIME.

Example in IL:

TIME

ST systime (* Result e.g.: T#35m11s342ms *)

Example in ST:

systime:=TIME();

Example in FUP:

10-30

CoDeSys V2.3

Соседние файлы в папке 759-333