NUERA project template offers readily available data server, command server, PLC server, image server in order to exchange different type of information through TCP Communication.
Follow the steps given below to enable PLC server.
Step 1: Enable PLC Server (if not already enabled)
The PLC server can be enabled or disabled by using the definition PLC_SERVER_ENABLED in sys_constants.hpp:
Step 2: Configure Data Server (if needed)
In TCP, the server listens for connection requests from clients at a specific port. By default, the Port Number for the PLC server is given in sys_constants.hpp . Navigate to file src >> system_configurations >> sys_constants.hpp. Many constants are defined in this header file. Find PLC_SERVER_PORT. By default, it is defined as 7894. This can be changed as per your requirement. Remember that in Step 4, we
will use this port number as the TCP client end to connect to this PLC server. The Buffer Size and Data Timeout of the data server can also be changed in this file:
Step 3: Update code in the PLC Server Function
Navigate to file src >> application >> application.cpp. Find and open the manage_plc_srvr() . Using this server, we can send control data to a device from NUERA which can be used for applications like starting and stopping of a motor, etc. The PLC server can be enabled or disabled by using the definition PLC_SERVER_ENABLED in sys_constants.hpp . The code is shown below:
Call the send_data() , passing the character array as first parameter and number of characters
as second parameter, to send this message through the network to the other device using
TCP. The code needs to be added at the location shown below:
Step 4: Observe Output (on Hercules)
Hercules is used here in place of a PLC TCP client. Connect a Windows System to the same network as NUERA. Open Hercules on the Windows System. Go to the TCP Client pane. Set the Module IP as the IP address of the NUERA camera. Set the Port field according to the data port as set in Step 2. Then, click Connect button. After a “Connected” message, the data we are sending from the Nuera camera will be
received by the TCP client and displayed on the screen as shown below:
For any further assistance, please contact our application engineer at [email protected]