Twido Modbus Communication - Quick Guide - File3
Twido Modbus Communication - Quick Guide - File3
Twido Modbus Communication - Quick Guide - File3
Transmission/ When in Transmit Only mode, the Control and Transmission tables are filled in prior
reception tables to executing the EXCHx instruction, and can be of type %KW or %MW. No space is
required for the reception of characters in Transmission only mode. Once all bytes
are transmitted, %MSGx.D is set to 1, and a new EXCHx instruction can be executed.
When in Transmit/Receive mode, the Control and Transmission tables are filled in prior to
executing the EXCHx instruction, and must be of type %MW. Space for up to 256 reception
bytes is required at the end of the Transmission table. Once all bytes are transmitted, the
Twido controller switches to reception mode and waits to receive any bytes.
When in Reception only mode, the Control table is filled in prior to executing the
EXCHx instruction, and must be of type %MW. Space for up to 256 reception bytes
is required at the end of the Control table. Twido controller immediately enters the
reception mode and waits to receive any bytes.
Reception ends when end of frame bytes used have been received, or the Reception
table is full. In this case, an error (receive table overflowed) appears in the word
%SW63 and %SW64. If a non-zero timeout is configured, reception ends when the
timeout is completed. If a zero timeout value is selected, there is no reception
timeout. Therefore to stop reception, %MSGx.R input must be activated.
Note: Each communications port can be configured for different protocols or the
same. The EXCHx instruction or %MSGx function block for each communications
port is accessed by appending the port number (1 or 2).
EXCHx The EXCHx instruction allows the Twido controller to send and/or receive information to/
Instruction from ASCII devices. The user defines a table of words (%MWi:L or %KWi:L) containing
control information and the data to be sent and/or received (up to 256 bytes in
transmission and/or reception). The format for the word table is described earlier.
A message exchange is performed using the EXCHx instruction:
The Twido controller must finish the exchange from the first EXCHx instruction
before a second can be launched. The %MSGx function block must be used when
sending several messages.
The processing of the EXCHx list instruction occurs immediately, with any
transmissions started under interrupt control (reception of data is also under
interrupt control), which is considered background processing.
%MSGx Function The use of the %MSGx function block is optional; it can be used to manage data
Block exchanges. The %MSGx function block has three purposes:
z Communications error checking
The error checking verifies that the parameter L (length of the Word table)
programmed with the EXCHx instruction is large enough to contain the length of
the message to be sent. This is compared with the length programmed in the
least significant byte of the first word of the word table.
z Coordination of multiple messages
To ensure the coordination when sending multiple messages, the %MSGx
function block provides the information required to determine when transmission
of a previous message is complete.
z Transmission of priority messages
The %MSGx function block allows current message transmissions to be stopped
in order to allow the immediate sending of an urgent message.
The %MSGx function block has one input and two outputs associated with it:
Input/Output Definition Description
R Reset input Set to 1: re-initializes communication or
resets block (%MSGx.E = 0 and %MSGx.D =
1).
%MSGx.D Communication 0: Request in progress.
complete 1: communication done if end of
transmission, end character received, error,
or reset of block.
%MSGx.E Error 0: message length OK and link OK.
1: if bad command, table incorrectly
configured, incorrect character received
(speed, parity, and so on.), or reception table
full.
Error and If an error occurs when using the EXCHx instruction, bits %MSGx.D and %MSGx.E
Operating Mode are set to 1 and system word %SW63 contains the error code for Port 1, and
Conditions %SW64 contains the error code for Port 2.
System Use
Words
%SW63 EXCH1 error code:
0 - operation was successful
1 – number of bytes to be transmitted is too great (> 250)
2 - transmission table too small
3 - word table too small
4 - receive table overflowed
5 - time-out elapsed
6 - transmission error
7 - bad command within table
8 - selected port not configured/available
9 - reception error
10 - cannot use %KW if receiving
11 - transmission offset larger than transmission table
12 - reception offset larger than reception table
13 - controller stopped EXCH processing
%SW64 EXCH2 error code: See %SW63.
Modbus Communications
Introduction The Modbus protocol is a master-slave protocol that allows for one, and only one,
master to request responses from slaves, or to act based on the request. The master
can address individual slaves, or can initiate a broadcast message to all slaves.
Slaves return a message (response) to queries that are addressed to them
individually. Responses are not returned to broadcast queries from the master.
CAUTION
UNEXPECTED EQUIPMENT OPERATION
z Be sure that there is only one Modbus master controller on the bus and that
each Modbus slave has a unique address. Failure to observe this precaution
may lead to corrupted data or unexpected and ambiguous results.
z Be sure that all Modbus slaves have unique addresses. No two slaves should
have the same address. Failure to observe this precaution may lead to
corrupted data or unexpected and ambiguous results.
Failure to follow this instruction can result in injury or equipment damage.
Hardware A Modbus link can be established on either the EIA RS-232 or EIA RS-485 port and
Configuration can run on as many as two communications ports at a time. Each of these ports can
be assigned its own Modbus address, using system bit %S101 and system words
%SW101 and %SW102 (See System Bits (%S), p. 596). . (See also System Words
(%SW), p. 604)
The table below lists the devices that can be used:
Remote Port Specifications
TWDLC•A10/16/24DRF, 1 Base controller supporting a 3-wire EIA RS-485 port with a miniDIN connector.
TWDLCA•40DRF,
TWDLMDA20/40DTK,
TWDLMDA20DRT
TWDNOZ232D 2 Communication module equipped with a 3-wire EIA RS-232 port with a miniDIN connector.
Note: This module is only available for the Modular controllers. When the module
is attached, the controller cannot have an Operator Display expansion module.
TWDNOZ485D 2 Communication module equipped with a 3-wire EIA RS-485 port with a miniDIN connector.
Note: This module is only available for the Modular controllers. When the module
is attached, the controller cannot have an Operator Display expansion module.
TWDNOZ485T 2 Communication module equipped with a 3-wire EIA RS-485 port with a terminal.
Note: This module is only available for the Modular controllers. When the module
is attached, the controller cannot have an Operator Display expansion module.
TWDNAC232D 2 Communication adapter equipped with a 3-wire EIA RS-232 port with a miniDIN connector.
Note: This adapter is only available for the Compact 16, 24 and 40 I/O controllers
and the Operator Display expansion module.
TWDNAC485D 2 Communication adapter equipped with a 3-wire EIA RS-485 port with a miniDIN connector.
Note: This adapter is only available for the Compact 16, 24 and 40 I/O controllers
and the Operator Display expansion module.
TWDNAC485T 2 Communication adapter equipped with a 3-wire EIA RS-485 port with a terminal connector.
Note: This adapter is only available for the Compact 16, 24 and 40 I/O controllers
and the Operator Display expansion module.
TWDXCPODM 2 Operator Display expansion module equipped with a 3-wire EIA RS-232 port with
a miniDIN connector, a 3-wire EIA RS-485 port with a miniDIN connector and a 3-
wire EIA RS-485 port with a terminal.
Note: This module is only available for the Modular controllers. When the module
is attached, the controller cannot have a Communication expansion module.
Nominal Cabling Nominal cable connections are illustrated below for both the EIA RS-232 and the
EIA RS-485 types.
Note: If port 1 is used on the Twido controller, the DPT signal on pin 5 must be tied
to the circuit common (COM) on pin 7. This signifies to the Twido controller that the
communications through port 1 is Modbus and is not the protocol used to
communicate with the TwidoSoft software.
The cable connections made to each remote device are shown below.
Mini-DIN connection
RS-232 EIA cable
Twido Remote
controller peripheral
TXD RXD COM TXD RXD COM
3 4 7
Note: EIA RS-485 external line polarization must be implemented on the Modbus
Master controller only; you must not implement it on any slave device.
+5 V
TWDLCA40•DRF Master
RS-485 EIA Line Polarization
Assembly
R
D1(A+)
D0(B-)
R
COM (0V)
Software To configure the controller to use a serial connection to send and receive characters
Configuration using the Modbus protocol, you must:
Step Description
1 Configure the serial port for Modbus using TwidoSoft.
2 Create in your application a transmission/reception table that will be used by the
EXCHx instruction.
Configuring the A Twido controller can use its primary port 1 or an optionally configured port 2 to use
Port the Modbus protocol. To configure a serial port for Modbus:
Step Action
1 Define any additional communication adapters or modules configured to the base.
2 Right-click on the port and click Edit Controller Comm Setup... and change serial port
type to "Modbus".
3 Set the associated communication parameters.
Modbus Master Modbus master mode allows the controller to send a Modbus query to a slave, and
to wait for the response. The Modbus Master mode is only supported via the EXCHx
instruction. Both Modbus ASCII and RTU are supported in Modbus Master mode.
The maximum size of the transmitted and/or received frames is 250 bytes.
Moreover, the word table associated with the EXCHx instruction is composed of the
control, transmission and reception tables.
Most significant byte Least significant byte
Control table Command Length (Transmission/
Reception)
Reception offset Transmission offset
Transmission table Transmitted Byte 1 Transmitted Byte 2
... ...
... Transmitted Byte n
Transmitted Byte n+1
Reception table Received Byte 1 Received Byte 2
... ...
... Received Byte p
Received Byte p+1
Note: In addition to queries to invidual slaves, the Modbus master controller can
initiate a broadcast query to all slaves. The command byte in case of a boradcast
query must be set to 00, while the slave address must be set to 0.
Control table The Length byte contains the length of the transmission table (maximum 250
bytes), which is overwritten by the number of characters received at the end of the
reception, if reception is requested.
This parameter is the length in bytes of the transmission table. If the Tx Offset
parameter is equal to 0, this parameter will be equal to the length of the transmission
frame. If the Tx Offset parameter is not equal to 0, one byte of the transmission table
(indicated by the offset value) will not be transmitted and this parameter is equal to
the frame length itself plus 1.
The Command byte in case of Modbus RTU request (except for broadcast) must
always equal to 1 (Tx and Rx).
The Tx Offset byte contains the rank (1 for the first byte, 2 for the second byte, and
so on) within the Transmission Table of the byte to ignore when transmitting the
bytes. This is used to handle the issues associated with byte/word values within the
Modbus protocol. For example, if this byte contains 3, the third byte would be
ignored, making the fourth byte in the table the third byte to be transmitted.
The Rx Offset byte contains the rank (1 for the first byte, 2 for the second byte, and
so on) within the Reception Table to add when transmitting the packet. This is used
to handle the issues associated with byte/word values within the Modbus protocol.
For example, if this byte contains 3, the third byte within the table would be filled with
a ZERO, and the third byte was actually received would be entered into the fourth
location in the table.
Transmission/ When using either mode (Modbus ASCII or Modbus RTU), the Transmission table
reception tables is filled with the request prior to executing the EXCHx instruction. At execution time,
the controller determines what the Data Link Layer is, and performs all conversions
necessary to process the transmission and response. Start, end, and check
characters are not stored in the Transmission/Reception tables.
Once all bytes are transmitted, the controller switches to reception mode and waits
to receive any bytes.
Reception is completed in one of several ways:
z timeout on a character or frame has been detected,
z end of frame character(s) received in ASCII mode,
z the Reception table is full.
Transmitted byte X entries contain Modbus protocol (RTU encoding) data that is to
be transmitted. If the communications port is configured for Modbus ASCII, the
correct framing characters are appended to the transmission. The first byte contains
the device address (specific or broadcast), the second byte contains the function
code, and the rest contain the information associated with that function code.
Note: This is a typical application, but does not define all the possibilities. No
validation of the data being transmitted will be performed.
Note: This is a typical application, but does not define all the possibilities. No
validation of the data being received will be performed, except for checksum
verification.
Modbus Slave Modbus slave mode allows the controller to respond to standard Modbus queries
from a Modbus master.
When TSXPCX1031 cable is attached to the controller, TwidoSoft communications
are started at the port, temporarily disabling the communications mode that was
running prior to the cable being connected.
The Modbus protocol supports two Data Link Layer formats: ASCII and RTU. Each
is defined by the Physical Layer implementation, with ASCII using 7 data bits, and
RTU using 8 data bits.
When using Modbus ASCII mode, each byte in the message is sent as two ASCII
characters. The Modbus ASCII frame begins with a start character (':'), and can end
with two end characters (CR and LF). The end of frame character defaults to 0x0A
(line feed), and the user can modify the value of this byte during configuration. The
check value for the Modbus ASCII frame is a simple two's complement of the frame,
excluding the start and end characters.
Modbus RTU mode does not reformat the message prior to transmitting; however,
it uses a different checksum calculation mode, specified as a CRC.
The Modbus Data Link Layer has the following limitations:
z Address 1-247
z Bits: 128 bits on request
z Words: 125 words of 16 bits on request
Note: Each communications port can be configured for different protocols or the
same. The EXCHx instruction or %MSGx function block for each communications
port is accessed by appending the port number (1 or 2).
EXCHx The EXCHx instruction allows the Twido controller to send and/or receive
Instruction information to/from Modbus devices. The user defines a table of words (%MWi:L)
containing control information and the data to be sent and/or received (up to 250
bytes in transmission and/or reception). The format for the word table is described
earlier.
A message exchange is performed using the EXCHx instruction:
Syntax: [EXCHx %MWi:L]
where: x = port number (1 or 2)
L = number of words in the control words, transmission and reception tables
The Twido controller must finish the exchange from the first EXCHx instruction
before a second can be launched. The %MSGx function block must be used when
sending several messages.
The processing of the EXCHx list instruction occurs immediately, with any
transmissions started under interrupt control (reception of data is also under
interrupt control), which is considered background processing.
%MSGx Function The use of the %MSGx function block is optional; it can be used to manage data
Block exchanges. The %MSGx function block has three purposes:
z Communications error checking
The error checking verifies that the parameter L (length of the Word table)
programmed with the EXCHx instruction is large enough to contain the length of
the message to be sent. This is compared with the length programmed in the
least significant byte of the first word of the word table.
z Coordination of multiple messages
To ensure the coordination when sending multiple messages, the %MSGx
function block provides the information required to determine when transmission
of a previous message is complete.
z Transmission of priority messages
The %MSGx function block allows current message transmissions to be stopped
in order to allow the immediate sending of an urgent message.
The %MSGx function block has one input and two outputs associated with it:
Input/Output Definition Description
R Reset input Set to 1: re-initializes communication or
resets block (%MSGx.E = 0 and %MSGx.D =
1).
%MSGx.D Communication 0: request in progress.
complete 1: communication done if end of
transmission, end character received, error,
or reset of block.
%MSGx.E Error 0: message length OK and link OK.
1: if bad command, table incorrectly
configured, incorrect character received
(speed, parity, and so on.), or reception table
full.
Error and If an error occurs when using the EXCHx instruction, bits %MSGx.D and %MSGx.E
Operating Mode are set to 1 and system word %SW63 contains the error code for Port 1, and
Conditions %SW64 contains the error code for Port 2.
System Use
Words
%SW63 EXCH1 error code:
0 - operation was successful
1 – number of bytes to be transmitted is too great (> 250)
2 - transmission table too small
3 - word table too small
4 - receive table overflowed
5 - time-out elapsed
6 - transmission
7 - bad command within table
8 - selected port not configured/available
9 - reception error
10 - can not use %KW if receiving
11 - transmission offset larger than transmission table
12 - reception offset larger than reception table
13 - controller stopped EXCH processing
%SW64 EXCH2 error code: See %SW63.
The hardware configuration is two Twido controllers. One will be configured as the
Modbus Master and the other as the Modbus Slave.
Note: In this example, each controller is configured to use EIA RS-485 on Port 1
and an optional EIA RS-485 Port 2. On a Modular controller, the optional Port 2 can
be either a TWDNOZ485D or a TWDNOZ485T, or if you use TWDXCPODM, it can
be either a TWDNAC485D or a TWDNAC485T. On a Compact controller, the
optional Port 2 can be either a TWDNAC485D or a TWDNAC485T.
Note: The TSXPCX1031 can only be connected to one controller at a time, on RS-
485 EIA port 1 only.
Next, connect the cable to the COM 1 port of the PC. Be sure that the cable is in
switch position 2. Download and monitor the application. Repeat procedure for
second controller.
Twido Twido
Modbus Master Modbus Slave
D1(A+) D0(B-) COM D1(A+) D0(B-) COM
1 2 7
Twido Twido
Modbus Master Modbus Slave
D1(A+) D0(B-) 0V D1(A+) D0(B-) 0V
A B SG
The wiring in this example demonstrates a simple point to point connection. The
three signals D1(A+), D0(B-), and COM(0V) are wired according to the diagram.
If using Port 1 of the Twido controller, the DPT signal (pin 5) must be tied to circuit
common (pin 7). This conditioning of DPT determines if TwidoSoft is connected.
When tied to the ground, the controller will use the port configuration set in the
application to determine the type of communication.
In both master and slave applications, the optional EIA RS-485 ports are configured.
Ensure that the controller's communication parameters are modified in Modbus
protocol and at different addresses.
In this example, the master is set to an address of 1 and the slave to 2. The number
of bits is set to 8, indicating that we will be using Modbus RTU mode. If this had been
set to 7, then we would be using Modbus-ASCII mode. The only other default
modified was to increase the response timeout to 1 second.
Note: Since Modbus RTU mode was selected, the "End of Frame" parameter was
ignored.
Using TwidoSoft, an application program is written for both the master and the slave.
For the slave, we simply write some memory words to a set of known values. In the
master, the word table of the EXCHx instruction is initialized to read 4 words from
the slave at Modbus address 2 starting at location %MW0.
Note: Notice the use of the RX offset set in %MW1 of the Modbus master. The
offset of three will add a byte (value = 0) at the third position in the reception area
of the table. This aligns the words in the master so that they fall correctly on word
boundaries. Without this offset, each word of data would be split between two
words in the exchange block. This offset is used for convenience.
Before executing the EXCH2 instruction, the application checks the communication
bit associated with %MSG2. Finally, the error status of the %MSG2 is sensed and
stored on the first output bit on the local base controller I/O. Additional error checking
using %SW64 could also be added to make this more accurate.
After downloading and setting each controller to run, open an animation table on the
master. Examine the response section of the table to check that the response code
is 3 and that the correct number of bytes was read. Also in this example, note that
the words read from the slave (beginning at %MW7) are aligned correctly with the
word boundaries in the master.
Modbus Link The diagram below illustrates the use of Modbus request 16 to write output words to
Example 2 a slave. This example uses two Twido Controllers.
Step 1: Configure the Hardware:
Twido Twido
Modbus Master Modbus Slave
D1(A+) D0(B-) COM D1(A+) D0(B-) COM
1 2 7
Twido Twido
Modbus Master Modbus Slave
D1(A+) D0(B-) 0V D1(A+) D0(B-) 0V
A B SG
Using TwidoSoft, an application program is created for both the master and the
slave. For the slave, write a single memory word %MW18. This will allocate space
on the slave for the memory addresses from %MW0 through %MW18. Without
allocating the space, the Modbus request would be trying to write to locations that
did not exist on the slave.
In the master, the word table of the EXCH2 instruction is initialized to read 4 bytes
to the slave at Modbus address 2 at the address %MW16 (10 hexadecimal).
Note: Notice the use of the TX offset set in %MW1 of the Modbus master
application. The offset of seven will suppress the high byte in the sixth word (the
value 00 hexadecimal in %MW5). This works to align the data values in the
transmission table of the word table so that they fall correctly on word boundaries.
Before executing the EXCH2 instruction, the application checks the communication
bit associated with %MSG2. Finally, the error status of the %MSG2 is sensed and
stored on the first output bit on the local base controller I/O. Additional error checking
using %SW64 could also be added to make this more accurate.
Step 5:Initialize the Animation Table Editor:
Create the following animation table on the master:
Address Current Retained Format
1 %MW0 010C 0000 Hexadecimal
2 %MW1 0007 0000 Hexadecimal
3 %MW2 0210 0000 Hexadecimal
4 %MW3 0010 0000 Hexadecimal
5 %MW4 0002 0000 Hexadecimal
6 %MW5 0004 0000 Hexadecimal
7 %MW6 6566 0000 Hexadecimal
8 %MW7 6768 0000 Hexadecimal
9 %MW8 0210 0000 Hexadecimal
10 %MW9 0010 0000 Hexadecimal
11 %MW10 0004 0000 Hexadecimal
After downloading and setting each controller to run, open an animation table on the
slave controller. The two values in %MW16 and %MW17 are written to the slave. In
the master, the animation table can be used to examine the reception table portion
of the exchange data. This data displays the slave address, the response code, the
first word written, and the number of words written starting at %MW8 in the example
above.
Introduction These requests are used to exchange memory words or bits between remote
devices. The table format is the same for both RTU and ASCII modes.
Format Reference number
Bit %Mi
Word %MWi
(*) This byte also receives the length of the string transmitted after response
(*) This byte also receives the length of the string transmitted after response
Note: The Rx offset of three will add a byte (value = 0) at the third position in the
reception table. This ensures a good positioning of the number of bytes read and
of the read words’ values in this table.
(*) This byte also receives the length of the string transmitted after response
Note:
z This request does not need the use of offset.
z The response frame is the same as the request frame here (in a normal case).
z For a bit to write 1, the associated word in the transmission table must contain
the value FF00H, and 0 for the bit to write 0.
(*) This byte also receives the length of the string transmitted after response
Note:
z This request does not need the use of offset.
z The response frame is the same as the request frame here (in a normal case).
Note:
z The Tx Offset=7 will suppress the 7th byte in the sent frame. This also allows a
good correspondence of words’ values in the transmission table.
Note: The Tx Offset = 7 will suppress the 5th MMSB byte in the sent frame. This
also allows a good correspondence of words’ values in the transmission table.
Introduction A Twido controller can be configured to communicate with Modbus slave devices or
can send and/or receive messages in character mode (ASCII).
TwidoSoft provides the following functions for these communications:
z EXCH instruction to transmit/receive messages
z Exchange control function block (%MSG) to control the data exchanges
The Twido controller uses the protocol configured for the specified port when
processing an EXCH instruction. Each communication port can be assigned a
different protocol. The communication ports are accessed by appending the port
number to the EXCH or %MSG function (EXCH1, EXCH2, %MSG1, %MSG2).
In addition, TWDLCAE40DRF series controllers implement Modbus TCP
messaging over the Ethernet network by using the EXCH3 intruction and %MSG3
function.
EXCH The EXCH instruction allows a Twido controller to send and/or receive information
Instruction to/from ASCII devices. The user defines a table of words (%MWi:L) containing the
data to be sent and/or received (up to 250 data bytes in transmission and/or
reception). The format for the word table is described in the paragraphs about each
protocol. A message exchange is performed using the EXCH instruction.
Note: To find out more information about the Modbus TCP messaging instruction
EXCH3, please refer to TCP Modbus Messaging, p. 180.
Introduction
Note: The "x" in %MSGx signifies the controller port: "x = 1 or 2"
z x = 1 or 2, signifies the serial port 1 or 2 of the controller, respectively;
z x = 3, signifies the Ethernet network port of the controller (on TWDLCAE40DRF
controllers only). For more information about the %MSG3 function, please refer
to TCP Modbus Messaging, p. 180.
The %MSGx function block manages data exchanges and has three functions:
z Communications error checking:
Error checking verifies that the block length (word table) programmed with the
EXCH instruction is large enough to contain the length of the message to be sent
(compare with length programmed in the least significant byte of the first word of
the word table).
z Coordination of multiple messages:
To ensure coordination when sending multiple messages, the %MSGx function
block provides the information required to determine when a previous message
is complete.
z Transmission of priority messages:
The %MSGx function block allows the current message transmission to be
stopped, in order to allow the immediate sending of an urgent message.
The programming of the %MSGx function block is optional.
%MSG1
R D
Parameters The following table lists parameters for the %MSGx function block.
Parameter Label Value
Reset input (or R At state 1, reinitializes communication: %MSGx.E = 0 and
instruction) %MSGx.D = 1.
Comm. done %MSGx.D State 1, comm. done, if:
output z End of transmission (if transmission)
z End of reception (end character received)
z Error
z Reset the block
State 0, request in progress.
Fault (Error) %MSGx.E State 1, comm. done, if:
output z Bad command
z Table incorrectly configured
z Incorrect character received (speed, parity, etc.)
z Reception table full (not updated)
State 0, message length OK, link OK.
If an error occurs when using an EXCH instruction, bits %MSGx.D and %MSGx.E
are set to 1, and system word %SW63 contains the error code for Port 1, and
%SW64 contains the error code for Port 2. See System Words (%SW), p. 604.
Fault (Error) The error output is set to 1 either because of a communications programming error
Output or a message transmission error. The error output is set to 1 if the number of bytes
(%MSGx.E) defined in the data block associated with the EXCH instruction (word 1, least
significant byte) is greater than 128 (+80 in hexadecimal by FA).
The error output is also set to 1if a problem exists in sending a Modbus message to
a Modbus device. In this case, the user should check wiring, and that the destination
device supports Modbus communication.
Communications When the Done output is set to 1, the Twido controller is ready to send another
Done output message. Use of the %MSGx.D bit is recommended when multiple messages are
(%MSGx.D) sent. If it is not used, messages may be lost.
Transmission of Execution of the EXCH instruction activates a message block in the application
Several program. The message is transmitted if the message block is not already active
Successive (%MSGx.D = 1). If several messages are sent in the same cycle, only the first
Messages message is transmitted. The user is responsible for managing the transmission of
several messages using the program.
Example of a transmission of two messages in succession on port 2:
%I0.0 %MSG2.D
P EXCH2%MW2:4 LDR %I0.0
AND %MSG2.D
%M0 [EXCH2 %MW2:4]
S S %M0
%MSG.D %M0 LD %MSG2.D
AND %M0
EXCH2%MW8:3
[EXCH2 %MW8:3]
%M0 R %M0
R
Reinitializing An exchange is cancelled by activating the input (or instruction) R. This input
Exchanges initializes communication and resets output %MSGx.E to 0 and output %MSGx.D to
1. It is possible to reinitialize an exchange if a fault is detected.
Example of reinitializing an exchange:
%M0 %MSG1
BLK %MSG1
LD %M0
R D R
END_BLK
Special Cases The following table the special operating cases for the %MSGx function block.
Special Case Description
Effect of a cold restart (%S0=1) Forces a reinitialization of the communication.
Effect of a warm restart (%S1=1) Has no effect.
Effect of a controller stop If a message transmission is in progress, the
controller stops its transfer and reinitializes the
outputs %MSGx.D and %MSGx.E.