Appendix
30
BC8000
Receiving
FOR i3:=0 TO 5 DO
Summe:=Summe+ senden[i3];
END_FOR
(*------------------------- TRANSMIT SENDEN ----------------------------------------*)
FOR J0:=0 TO 6 DO
IF J0<4 THEN
Sb := senden[J0]; (* values from the ARRAY *)
ELSIF J0=4 THEN
Sb:=senden[J0];
(* D0 as counter from 0 to 255 *)
ELSIF J0=5 THEN
Sb:= senden[J0]; (* D1 is here &HFF *)
ELSIF J0=6 THEN
sb:=Summe;
(* checksum *)
END_IF
Send(SendByte:=Sb , TxBuffer:=TxBuffer );
END_FOR
(*------------------------- COUNTER -----------------------------------------------------*)
i2:=i2+1;
IF i2>255 THEN
i2:=0;
END_IF
senden[4]:=i2;
Starten:=FALSE;
END_IF
(*------------------------RECEPTION-----------------------------------------------*)
REPEAT
Receive(RxBuffer:= RxBuffer);
IF Receive.ByteReceived THEN (* waits until data have arrived *)
byAusgang1[t1]:= Receive.ReceivedByte;
byausgang1[t1];
IF byAusgang1[0]<>16#70 THEN(* If the start marker is not *)
(* recognized, the program exits the loop *)
EXIT;
END_IF
EingWorte:=byAusgang1[1];
t1:=t1+1;
END_IF
UNTIL rxBuffer.count = 0
END_REPEAT
IF (T1>5+2*EingWorte) THEN
T1:=0;
END_IF
byAusgang0:=ROL(ByAusgang1[5],byEingang0);
Global variables
VAR_GLOBAL
(* Address 500 is the emulation terminal
*)
(* where %500=status, %501=D0, %502=D1, %503=D2, *)
(* %504=D3, %505=D4 *)
Kl6InData
AT %IB500
: KL6inData5B;
Kl6OutData
AT %QB500
: KL6outData5B;
RxBuffer
: ComBuffer;
TxBuffer
: ComBuffer;
byAusgang0 AT %QB6: BYTE; (* 2 x KL2114 *)
byEingang0 AT %IB6:BYTE; (* 1 x KL1104 *)
END_VAR