User`s guide
Counter
5-106
parameter setting. When the counter value does equal the Hit value setting, 
the block generates a value of 
1 at the Hit port. The output is sample-based 
with the same sample period as the inputs.
•
Count and Hit configures the block icon with both ports. 
Frame-Based Operation
The block operates in frame-based mode when the Clk input is a frame-based 
vector (i.e., single channel). Multichannel frame-based inputs are not accepted.
Frame-based operation is the same as sample-based operation, except that the 
block increments or decrements the counter by the total number of trigger 
events contained in the 
Clk input frame. A trigger event that is split across two 
consecutive frames is counted in the frame that contains the conclusion of the 
event. When a trigger event is received at the 
Rst port, the block first resets the 
counter, and then increments or decrements the counter by the number of 
trigger events contained in the 
Clk frame. 
The 
Cnt and Hit outputs are sample-based scalars with sample period equal to 
the 
Clk input frame period.
Free-Running Operation
The block operates in free-running mode when Free running is selected from 
the 
Count event menu. 
The 
Clk input port is disabled in this mode, and the block simply increments or 
decrements the counter using the constant sample period specified by the 
Sample time parameter, T
s
. The Cnt output is a frame-based M-by-1 matrix 
containing the count value at each of M consecutive sample times, where M is 
specified by the 
Samples per output frame parameter. The Hit output is a 
frame-based M-by-1 matrix containing the hit status (
0 or 1) at each of those M 
consecutive sample times. Both outputs have a frame period of M
∗T
s
.
Example In the model below, the Clk port of the Counter block is driven by Simulink’s 
Pulse Generator block, and the 
Rst port is triggered by an N-Sample Enable 
block. All of the Counter block’s inputs and outputs are multiplexed into a 
single To Workspace block using a 4-port Mux block.










