Rollover Counter sample block
Simulink® Real-Time™ Library for Rollover
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.
Enter the starting value you want the encoder block to begin with. Match this value to the value in the encoder mask.
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,
n is the size of the register in bits.