Rollover Counter

Rollover Counter sample block (not recommended)


Simulink® Real-Time™ Library of Drivers No Longer Recommended for Use.

To open this library, type xpcobsoletelib in the Command Window.


This block counts the number of times the output of an encoder block has rolled over. It counts up for positive direction rollovers and down for negative direction rollovers.

Block Parameters

Encoder Starting Value

Enter the starting value you want the encoder block to begin with. Match this value to the value in the encoder mask.

Rollover Threshold

Enter a rollover threshold value. To determine when a rollover has occurred, the model compares two consecutive encoder outputs and looks for a large jump. A large jump indicates a register overflow.

The threshold you enter defines a large jump. The smaller the threshold, the more likely the model will misinterpret a jump in successive encoder counts as a rollover. The larger the threshold, the more likely the model will not detect a rollover. Ideally, choose a number that is half the size of the register (for example, 2^(n-1)), where n is the size of the register in bits.

Was this topic helpful?