Traffic / Clock
Block Name: Clock
Code File Location: VisualSim/actor/lib/Clock
o It produces a periodic signal, a generalized square wave that sequences through N output values with arbitrary duty cycles and period.
This block produces a periodic signal, a generalized square wave that sequences through N output values with arbitrary duty cycles and period. It can also generate finite pulses by specifying a finite numberOfCycles. Once the specified number of cycles has been completed, then this block will output zeros with the same type as the values in the values parameter.
At the beginning of each time interval of length given by period, this block initiates a sequence of output events with values given by values and offset into the period given by offsets. These parameters contain arrays, which are required to have the same length. The offsets array contains doubles, which must be nondecreasing and nonnegative (exception generated). Moreover, its largest entry must be smaller than period (exception generated).
The values parameter by default contains an array of IntTokens with values 1 and 0. The default offsets array is {0.0, 1.0}. Thus, the default output will be alternating 1 and 0 with 50% duty cycle. The default period is 2.0.
The block generates at the beginning of each period plus each of the offsets. It may in addition generate at any time in response to a trigger input. On such generations, it simply repeats the most recent output (or a new output value, if the time is suitable.) If the block is triggered before the first offset has been reached, then a zero value of the same data type as those in the values array is produced.
The clock waveform is a square wave (in the sense that transitions between levels are discrete and the signal is piecewise constant), with N levels, where N is the length of the values parameter. Changes between levels occur at times nP + oi where n is any nonnegative integer, P is the period, and oi is an entry in the offsets array.
The type of the output can be any token type. This type is inferred from the element type of the values parameter.
Refer Clock Demo Model.
Parameter |
Explanation |
Type |
Example |
stopTime |
The stop time of the model. |
Integer |
Infinity |
period |
The period of the output waveform. |
Double |
2.0 |
offsets |
The offsets at which the specified values will be produced. |
Array |
{0.0, 1.0} |
values |
The values that will be produced at the specified offsets. |
Array |
{1, 0} |
numberOfCycles |
The number of cycles to produce, or -1 to specify no limit. |
Integer |
-1 |
Port |
Explanation |
Type |
Output |
At every rising and trailing edge a value is output on this port for example 1 or 0; |
Integer |
Period |
This input port is used to define the period of the output waveform. This is an optional port and the block can be used without the period value. |
Double |
trigger |
This input port is used to start the generation of events from this block. This is an optional port and the block can be used without the input trigger. |
Any value |
Created with the Personal Edition of HelpNDoc: Easily create PDF Help documents