1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| uses
DLPortOCXControl1_TLB // dll installee
// port selectionne
AB : integer; {adresse du port parallèle sélectionné}
AB := $378;
// initialisation
{ouverture du driver port parallele}
DLPortOCX1.OpenDriver;
{initialisation du port parallele a zero}
DLPortOCX1.WritePort(AB, 0);
// teste arret urgence
{Vérifie si les butées sur les Chariots X, Y, Z sont activées}
repeat
n1 := DLPortOCX1.ReadPort(AB + 1);
n2 := DLPortOCX1.ReadPort(AB + 1);
until (n1 = n2);
procedure TForm1.deplacement
(choix_moteur, choix_sens : integer; tempo : word; choix_pas : integer);
var
{ Thread }
inc_x, inc_y, inc_z : integer;
begin
moteur := choix_moteur;
sens := choix_sens;
attente := trunc(tempo);
pas := choix_pas;
inc_x := 0; inc_y := 0; inc_z := 0; inc_pas := 0;
{Tri pour déterminer le sens de rotation de chaque moteur}
case choix_moteur of mx,mx+my,mx+mz,mx+my+mz :
begin
case choix_sens of sx,sx+sy,sx+sz,sx+sy+sz : inc_x := 1; end;
case choix_sens of 0,sy,sz,sy+sz : inc_x := -1; end;
end;
end;
case choix_moteur of my,my+mx,my+mz,my+mx+mz :
begin
case choix_sens of sy,sy+sx,sy+sz,sy+sx+sz : inc_y := 1; end;
case choix_sens of 0,sx,sz,sx+sz : inc_y := -1; end;
end;
end;
case choix_moteur of mz,mz+mx,mz+my,mz+mx+my :
begin
case choix_sens of 0,sx,sy,sx+sy : inc_z := 1; end;
case choix_sens of sz,sz+sx,sz+sy,sz+sx+sy : inc_z := -1; end;
end;
end; {Sélections des sens de rotations}
repeat {Mise en rotation des moteurs}
DLPortOCX1.WritePort(AB, choix_sens);
DLPortOCX1.WritePort(AB, choix_sens + choix_moteur);
Sleep(1);
DLPortOCX1.WritePort(AB, 0);
total_inc_x := total_inc_x + inc_x;
total_inc_y := total_inc_y + inc_y;
total_inc_z := total_inc_z + inc_z;
inc(inc_pas);
Application.ProcessMessages;
until (inc_pas = choix_pas) or (aru = true);
end;
// fermeture
{initialisation a zero du port parallele}
DLPortOCX1.WritePort(AB, 0);
{fermeture du driver port parallele} |
Partager