LGF_CountRisInDWord (FC / V3.0.1)


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

IdentifierData typeDescription
dWordActCycleDWordInput Double word in which the rising edges are counted
dWordPrevCycleDWordDouble word from the previous cycle

Output parameter

IdentifierData typeDescription
Ret_ValIntNumber 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

LGF_CountFalRiseInDWord - 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 & DateChange description
01.00.00Siemens Industry Online Support
19.08.2015First released version
01.00.01Siemens Industry Online Support
02.01.2017Upgrade: TIA V14 Update 1
01.00.02Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.00.03Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
03.00.01Simatic Systems Support
12.11.2020Insert documentation and LEGACY Hint
Please use the FB with the same name `LGF_CountRisInDWord` in the future