Background Communication

The communication between the serial hardware and the data buffer, of type ComBuffer, is performed with the aid of a separate block, ComControl.

 

See also the Communication Principle.

 PROGRAM MAIN
VAR
    ComControl: KL6ControlBC;
    Timer: TON;
    Receive: ReceiveByte;
    Send: SendByte;
    Rb: BYTE;
    Sb: BYTE;
END_VAR
ComControl( CoMin:=KL6InData,
            CoMout:=KL6OutData,
            TxBuffer:=TxBuffer,
            RxBuffer:=RxBuffer );

Timer(IN:=TRUE,PT:=T#1S );
IF Timer.Q THEN
    IF Sb=0 THEN
        Sb:=64;
    END IF
    Sb:=Sb+1;
    IF Sb>90 THEN
        Sb:=64;
    END IF
    Send(SendByte:=Sb, TxBuffer:=TxBuffer);
    Timer(IN:=FALSE);
END IF