Technical pages
Real-Time sequencer
Instructions
Use
Example
Principle
If the real time kernel developped in this system allows
the management of several tasks et different levels for the realisation
of more or less complex programms, it is often suffisant to dispose of
a simple task sequencer more easy tu debug. Moreover, the 1 millisecond
resolution, necessary in the fast systems as the current comsumption
monitoring at the output of an electronic switch, is not mandatory in a
slower system as an electrical radiator temperature regulation which
needs only a resolution of a few seconds.
The
principle is so to furnish a complementary instruction set to realize
some relatively slow functions with an easier waranty or their timing.
Those functions are some simple FORTH instructions which the running is
lauched following a table managed by only one task of the real time
kernel. The time base is a programmable number of milliseconds. The
functions are all realized at the same level as the calling task and
run in a deterministic sequential order.
Instructions
- SEQUENCE adr
Address of the variables used by the sequencer management
- T_SEQ -
Task of the sequences execution (priority level at 32768)
This instruction does not exist in the sequencer Micro FORTH kernel version
- SEQ_BEGIN[ -
Begin of a sequence table
deb_per,nbr_per SEQ_ADD "nom" -
Insertion of a sequence in a sequence table:
"nom" eis the name of the FORTH word which must be run
deb_per indicates the number of the first running period
nbr_per indicates the duration between 2 runnings
- SEQ_END] -
End of a sequence table
Use
It
is necessary to start by defining the various instructions to be run
sequentially. These instructions do not must use of input or output
parameters on the data stack as in the case of real-time kernel task
knowing that they can be called at any time according to the selected
sequencing.
The task should then be built
containing the sequential calling table using instruction “SEQ_ADD”
defining the date of the first call of each instruction (“deb_per") and
their repetition period time
("nbr_per").
It is then enough to launch
this particular task by defining its calling period in milliseconds. The task will periodically made the scanning of the
sequence table by respecting the temporal parameters of each instruction in a deterministic way.
Example
In
order to better apprehend the possibilities of the real-time sequencer,
here a simple program which uses the instructions defined in this page:
0 VARIABLE DUREE
: SEQUENCE_10ms
CR ." Seq. 10 ms " 10 TEMPO
;
: SEQUENCE_20ms
." Seq. 20 ms " 20 TEMPO
;
: SEQUENCE_30ms
." Seq. 30 ms " 30 TEMPO
;
: SEQUENCE_40ms
." Seq. 40 ms " 40 TEMPO
;
: SEQUENCE_50ms
." Seq. 50 ms " 50 TEMPO
;
: SEQ_START ( period in ms --> - )
SEQ_BEGIN[
4 1 SEQ_ADD SEQUENCE_10ms
4 3 SEQ_ADD SEQUENCE_20ms
4 3 SEQ_ADD SEQUENCE_30ms
5 3 SEQ_ADD SEQUENCE_40ms
6 3 SEQ_ADD SEQUENCE_50ms
SEQ_END]
;
1000 SEQ_START
It is about a program allowing to run 5 sequences from 10 to 50 ms every second according to the following timing:
The following screen shot is schowing the unfolding of this sequencer starting from the beginning: