Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

// Source code for CASE 721 B transmission

// Author: Keiso Callejas


// Country: Bolivia
// CPU: At89c51@12.000Mhz
// Compiler: Turbo51

Program Mando;

Const
F_FIRST = 28;
F_SECOND = 24;
F_THIRD = 8;
F_QUIRT = 1;
NEUTER = 0;
R_FIRST = 22;
R_SECOND = 18;
R_THIRD = 2;

Var
Forward: Boolean absolute P1.0;
Reverse: Boolean absolute P1.1;
INC: Boolean absolute P1.2;
DEC: Boolean absolute P1.3;
S_ENABLE: Boolean absolute P2.0;
R_ENABLE: Boolean absolute P2.1;

Gear: Integer;
auxGear: Integer;
Inf: Boolean;
PUSH: Boolean;
INTRO: Boolean;
//asim: array[0..15] of char;

Procedure DelayTime(VAR_XX, VAR_YY, VAR_ZZ: Byte);


begin
Asm
MOV R2,VAR_XX
@BUCLE3: MOV R1,VAR_YY
@BUCLE2: MOV R0,VAR_ZZ
@BUCLE1: DJNZ R0,@BUCLE1
DJNZ R1,@BUCLE2
DJNZ R2,@BUCLE3
end;
End;

Begin
P3:= 0;
Inf:= False;
P0:= 0;
Gear:= 0;
P1.4:= False;
P1.5:= False;
P1.6:= False;
P1.7:= False;
P2.0:= True;
P2.1:= False;
P2.2:= False;
P2.3:= False;
P2.4:= False;
P2.5:= False;
P2.6:= False;
P2.7:= False;

// S_ENABLE:= False;
// R_ENABLE:= False;

Repeat
P3:= Gear;
P2:= auxGear;
Gear:= Gear + 1;
DelayTime(50,50,10);
Until Gear > 4;

Gear:= 0;
P3:= Gear;

Repeat
If not Forward Then
Begin
If Gear = 0 then Gear:=1;
If (auxGear > -3 ) and (auxGear < 0) Then Gear := auxGear * (-1);
S_ENABLE:= True;
R_ENABLE:= False;
If not INC Then
If Gear < 4 Then
Begin
Gear:= Gear + 1;
INTRO:= True;
DelayTime(50,50,10);
end;

If not DEC Then


If Gear > 1 Then
Begin
Gear:= Gear - 1;
INTRO:= True;
DelayTime(50,50,10);
end;
end;

If not Reverse Then


Begin
If Gear = 0 then Gear:=-1;
If (auxGear < 3) and (auxGear > 0) Then Gear := auxGear * (-1);
S_ENABLE:= True;
R_ENABLE:= True;
If Gear > -3 Then
If not INC then
Begin
Gear:= Gear - 1;
INTRO:= True;
DelayTime(50,50,10);
end;
If Gear < -1 Then
If not DEC then
Begin
Gear:= Gear + 1;
INTRO:= True;
DelayTime(50,50,10);
end;
end;

If Reverse and Forward Then


Begin
Gear:= 0;
S_ENABLE:= False;
R_ENABLE:= False;
DelayTime(50,50,10);
end;
If Gear <> 0 Then
auxGear:= Gear;
P3:= Abs(Gear);

Case Gear of
-1: P0:= R_FIRST;

-2: P0:= R_SECOND;

-3: P0:= R_THIRD;

0: P0:= NEUTER;

1: P0:= F_FIRST;

2: P0:= F_SECOND;

3: P0:= F_THIRD;

4: P0:= F_QUIRT;

end;

If INTRO = True Then


Begin
Repeat
If (not INC) or (not DEC) = True Then
Begin
PUSH:= True;
INTRO:= False;
DelayTime(50,50,10);
end
Else PUSH := False;
Until PUSH = False;
end;

Until Inf = True;


End.

You might also like