Session 7: What is this Event
Clock?
We have seen that an Event Clock is an essential element of any Scicos
diagram. Contrary to what it may seem, an Event Clock is not a Basic Scicos
block. It is a compiled Super Block. In many respects, a compliled Super
Block resembles a Basic block, that is why we use the term block or Scicos
block to designate both of them.
So far we have seen that a Basic block can generate output activation
signals, we have in particular seen the case of Synchro blocks. The output
activation signal of a Synchro block is not delayed with respect to its
activation time (i.e. when it is activated by an event, it generates an
event without delay; it just routes the event). But Baisc blocks in Scicos
can also generate delayed events. It is exactly this feature which is used
to construct an Event Clock.
Construct the following diagram
by copying blocks from the palettes
The Delay
block (or more specifically the event delay block) is found in the Events
palette.
Constructing an event clock using basic blocks
The Delay block
has two parameters. The first one determines the delay between the incoming
and the outgoing event, and the second determines the initial event firing
(prescheduled). If the initial firing time is set to a negative value,
then the block does not initially generate an event. This of course would
mean that in the above situation, the diagram remains frozen in time. In
other situations however, no presecheduling of output event may be
desirable.
Set block parameters (delay=1
and initial firing time=5) and simulate
The result
is the following. Note that the looped-back Delay
block behaves just like an Event
Clock.
The Event Scope display
Now let us construct a block from our event clock.
Modify the diagram as follows
This diagram cannot be simulated
The above diagram is not a Scicos diagram, it is more like the inside of
a Super Block. But our intention here is not to simulate but to convert
this into to a block, i.e., to compile the Super Block.
Save as Interfacing
(GUI) function under the name myclk
This can be done using
the Save as Interf. Func.
in the Diagram
menu.
Each block in Scicos has
an Interfacing (or GUI) function. This Scilab function determines all the
properties of the block (size, color, parameters, user interface, initial
condition,...) and the name of the computational
function which defines the mathematical properties
of the block (for example it computes the output from the input). The computational
function is usually written in C or fortran for simulation efficiency,
but it can also be written in Scilab. The interfacing function is
always a Scilab function.
Saving the diagram, as an
Interfacing function, creates the interfacing function associated with
a block which would include the diagram. The number of inputs and outputs
of the block are determined by the number of input output ports in the
diagram (both regular and activation), etc...
Load the new block in an empty
diagram
Use
the button Add new block
of the Edit
menu.
This is a custom made event clock
The parameters of a compiled Super Block block are just the union of all
the parameters of the blocks within it. When compiling the Super Block,
the Interfacing function is generated in such way that when the block is
clicked upon after open/set, the parameters of the blocks within the Super
Block can be set one after the other. In some cases that can be tedious.
To customize the user interface, the Interfacing function should be edited
manually.
Ready to go on?
For more information about Scicos, send an e-mail to Doctor Scilab:
Scilab@inria.fr
For suggestions about this Web server, send an e-mail
to Scilab@inria.fr