Function Description

The INPUT_CHAR_QX function is used to receive a character string from a serial device connected to a Modicon X80 serial communication module (BMX NOM) located in an EIO drop.

The message received is stored in a character string.

The additional parameters EN and ENO can be configured.

NOTE: The INPUT_CHAR_QX function works with a Modicon M340 BMX NOM 0200 module with a firmware version SV: 1.4 or later. With an earlier firmware version, an error (STATUS = 16#3301) is raised.

The communication function blocks use one data transaction path and require multiple cycles to complete an operation. The number of transaction paths available by module and by MAST cycle depends on the communication port used:

  • Modbus Plus embedded port or NOM modules support up to 4 blocks at the same time.

  • TCP/IP Ethernet embedded port support up to 4 blocks at the same time.

  • TCP/IP Ethernet NOE, NOC, and 140 CRP 312 00 modules support up to 16 blocks at the same time.

More communication function blocks may be programmed on the same communication port. However, a communication block exceeding the maximum number on that port is not serviced until one of the transaction paths is available. Then, the next block on the same port becomes active and begins using an available path.

FBD Representation

Representation:

LD Representation

Representation:

IL Representation

Representation:

CAL INPUT_CHAR_QX_Instance (ENABLE:=InputCharEnable, ABORT:=InputCharAbort, ADDR:=ModuleAddress, RESET_BUF:=ResetInputBuffer, INPUT_LEN:=NbCharToRead, DONE=>InputCharSuccessfull, ACTIVE=>InputCharActive, ERROR=>InputCharFaulty, STATUS=>ErrorCode, REC_LEN=>NbCharReceived, REC_BUF=>ReceivedBuffer)

ST Representation

Representation:

INPUT_CHAR_QX_Instance (ENABLE:=InputCharEnable, ABORT:=InputCharAbort, ADDR:=ModuleAddress, RESET_BUF:=ResetInputBuffer, INPUT_LEN:=NbCharToRead, DONE=>InputCharSuccessfull, ACTIVE=>InputCharActive, ERROR=>InputCharFaulty, STATUS=>ErrorCode, REC_LEN=>NbCharReceived, REC_BUF=>ReceivedBuffer)

Parameter Description

The following table describes the input parameters:

Parameter

Type

Comment

ENABLE

BOOL

Set to 1 to receive a character string.

ABORT

BOOL

Set to 1 to abort the current operation.

ADDR

ANY_ARRAY_INT

Array containing the target Modicon M340 module address, result of ADDMX function.

RESET_BUF

BOOL

This parameter is used to reset the receiving memory:

  • 0: no memory reset

  • 1: memory reset

INPUT_LEN

INT

Number of characters to be received:

  • 0: message read as soon as it is available on the channel. A STOP condition must be specified in the configuration screen.

  • >0: number of characters to be read

The following table describes the output parameters:

Parameter

Type

Comment

DONE

BOOL

Set to 1 when the execution of the function is completed successfully.

ACTIVE

BOOL

Set to 1 when the execution of the function is in progress.

ERROR

BOOL

Set to 1 if an error is detected by the function block.

STATUS

WORD

Provides the error code if an error is detected by the function block.

REC_LEN

INT

Number of characters received.

REC_BUF

ANY

Characters received.

Programming Rules

When several INPUT_CHAR_QX are launched simultaneously, the RESET_BUF parameter must be set to 0 (module's receive memory not reset).

A reset request (RESET_BUF=1) may be made to reset the module's memory for the next message in order to avoid receiving old data. When the RESET_BUF parameter is set to 1, the INPUT_CHAR_QX function must be launched before sending the data otherwise the characters already received are flushed.

It is possible to launch the INPUT_CHAR_QX function before the ending characters to the PLC.

If the ending characters are used, if in the buffer there are many ending characters and the buffer hasn't been reset, each INPUT_CHAR_QX function receives the beginning string of the buffer until it reaches the first ending character and then the buffer is removed from the read characters.

It works in the same way for reading a number of characters.

If ending characters are configured it could be possible to use the number of characters function.

NOTE: RTS/CTS management: In Character mode communication, when using EF INPUT_CHAR_QX, the characters received on serial link are stored in a ring buffer. The size of this buffer is 1024. When the buffer is full the other characters are lost. To prevent this loss of characters it is possible to select the RTS/CTS management. In this case when the ring buffer is almost full, the CPU resets its RTS signal to stop the sending of the characters.

If a string of more than 1000 characters is sent (for example 1013), the RTS will allow to receive only the first 1000 characters, while the INPUT_CHAR_QX function will wait for the ending character indefinitely.

NOTE: If you want to send a string of more than 1000 characters (1013 for example) you have to send 2 strings. First send 1000 characters and then the remaining 13 characters for example.