3964R

3964R 1:

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.

3964R 2: 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

TXstart is edge-triggered, so that before a new attempt to send is made, the function block must be called with TXstart=FALSE. If TXstart is then set to TRUE, this starts the transmission attempt.

RXstart

BOOL

RXstart is edge-triggered. RXstart is set to TRUE to receive data.

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 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.

TXcount

INT

The entered number of data bytes is transferred to TXcount.

3964R 3: 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

P3964buffer

Send data are entered into the send data buffer TXdata by the PLC.

RXdata

P3964buffer

RXcount data bytes are available in the receive data buffer RXdata.

TxBuffer

ComBuffer

Buffer with send data for the serial hardware being used.

RxBuffer

ComBuffer

Buffer into which received data is placed.

3964R 4: 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 (Busy=FALSE).

TXbusy

BOOL

While sending, TXbusy=TRUE.

TXready

BOOL

Once the data has been successfully transferred, TXready=TRUE.

RXbusy

BOOL

While receiving, RXbusy=TRUE.

RXready

BOOL

After a complete data set has been received, the output is RXready=TRUE.

RXcount

INT

RXcount data bytes are available in the receive data buffer RXdata.

Error

BOOL

In the event of an error, the output is Error=TRUE and the function block goes into the initial state (Busy=FALSE).

ErrorID

P3964R_Error_t

The ErrorID returns the error code.

ErrorState

STRING

ErrorState provides information about the state in which the error occurred when the internal protocol structure is known.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4012

PC or CX (ARM, x86, x64)

Tc2_SerialCom