This tutorial describes guidelines and procedures for communicating a Nexto Xpress with the RealTerm emulator using ASCII transmission mode via the RS-485 port.
Components
Software: Mastertool IEC XE 3.30; RealTerm 3.0.1.43
PLC: XP340
Converter: FBs-CM25C
Tutorial Sections
1. ARCHITECTURE
2. DEVELOPMENT
2.1. Adding library
2.2. Understanding the logic
2.2.1. Explaining TX function block
2.2.2 Explaining RX function block
2.3. Declared variables
2.4. COM1 configuration parameters
2.5. Configuring RealTerm
2.6. Running the application
1. ARCHITECTURE
In the architecture of this tutorial, the Ethernet port of the XP340 was connected to the computer's Ethernet port using the NX9202 cable. The D+ and D- of the Xpress RS-485 port were connected to the FBs-CM25C converter and its serial input was connected to the computer's USB port.
2. DEVELOPMENT
This tutorial will show the steps to send and receive messages using the ASCII protocol. A code will be created that uses the serial TX and RX blocks for transmission and reception, respectively.
It is important to have the Nexto Xpress Series Manual on hand, allowing for consultation during the application steps. This document will guide you regarding technical characteristics, installation, programming, and configurations.
2.1. Adding library
First, open the project in Mastertool IEX XE and go to Library Manager. Click on Add library and select NextoSerial.
Make sure the library was inserted.
2.2. Understanding the logic
The logic present in UserPrg is shown below. Three physical variables were used in order to enable the blocks, but they can be replaced by another variable.
In line 1 we have the physical variable I00, responsible for enabling the POU subprogram. This subprogram consists of logic that is shown below.
Opening the created POU, we see that the variable hab_tx starts as FALSE. If the variable OLD_VALOR is different from P_TX, it means that the value transmitted by Mastertool has been changed, so hab_tx goes to TRUE, enabling the SERIAL_TX block. Lastly, OLD_VALOR becomes equal to P_TX, preparing for the next cycle.
In line 2 we have the Serial_TX block. To insert it, just insert a box with EN/ENO and type “SERIAL_TX”.
The other variable names of this block, as well as the times, should follow the image of the logic shown above.
IMPORTANT: when declaring P_TX, change POINTER TO BYTE to POINTER TO STRING
In line 3 we have a FEITO_TX contact and when it is TRUE, that is, when the SERIAL_TX block is executed, the LEITURA variable from SERIAL_RX will receive a pulse.
In line 4 we have the Serial_RX block. To insert it, just insert a box with enable the same way as Serial_TX, but type “Serial_RX”.
IMPORTANT: when declaring P_RX, change POINTER TO BYTE to POINTER TO STRING
2.2.1. Explaining TX function block
This function block is used to transmit a data buffer through the serial port, and it only finishes after all bytes have been transmitted or after a time-out (which generates some errors).
SERIAL_TX Input Parameters:
SERIAL_TX Output Parameters:
2.2.2 Explaining RX function block
This function block is used to receive a buffer from the serial port using the normal mode of the RX queue. In this mode, each character in the RX queue occupies a single byte containing the received data, i.e., it stores 5, 6, 7, or 8 bits, according to the serial interface configuration.
SERIAL_RX Input Parameters:
SERIAL_RX Output Parameters:
2.3. Declared variables
When declaring the variables, make sure they are as shown in the figure below:
We will also define global variables in Qualities.
2.4. COM1 configuration parameters
Access COM 1 and configure as follows:
Then, go to Device Manager and select the item highlighted in red with two clicks. The port number varies according to the computer; in this case it was COM4. Configure the properties as shown below:
2.5. Configuring RealTerm
Open RealTerm.
In Display, make the highlighted changes and finally click Change.
In the Port tab, configure as shown in the figure below and click Change.
2.6. Running the application
The developed project will be available at the end of this tutorial.
Log in to the PLC in use. By enabling inputs I00 and I01, every time the value is changed in Mastertool IEC XE, it will be written in RealTerm.
Inputs I00 and I01 set to TRUE:
Variable where the value should be written, P_TX^:
Values sent in RealTerm:
Now, to write values from RealTerm to Mastertool IEC XE, we will disable I01 and enable I02.
In the Send tab, set the value you want to write and click the as ASCII button.
We can see, in the variable Valor Lido, the same value that was typed in RealTerm.
Comments
0 comments
Please sign in to leave a comment.