PS Counter
Increment output signal by 1 with every time step
Libraries:
Simscape /
Foundation Library /
Physical Signals /
Sources
Description
The PS Counter block increments the output signal, Y, by 1 with every time step repeatedly between the minimum (reset) value and the maximum value. You can optionally specify an initial signal value, different from the reset value, and an initial time offset. The output signal generated by the block is shown in the following diagram.
If the initial time offset is specified, the block outputs the initial signal value
init
until the simulation time reaches the
offset
value, at which point the counting cycle starts. The block
outputs the current value for one time step, then repeatedly increments the signal value by 1
and outputs it for one time step, until it reaches the maximum value
max
. The block outputs the max
value
for one time step, then returns to the reset
value, and the
counting cycle starts again.
Use this block, in conjunction with other physical signal blocks, to model discrete behaviors.
The Discrete-Time PWM Voltage Source example illustrates how you can use the PS Counter block to build components with more complex behaviors. For an alternative asynchronous implementation, see the Asynchronous PWM Voltage Source example. The discrete-time version is better suited to fixed-step solvers and hardware-in-the-loop applications, whereas the asynchronous implementation is better suited to fast desktop simulation using variable-step solvers.