# LGF_CountRisInDWord (FC / 3.0.1)

Overview

Author: Siemens Digital Industry Support

## Short description

The function analyzes a variable of the type DWORD and outputs how often a 0-1 sequence (rising edge) occurs in the variable.

NOTE
  LEGACY FUNCTION
  Please update and use the FB with the same name `LGF_CountRisInDWord` in the future!
  This function is no longer maintained!

### Block Interface

| LGF_CountRisInDWord (FC) |
--- | --- | ---
DWord |  |  | dWordActCycle |  | Ret_Val |  |  | Int
DWord |  |  | dWordPrevCycle |  |  |  |  |

### Input parameter

Identifier | Data type | Description
--- | --- | ---
dWordActCycle | DWord | Input Double word in which the rising edges are counted
dWordPrevCycle | DWord | Double word from the previous cycle

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Int | Number of rising edges in the DWord

## Functional description

In a variable of the data type DWORD, the block counts the rising edges (0-1 transitions) from left to right. The output `countRisInDWord` outputs the number of rising edges.

So that rising edges at the variable limit are also detected, the input `value` is copied to the static variable `statDWordPrevCycle` at the end of the evaluation and evaluated in the next cycle.

### Example

The following example illustrates the block’s functionality. In this case, it is assumed that a signal of unknown length is continuously sampled in the form of double words (DWORD) per cycle.

Within this signal, the 0-1 sequences (rising edges) must be counted and output continuously. To detect the rising edge on variable limits, as in this example, the input “statDWordPrevCycle” must be interconnected with the double word of the previous sampling.

Table: Example

DWord previous cycle `statDWordPrevCycle` | DWord actual cycle `value`
--- | ---
1001_0000_0001_1010_1001_0000_0001_1010 | 1010_1010_0001_1111_0100_0011_1000_0101

Number of 0-1 sequences (rising edges): `Ret_Val` = 9

### Application example:

Excerpt from the manual of the technology module TM Timer DIDQ 16x24V:

With the oversampling function, the technology module records the state of the respective digital input per application cycle (e.g. OB61) at 32 points in time with a uniform time interval. The 32 states are jointly returned as 32-bit values in the checkback interface.

Figure: Example of an oversampling of DI0 on TM Timer DIDQ 16x24V

The block LGF_CountRisInDWordFB is used in this case to count how often a rising edge occurs.

SIMATIC ET 200MP/S7-1500 Technology Module TM Timer DIDQ 16x24V
(6ES7552-1AA00-0AB0)
https://support.industry.siemens.com/cs/ww/en/view/95153313

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 19.08.2015 | First released version
| 1.0.1 | Siemens Industry Online Support
| 02.01.2017 | Upgrade: TIA V14 Update 1
| 1.0.2 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 1.0.3 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 3.0.1 | Simatic Systems Support
| 12.11.2020 | Insert documentation and LEGACY Hint Please use the FB with the same name `LGF_CountRisInDWord` in the future