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

Average - Running Average

This function returns the running avergae of an input value over a desired number of samples.

Arguments

IN%

The changing integer value to be averaged.

N%

The number of samples of IN% over which the average is to be calculated. This must be a constant integer value.

Return Values

Q%

The average of IN% over N% samples.

Example

The following graph shows the value of Q% in successive calls to AVERAGE changes when a value of 1000 is passed as IN%. Each call to AVERAGE is made in the Clock task with a 5ms time-base.

Target/ Language Restrictions

None.

See Also

  • FILTER

Bcd2bin - Binary-coded Decimal to Binary Conversion

This function converts a binary coded decimal number to a normal binary integer. It is typically used to operate on digital input data from the IOBOX (for example data from thumbwheel switches).

Arguments

IN%

The BCD format value to convert.

Return Values

Q%

The binary version of IN%.

Example

To encode the decimal value 954 in a variable (X%) in BCD format, X% would need to be set to the value 2388 as shown in the following table.

9

5

4

1 0 0 1

0 1 0 1

0 1 0 0

BCD2BIN can then be used to retrieve the decimal value from X%.

Target/ Language Restrictions

None.

See Also

  • BIN2BCD

  • BCD2SEG

________________________________________________________________________________

Bin2bcd - Binary to Binary-coded Decimal Conversion

This function converts a normal binary integer to a binary coded decimal number. It is typically used to operate on digital output data to the IOBOX.

Arguments

IN%

The binary format value to convert.

Return Values

Q%

The BCD version of IN%.

Example

To encode the decimal value 954 in a variable (X%) in BCD format, X% would need to be set to the value 2388 as shown in the following table.

9

5

4

1 0 0 1

0 1 0 1

0 1 0 0

BIN2BCD can be used to convert the decimal value into BCD.

Target/ Language Restrictions

None.

See Also

  • BCD2BIN

  • BCD2SEG

________________________________________________________________________________

Bcd2seg - Binary-coded Decimal to Seven-segment Display Data

This function converts binary coded decimal to 7-segment LED codes. This function is typically used to operate on digital output data to the IOBOX.

The output will consist of three 7-segment display digit data.

The output of this function can be split into 8-bit parts, which are arranged as follows:

Bit #

7

6

5

4

3

2

1

0

Segment

-

g

f

e

d

c

b

a

The least significant byte represents the first of the three digits, the maximum value which can be converted is 999. Leading zeros will be given.

Arguments

IN%

The BCD format value to convert.

Return Values

Q%

The 7-segment display data.

Example

The following example shows how the segment codes are obtained for displaying the value 123.

Target/ Language Restrictions

None.

See Also

  • BIN2BCD

  • BCD2BIN

________________________________________________________________________________

Blkdef - Block Parameter Write

This block writes a given integer value to a consecutive set of parameters.

An example use of this block is for defaulting a PLC register menu or a sequence of menu 20 parameters.

The block can only be used with integer parameters since only an integer value can be defined. Between 1 and 99 parameters can be set in one operation. The parameters must be consecutive (i.e. in numerical order). If a problem occurs when writing to any parameter, the block will terminate at that parameter and return an error code. This block should not be used in a real-time task such as CLOCK or SPEED since it may take some time to execute.

Arguments

StrtP%

The starting parameter number in the format MMPP, e.g. the value 1811 will start writing at parameter #18.11.

NumP%

The number of consecutive parameters to be written.

Value%

The integer value to write.

Return Values

Q%

This has the value 1 if the block executed correctly and 0 if the block failed to execute.

Err%

Value

Meaning

0

OK.

1

Illegal parameter.

2

Value out of range.

3

Parameter is read-only.

Example

The following example sets parameter #20.20, #20.21 and #20.22 to the value 10.

Target/ Language Restrictions

None.

See Also

  • PFIXWRITE

  • PFIXWRITE6

________________________________________________________________________________