Function Description

The INPUT_CHAR function is used to send a character string read request to a character mode communication module (await reception of character strings). The message received is stored in a character string.

For Premium PLCs, this function is used to receive up to 4 Kbytes (120 bytes for the terminal port).

For Modicon M340 and M580 CPU, this function is used to receive up to 1,024 bytes.

2 exclusive possibilities are available:

  • Read a number of characters: No condition should be configured.

  • Read a message: A stop condition should be configured in the configuration screen.

The additional parameters EN and ENO can be configured.

FBD Representation

Representation:

LD Representation

Representation:

IL Representation

Representation:

LD Address
INPUT_CHAR Raz, String_Length, Management_Param, Received_Data

ST Representation

Representation:

INPUT_CHAR(Address, Raz, String_Length, Management_Param, Received_Data);

Parameter Description

The following table describes the input parameters:

Parameter

Type

Comment

ADR

ARRAY [0..5] OF INT for Premium

ARRAY [0..7] OF INT for Modicon M340 and M580

For the Premium PLC:

  • Address of the message's receiving character mode channel is given by the ADDR function.

  • Only those addresses ending in SYS are possible (example: 0.0.0.SYS processor terminal port).

For the Modicon M340 PLC:

  • Address of the message's receiving character mode channel is given by the ADDM function.

  • The syntax of the address is of ADDM (‘r.m.c.node’)-type. Node is an optional field that may be SYS or empty (e.g. ADDM(‘0.0.0.SYS’) equals ADDM(‘0.0.0’).

For the Modicon M580 CPU:

  • Address of the destination entity of the input operation, result of an ADDMX function.

RAZ

INT

Reset. This parameter is used to reset the coupler's receive memory.

  • value = 0: no memory reset

  • value = 1: memory reset

NOTE: For terminal port communications of Premium PLCs, the value must be 1.

NOTE: On Modicon M340 and M580 CPU, the INPUT_CHAR EF can be programmed with or without this parameter.

NB

INT

Length of the character string or number of characters to be received.

  • Value = 0: Message read as soon as it is available on the channel. Here, a stop condition must be specified in the configuration screen.

  • Value greater than 0: Specifies the number of characters to be read.

NOTE: For terminal port communications of Premium PLCs, 0 is the only value authorized. Here, the default end of message character is a carriage return (CR).

The following table describes the input/output parameters:

Parameter

Type

Comment

GEST

ARRAY [0..3] OF INT

Exchange management table consisting of the following words:

  • Rank 1 word: a word managed by the system and consisting of two bytes:

    • Most significant byte: exchange number

    • Least significant byte: activity bit (rank 0), cancel bit (rank 1) and immediate acknowledge bit (rank 2)

      NOTE: The cancel bit is only available for Modicon M340 and M580 PLCs.
  • Rank 2 word: a word managed by the system and consisting of two bytes:

    • Most significant byte: operation report

    • Least significant byte: communication report

  • Rank 3 word: a word managed by the user which defines the maximum response time using a time base of 100 ms.

  • Rank 4 word: a word managed by the system which defines the length of the exchange.

For detailed information, refer to section Structure of the Management Parameters.

The following table describes the output parameters:

Parameter

Type

Comment

RCP

STRING

String received. This is then stored in a character string.

NOTE: The size of the data received (in bytes) is written automatically by the system in the fourth word of the management table.

Programming Rules

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

A request may be made to reset the module's memory for the next message in order to avoid receiving old data.

When the RAZ parameter is set to 1, the INPUT_CHAR function must be launched before sending the data.

On Premium PLCs, it takes several PLC cycles to receive a character string of more than 240 bytes (the string is fragmented). It is therefore important to make sure that the management data is not modified during the processing of the function. The system receives the string consistently over several fragments.

On Modicon M340 and M580 CPU, it takes only one CPU cycle to receive a character string of a maximum length of 1,024 bytes. It is important to make sure that the management data is not modified during the processing of the function.

The Modicon M340 PLC's serial port is full duplex, so a PRINT_CHAR function can be sent even when an INPUT_CHAR function has been sent and is still pending.

It is possible to launch the INPUT_CHAR function before ending the 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 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, 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 function will wait for the ending character indefinitely (if no timeout has been defined with the function).

NOTE: If you want to send string of more than 1000 characters (1013 for example) you have to send the string twice, one sending of the first 1000 characters and the other for the remaining 13 for example.