Setting up UART for Transmission and Reception................................................................................................................6
Set up Transmission................................................................................................................................................................... 6
Set up Reception......................................................................................................................................................................... 8
Setting up UART with Heartbeat Messages............................................................................................................................9
SC0XX-1XX devices are supported for use with the library.
•
SC0XX-0XX devices are not supported for use with the library.
•
MCXXX-0XX, MCXXX-1XX and Display devices are not supported by the library.
•
Minimum required SC0XX-1XX HWD version is v210.
•
Make dependency files available, as follows:
1. After you add the first UART function block to the application, click Yes in the dialog box that
appears.
Limitations
2. In the project manager, right click on UART_Include.h and select Make available to PLC C code
POUs.
Before using the function blocks in this library, note the following limitations of some blocks.
A UART_Tx_Msg block can only transmit every other loop. If a piece of data needs to be sent every loop,
ensure it uses two blocks with two different IDs with alternating transmission.
The UART_Tx_Buffer block can send up to four messages per loop. Any additional messages stored in
the buffer are sent in the following loop following a First In, First Out queue. The buffer can hold 18
messages from the UART_Tx_Msg block.
Set up UART so an application can transmit messages and an application can receive messages.
Set up Transmission
To set up an application to transmit messages, complete the tasks that follow.
1. From the Library, drag in the UART_Tx_Buffer block. Place this function near the end of the
application.
2. Connect the UART_In bus to the UART_App bus from the Inputs bus of the controller template.
Then, connect the UART_Out bus to the UART_App_Outputs bus from the Outputs bus of the
controller template.
3. Navigate to the UART page in the outputs section of the controller template, “!TOP!Outputs!UART.”
Remove the logic from the following signals for proper compilation: TxMsg_Len, TxMsg_Tx, and
TxMsg_Data.
Make the changes shown in the following figure. If you are using the UART_Rx_Buffer block, also
•
remove the signal mentioned in the next section.
4. Add a UART_Tx_Msg block. This block is used to send 8 bytes of data over UART. The messages are
added to a queue that is processed by the UART_Tx_Buffer.
5. Connect inputs to the block, as shown in the following example.
ID: 25. Values from 0 to 120 are allowed.
•
Data: Safety Layer Failure signal in the lower four bytes, zero in the upper four bytes.
In the example, the message is then sent every 100 ms. To set up the other application to receive the
message, see Set up Reception.
Set up Reception
To set up an application to receive messages, complete the tasks that follow.
1. From the Library, drag in the UART_Rx_Buffer block. Place this function near the front of the
application.
2. Connect the UART_In bus to the UART_App bus from the Inputs bus of the controller template.
Then, connect the UART_Out bus to the UART_App_Outputs bus from the Outputs bus of the
controller template.