3964R

The function block P3964R
handles the 3964R protocol. The background communication, which is handled by a separate function block SerialLineControl decides on the hardware interface used. The associated data buffers TxBuffer
and RxBuffer
(of type ComBuffer) are transferred to the function block P3964R.
Sending
Send data are entered into the send data buffer TXdata
by the PLC. The number of data bytes entered is passed on in TXcount
, and then TXstart
is set to TRUE. While sending, TXbusy=TRUE
. Once the data has been successfully transferred, TXready=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
. While receiving, RXbusy=TRUE
.
Interrupt reception
The function block P3964R
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 remote terminal, 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, each remote terminal 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 output RXready=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.
Inputs
VAR_INPUT
TXstart : BOOL; (* start signal, edge-triggered *)
RXstart : BOOL; (* start signal, edge-triggered *)
Priority : BOOL; (* 3964 priority, TRUE=high, FALSE=low *)
TXcount : INT; (* number of data bytes in TxData *)
END_VAR
Name | Type | Description |
---|---|---|
TXstart | BOOL |
|
RXstart | BOOL |
|
Priority | BOOL | In a 3964R data connection, each remote terminal 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 output |
TXcount | INT | The entered number of data bytes is transferred to |
Inputs/outputs
VAR_IN_OUT
TXdata : P3964buffer; (* application data (to send)*)
RXdata : P3964buffer; (* application data (received)*)
TxBuffer : ComBuffer; (* buffer between protocol software and terminal *)
RxBuffer : ComBuffer; (* buffer between protocol software and terminal *)
END_VAR
Name | Type | Description |
---|---|---|
TXdata | Send data are entered into the send data buffer | |
RXdata |
| |
TxBuffer | ComBuffer | Buffer with send data for the serial hardware being used. |
RxBuffer | ComBuffer | Buffer into which received data is placed. |
Outputs
VAR_OUTPUT
Busy : BOOL; (* block is active *)
TXbusy : BOOL; (* send state *)
TXready : BOOL; (* send completed, data were transferred *)
RXbusy : BOOL; (* receive state *)
RXready : BOOL; (* receive completed, data were transferred *)
RXcount : INT; (* number of data bytes in RxData *)
Error : BOOL; (* error *)
ErrorID : P3964R_Error_t; (* error id *)
ErrorState : STRING(80); (* internal error state *)
END_VAR
Name | Type | Description |
---|---|---|
Busy | BOOL | After the transfer, the function block switches to the basic state ( |
TXbusy | BOOL | While sending, |
TXready | BOOL | Once the data has been successfully transferred, |
RXbusy | BOOL | While receiving, |
RXready | BOOL | After a complete data set has been received, the output is |
RXcount | INT |
|
Error | BOOL | In the event of an error, the output is |
ErrorID | P3964R_Error_t | The |
ErrorState | STRING |
|
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4012 | PC or CX (ARM, x86, x64) | Tc2_SerialCom |