Reading a Finder 7M series via Modbus RTU with Finder OPTA in CODESYS

Learn how to configure Finder OPTA in CODESYS to read data from a Finder 7M series via Modbus RTU.

Guide and Tutorial | Reading a Finder 7M series via Modbus RTU with Finder OPTA in CODESYS

Reading a Finder 7M series via Modbus RTU with Finder OPTA in CODESYS

Learn how to configure Finder OPTA in CODESYS to read data from a Finder 7M series via Modbus RTU.

Overview

Finder OPTA is equipped with an RS-485 port that enables communication with devices compatible with the Modbus RTU protocol, such as the Finder 7M series. In this tutorial, we will show step by step how to configure Finder OPTA in CODESYS to correctly read data from a Finder 7M series energy meter.

Goals

  • Configure Finder OPTA via Ethernet to read registers from a Finder 7M series device in CODESYS.
  • Read registers from a Finder 7M series device via Modbus RTU CODESYS.

Requirements

Before starting, make sure you have:

  • Finder OPTA CODESYS PLC (x1)
  • 12W or 25W switching power supply for OPTA (1x)
  • Finder 7M series with Modbus RTU (x1)
  • Ethernet cable (x1)
  • Wire with either specification for RS-485 connection (x2):
    • STP/UTP 24-18AWG (Unterminated) 100-130Ω rated
    • STP/UTP 22-16AWG (Terminated) 100-130Ω rated
  • CODESYS development environment installed with the OPTA Configurator plug-in.
    You can find an installation guide at this link.
  • Properly configured network: your PC must be able to communicate with Finder OPTA via Ethernet.
    Configuration guide available here.

To follow this tutorial, you will need to connect the Finder 7M energy meter to the electrical grid and provide an appropriate load. You will also need to power the Finder OPTA using the power supply and properly configure the RS-485 serial connection. The diagram below shows the correct wiring between Finder OPTA and the Finder 7M series.

Connection

Instructions

In this tutorial, the configuration parameters used for Modbus communication with the Finder 7M series are:

  • Modbus Address: 1.
  • Baudrate: 38400.
  • Stop bit: 1.
  • Parity: NO.

You can set these values via NFC using the Finder Toolbox NFC application.

Creating the CODESYS Project

Open CODESYS.

Open CODESYS

Create a new project and choose Standard Project.

New project

Ensure the device is Finder Opta, then select the programming language (we’ll use ST).

Standard project

Identifying Finder OPTA via Ethernet

Now double-click on the Device (Finder Opta) entry in the Devices menu. A tab will open as shown below.

Device

Click the Scan Network button and ensure the Finder OPTA device appears under the Gateway.

Scan Network

Modbus Configuration

At this stage, we configure the RS-485 port and Modbus protocol parameters to ensure Finder OPTA can communicate with the Finder 7M series.

Right-click on Device (Finder Opta) and select Add device....

Device Menu

Now configure the Modbus RTU protocol on the RS-485 port of Finder OPTA. From the list select Modbus COM Port and click Add device.

Add Modbus COM port

Now set the serial port values:

  • COM Port: 2, which is the RS-485 port of Finder OPTA.
  • Baudrate: 38400.
  • Parity: NONE.
  • Data bits: 8.
  • Stop bits: 1.

Set Modbus COM port

After setting the serial port, right-click on Modbus_COM_Port(Modbus COM Port) and then on Add Device.

Modbus COM port menu

From the list select Modbus Client, COM Port and click Add device. In this way you add a Modbus client communicating on the previously configured serial port, i.e. the Finder 7M series.

Add Modbus client

Then right-click on the newly added entry in the side menu Modbus_Client_COM_Port(Modbus Client, COM Port) and click Add Device.

Modbus client menu

Select Modbus Server, COM port, then Add device to specify that the Finder 7M serie will act as server, while the Finder OPTA will act as client.

Add Server Modbus

Click the newly added item in the side menu and ensure the Server Address is 1, the Modbus address of the Finder 7M series.

Set Server Modbus

Finally, we configure a Modbus server channel, meaning we set the parameters that will be used by the program to read from the Finder 7M series. On the same screen, click Modbus Server Channel and then Add Channel at the bottom right.
In this tutorial, we’ll read the frequency value from the Finder 7M. As defined in the device technical manual, the frequency value is in Input Registers 32498 and 32499 in float format. Set the channel values as follows:

  • Name: Frequency.
  • Access Type: Read Input Registers (Function Code 4).
  • Trigger: Cyclic.
  • Cycle Time: 1000 (one read per second).
  • Offset: 2498.
  • Length: 2.
  • Error Handling: Keep last value.

Add Channel

After clicking OK, you will see the channel summary.

Set Channel

Preparing the ST Program

Now write the ST program that reads the frequency value.

This program handles the byte order inversion of data read from the Finder 7M series, allowing it to be correctly interpreted as floating-point numbers (float). This operation is necessary because the counter data is stored in Little Endian format, whereas correct interpretation as a float requires Big Endian ordering. After the inversion, the program directly accesses the memory address of the reconstructed variable and interprets its contents as a float value. This step is essential to retrieve the actual measurement stored in the device and convert it into a readable and usable format for the user. In CODESYS, the float data type is referred to as REAL.

In the side menu, click on PLC_PRG (PRG).

PLC PRG

At the top of the editor - section dedicated to variables declaration - insert the following code:

PROGRAM PLC_PRG
VAR
    words: ARRAY[0..1] OF WORD;
    frequency_w: ARRAY[0..1] OF WORD;
    ptr: POINTER TO REAL;
    frequency: REAL;
END_VAR

Program Variables

At the bottom of the editor - section dedicated to program logic - insert the following code:

// Flip endianness
frequency_w[0] := words[1];
frequency_w[1] := words[0];

// Interpret as float
ptr := ADR(frequency_w);
frequency := ptr^;

Program Code

Now it is necessary to link the program variables to the Modbus channel, so that the variables contain the values read from the channel.

In the side menu, double-click on Server_Modbus_porta_COM. Now click on the
ModbusGenericSerialServer mapping I/O section, and in the table double-click on the Variable
cell to bring up the options button.

Add mapping

Click the options button to display the list of variables, expand Application and then PLC_PRG to access the variables previously defined in the ST program. Now click on the words variable and press OK to assign it to the Frequency channel.

Variable association

The summary shows the variable assigned to the Frequency channel. From now on, the variable words contains the bytes read from the registers of the Finder 7M series, representing the frequency value measured by the device. It's our ST program that transforms these bytes in float.

Variable Summary

Uploading the Program to Finder OPTA

At this stage, we download the program and the hardware configuration to Finder OPTA, so that it executes the code we just wrote, returning the frequency value read by the Finder 7M series.

Download the program and configuration to the device by pressing the green button at the top labeled Login.

Login

Once the download is over, the program will be downloaded on Finder OPTA. Execute it by pressing the Start button.

Start

The PLC_PRG tab now displays the real-time frequency value stored
in the frequency variable — in this case, 50.01 Hz.

Working

Conclusion

By following these steps, you have successfully performed a Modbus RTU read
from the registers of a Finder 7M series device using Finder OPTA in CODESYS.

If you encounter any issues, make sure the devices are properly wired
and that the Modbus parameters are configured as specified in the tutorial.