Emulator
step by step engines driver
FORTH mini system
Instructions
Use
Example
Principle
If the step by step engines of the
emulator are an addressable register in
the extension registers area of the FORTH core described as follows:
276 (0x114):
bits[15..7] = 0xFF8 if angle 0 (in top side)
0x000 otherwise (read only)
bit[6] = 1 to drive the index
(read/write)
bit[5] = 1 to drive the big hand
(read/write)
bit[4] = 1 to drive the little hand (read/write)
bits[3..0] = phase4,phase3,phase2,phase1
(read/write)
1 tour = 120 steps (3°/step)
The driver will allow to facilitate the use of this registes while
making
use of the real-time kernel. The principle consists in making i
possible the developer to indicate the desired position without to have to manage the engines moving.
For the FORTH mini system emulator, the bits 0 to 7 are wired on a component PCF8574A of I2C port numero 7. The electrical schematic is the following:
Instructions
- CW_MOTEUR 276
Numero of the motor
control extension register.
This instruction does not exist in the FORTH mini system,
the access to the motors is made with the instructions I2C_PCF8574A_C@ and I2C_PCF8574A_C! numero 7.
consigne MOTEUR -
Displaying of the desired position of the little hand engine.
consigne is the value of the desired position (0 minimum to 119 maximum).
consigne MOTEUR_G -
Displaying of the desired position of the big hand engine.
consigne is the value of the desired position (0 minimum to 119 maximum).
consigne MOTEUR_I -
Displaying of the desired position of the index ingine.
consigne is the value of the desired position (0 minimum to 119 maximum).
Use
The
driver not being integrated into the kernel, it is initially necessary
to compile the source file moteur_pap.txt
before being able to use it.
For the FORTH mini system emulator, it is necessary to compile firts the I2C driver described in the source file pcf8574a.txt then compile moteur_pap.txt.
The following sequence is corresponding to the displaying of 3 O clock:
30 MOTEUR
The driver manages
automaticaly the task installation which computes the shortest moving
and generate each step every 5 ms. At the first call (just after a
system initialization), a searching of the position "0" is made before
to go to the desired position. This is
realized with priority 49152.
Example
The programme of the file test_moteurs.txtbegins
with a turn in the clock direction of the little hand engine, then the
lbig hand engine, then the index and finishes by a turn in the opposite
direction of the 3 engines at the same time:
DECIMAL
0 VARIABLE ETAPE
TACHE: T_MOTEURS_PAS_A_PAS
ETAPE DUP >R @ 1 R> +! 120 /MOD DUP 3 >
IF
DROP DUP XOR DUP MOTEUR DUP MOTEUR_G MOTEUR_I T_MOTEURS_PAS_A_PAS T_RETIRE
ELSE
?DUP
IF
1- ?DUP
IF
1-
IF
>R 120 R> - DUP MOTEUR DUP MOTEUR_G MOTEUR_I
ELSE
DUP 0=
IF
0 MOTEUR_G
THEN
MOTEUR_I
THEN
ELSE
DUP 0=
IF
0 MOTEUR
THEN
MOTEUR_G
THEN
ELSE
MOTEUR
THEN
THEN
;
0 DUP MOTEUR DUP MOTEUR_G MOTEUR_I 1000 TEMPO
50 T_MOTEURS_PAS_A_PAS 32768 OVER T_AJOUTE T_PERIODE
Here is a video:
