Procedure to Follow

The array below shows the procedure to follow for programming the OUT_IN_MBUS block.

Step

Action

details

1

Preparing the communication port

  • If the serial port is not configured to character mode, change the Modbus mode of the port to character mode by sending the WRITE_CMD command to the serial port.

  • For a modem transmission, send the HAYES command by using the PRINT_CHAR block or the OUT_IN_CHAR block to configure the modem.

  • For a modem transmission, use the HAYES command to send a dial message to the modem by using the PRINT_CHAR block or the OUT_IN_CHAR block. The dial message is used to send a telephone number to the modem.

2

Initialization of parameters

Initialize the DFB block input parameters. It is not useful to repeat this operation for each PLC cycle.

3

OUT_IN_MBUS block call

  • OUT_IN_MBUS must be called at each PLC cycle until the activity bit is at zero.

  • As soon as the activity bit is at zero, force a bit in the block call condition to prevent a new call.

  • Check the error bit (in the event of an error, the status word will specify the cause of the error).

4

Resetting the communication port

  • For a modem transmission, send the HAYES command to send a disconnection message to the modem by using the PRINT_CHAR block or the OUT_IN_CHAR block.

  • If the port was switched to character mode (in step 1), return to the starting mode of the serial port using the WRITE_CMD command.

Writing the Command Words to a Communication Port

The following steps should be executed to send a WRITE_CMD to a communication port:

Step

Action

1

Test to determine whether any command is pending.

  • Before executing a WRITE_CMD, test whether an exchange is currently in progress using the %MWr.m.c.0 language object. To refresh this word, use the READ_STS block.

2

Assign the command word.

  • You must next modify the value of the command language object in order to perform the required command. For a Modbus link, the object language is the internal word %MWr.m.c.15. For example, to switch from Modbus mode to character mode, %MWr.m.c.15 is set to 16#4000 (%MWr.m.c.15.14=1).

    Note: A single command bit must then be switched from 0 to 1 before transmitting the WRITE_CMD.

3

Send the command.

  • Finally, a WRITE_CMD must be executed to acknowledge the command.

In the example that follows, we use the corresponding IODDT interface to communicate with the serial port channel.