Main Content

Counter Limited

Count up and wrap to zero after specified upper limit

  • Counter Limited block

Libraries:
Simulink / Sources
HDL Coder / 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.

Note

This block does not report wrap on overflow warnings during simulation. To report these warnings, see the Simulink.restoreDiagnostic reference page. The block does report errors due to wrap on overflow.

Ports

Output

expand all

Count value, returned as an unsigned integer of 8 bits, 16 bits, 32 bits, 64 bits, or ufix128. The block uses the smallest number of bits required to represent the upper limit.

Data Types: uint8 | uint16 | uint32 | uint64 | fixed point

Parameters

expand all

Specify the upper limit for the block to count to as a finite, real-valued scalar.

Programmatic Use

Block Parameter: uplimit
Type: character vector
Values: scalar
Default: '7'

Specify the time interval between samples as a scalar (sampling period), or a two-element vector (sampling period, initial offset). To inherit the sample time, set this parameter to -1. For more information, see Specify Sample Time.

Programmatic Use

Block Parameter: tsamp
Type: character vector
Values: scalar | vector
Default: '-1'

Block Characteristics

Data Types

Boolean | fixed point | integer

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a