P3964RBC
VAR_INPUT
TXstart : BOOL;
RXstart : BOOL;
Priority: BOOL;
TXcount : INT;
END_VAR
VAR_OUTPUT
Busy : BOOL;
TXbusy : BOOL;
TXready : BOOL;
RXbusy : BOOL;
RXready : BOOL;
RXcount : INT;
Error : BOOL;
ErrorID : INT;
ErrorState: STRING(80);
END_VAR
VAR_IN_OUT
TXbuffer: COMbuffer;
RXbuffer: COMbuffer;
TXdata : P3964bufferBC;
RXdata : P3964bufferBC;
END_VAR
TXstart: start signal, edge triggered
RXstart: start signal, edge triggered
Priority: 3964 priority
TXcount: number of data bytes in TxData
Busy: function block active
TXbusy: sending status
TXready: sending finished
RXbusy: receiving status
RXready: receiving finished
RXcount: number of data bytes in RxData
Error: error
ErrorID: error number
ErrorState: internal error state
TXbuffer: intermediate buffer for hardware
RXbuffer: intermediate buffer for hardware
TXdata: application data (to be sent)
RXdata: application data (received)
Connection to Hardware
The P3964RBC function block handles the 3964R protocol. The background communication, which is handled by a separate function block (KL6ControlBC, KL6Control5B) decides on the hardware interface used. The associated data buffers, Txbuffer and Rxbuffer, are passed to the P3964RBC function block.
Sending
Send data are entered into the Txdata send data buffer by the PLC. The number of data bytes entered is passed on in Txcount, and then Txstart is set to TRUE. Txstart is edge-triggered, so that before a new attempt to send is made, the function block must be called with Txstart=FALSE. While sending, Txbusy=TRUE. Once the data has been successfully transferred, Txready changes to TRUE.
Receiving
RxStart is set to TRUE to receive data. After a complete data set has been received, the Rxready output goes TRUE and Rxcount data bytes are ready in the receive data buffer Rxdata. Rxstart is also edge-triggered. While receiving, Rxbusy=TRUE.
Interrupt reception
The P3964RBC function block can be used in either send or receive mode. It is worthwhile switching the function block to receive when transmission is not taking place. As long as the function block is in receive mode, but no start character has been received from the other device, a rising edge at Txstart can interrupt the reception and initiate the sending of data. After the transfer the function block goes into its initial state (Busy=FALSE), and is only switched over to receive by a new edge at Rxstart.
Priority
In a 3964R data connection, either end may send at any time. If both ends attempt to send at the same time, there is a collision. In that case, the end with the lower priority goes into receive mode, while the end with the higher priority sends again. For this reason, when priority is low the RxReady output can be TRUE, even though data are to be sent. The data in RxData may then require evaluation. The setting of the priority at the two ends is to be agreed.
Error
In the event of an error the function block goes into its initial state (Busy=FALSE), and the Error output goes TRUE. The ErrorId returns the error code. ErrorState provides information about the state in which the error occurred when the internal protocol structure is known.