文档

Counter Limited

Count up and wrap back to zero after outputting specified upper limit

Library

Sources

Description

The Counter Limited block counts up until the specified upper limit is reached. Then the counter wraps back to zero, and restarts counting up. The counter always initializes to zero.

You can specify the upper limit with theUpper limitparameter.

You can specify the sample time with theSample timeparameter. ASample timeof-1means that the sample time is inherited.

The output is an unsigned integer of 8, 16, or 32 bits, with the smallest number of bits needed to represent the upper limit.

This block does not report wrap on overflow warnings during simulation. To report these warnings, see theSimulink.restoreDiagnosticreference page. The block does report errors due to wrap on overflow.

Data Type Support

The Counter Limited block outputs an unsigned integer.

For more information, seeData Types Supported by Simulinkin the Simulink®documentation.

Parameters

Upper limit

Specify the upper limit.

Sample time

Specify the time interval between samples. To inherit the sample time, set this parameter to-1. SeeSpecify Sample Timein the Simulink documentation.

Examples

The following Simulink examples show how to use the Counter Limited block:

Characteristics

Data Types

Boolean | Base Integer | Fixed-Point

Sample Time

Specified in theSample timeparameter

Multidimensional Signals

No

Variable-Size Signals

No

Code Generation

Yes

Introduced before R2006a

Was this topic helpful?