IsReceptionDoneByTimeOut

Evaluate "reception done" condition by timeout

This function block evaluates a timeout condition to detect the end of reception in data streams not containing an end code, e.g. when transferring binary data.

Parameters

Input

Port (WORD, INT, UINT)

Specifies the communication ports depending on the PLC type:

  • COM port e.g. SYS_COM0_PORT

  • Ethernet port e.g. SYS_ETHERNET_USER_CONNECTION_1

  • MCU/SCU e.g. 16#xx01 (xx = slot number) in COM01

TimeOutForCPU (TIME)

Time after which IsDone is set to TRUE if no further data is received.

NoOfBytesReceived (WORD, INT, UINT)

Applies to the starting address of the receive buffer. This address contains the number of bytes received. (CPU only)

Output

IsDone (BOOL)

Set to TRUE, if one or more bytes have been received and the number of bytes received has not changed within the time specified at TimeOutForCPU or in the "MCU Setting" dialog.

Remarks

For the communication port of a CPU, the first word of the receive buffer must be applied at NoOfBytesReceived (number of bytes received). If the number of bytes received does not change within the time specified at TimeOutForCPU, IsDone turns to TRUE.

For a Multi-Communication Unit and for FP7, the "reception done" flag is evaluated. The timeout must be set in PROG mode using the “MCU Setting” dialog or in RUN mode using F159_MWRT_PARA (FP2 only).

Evaluation of the "reception done" flag

When for the specified time no further bytes are received or the instruction ClearReceiveBuffer is performed, the IsDone output turns to TRUE. Reception of any further data is prohibited. F159_MTRN or ClearReceiveBuffer turns the "IsDone" flag to FALSE.

The end of reception can also be determined by checking the contents of the receive buffer (e.g. the number of received bytes). The number of received bytes may change while a scan is being carried out. For example, if the number of received bytes is read more than once different statuses may exist within one scan.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		IsReceptionDone1: IsReceptionDoneByTimeOut;
	END_VAR
	VAR_EXTERNAL
		g_awReceiveBuffer: ARRAY [0..10] OF WORD;
	END_VAR
	VAR 
		bIsRecDone1: BOOL:=FALSE;
		wPort: WORD:=0;
	END_VAR

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_FB,IsReceptionDoneByTimeOut!,IsReceptionDone1,11,1,24,6,,?BPort?BTimeOutForCPU?BNoOfBytesReceived?AIsDone);
B(B_VARIN,,wPort,9,2,11,4,);
B(B_VARIN,,T#20ms,9,3,11,5,);
B(B_VAROUT,,IsRecDone1,24,2,26,4,);
B(B_VARIN,,g_awReceiveBuffer[0],9,4,11,6,);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IsReceptionDone1(Port := wPort,
                 TimeOutForCPU := T#20ms,
                 NoOfBytesReceived := g_awReceiveBuffer[0],
                 IsDone => bIsRecDone1);

Modified on: 2022-01-14Feedback on this pagePanasonic hotline