Skip to main content

Guides

Adding an energy analyzer to SCADA over Modbus TCP

Every step from the analyzer's register map to seeing current, power and kWh on screen and in a daily consumption chart.

An energy analyzer keeps voltage, current, power and energy values in Modbus registers. In this guide we connect an analyzer to 2Win Scada over Modbus TCP, read three of its values (L1 current, total active power and the active energy counter), derive daily consumption from the counter and show the values on a page. The steps are the same for other Modbus devices; only the register map changes.

Before you start

You need four things:

  • The analyzer's Modbus register map. The manufacturer's document lists, for each measurement, the register address, the area (holding or input register), the data type, the multiplier and, for 32-bit values, the word order. The rest of this guide is about carrying that table over to 2Win Scada.
  • Connection details. For an analyzer with an Ethernet port you need the IP address, the port (usually 502) and the unit identifier (unit id). An analyzer with an RS-485 output is reached through a gateway; you then need the gateway's IP address and the analyzer's address on the serial line.
  • A running 2Win Scada installation. Modbus is included in every package. Each device and tag you add counts toward the license capacity; the package capacities are on the Licensing page.
  • The right to make definitions. Managing channel, device, tag and log definitions with your own team is included in the Professional package; in Starter and Standard it can be added to your quote, otherwise your integrator makes these definitions. The screen editor in step 7 is included in the Professional package and needs a user with the Editor role.

Example register map

Addresses differ by manufacturer and model. The table below is an example map made up for this guide; it does not belong to a real product. Use the values from your own analyzer's document.

MeasurementRegistersAreaData typeUnit
L1 current40007–40008Holding register32-bit floating point (float)A
Total active power40019–40020Holding register32-bit floating point (float)W
Active energy counter40101–40102Holding register32-bit unsigned integer0.1 kWh

The example document also carries two notes: register numbers start from 1, and 32-bit values send the high word first. Each of them maps to a setting below.

1. Create the channel

A channel groups devices of the same connection type. A Modbus TCP channel has no connection settings; the IP address and port are entered on each device.

  1. Open Settings > Tag Management from the left menu.
  2. Click the + button in the header of the Channels tree.
  3. On the General tab, type Pano1 in the Name field. A channel name must be 3–50 characters long and must not start with a digit.
  4. Select ModbusTcp in the Connection Type list and click Save.

The connection type cannot be changed after the channel is saved.

2. Define the device

  1. In the tree, right-click the Pano1 channel and select New Device.
  2. On the General tab, type Analizor1 in the Name field and select the Active check box.
  3. On the Parameters tab, enter the analyzer's Ip address (for example 192.168.1.10), the Port value and the Slave Id value. The Ip field accepts only an IPv4 address.
  4. Set the Settings tab according to the two notes in the document:
    • Zero Based: Keep it selected if the document numbers registers from 1 (40001, 40002, …). Clear it if the document gives addresses from 0.
    • First Word Low 32 Bit: Clear it if the document says "high word first" or "big-endian". Our example map does, so we clear it.
  5. Click Save.

Device Definition window, Parameters tab: Ip 192.168.1.10, Port 502, Slave Id 1; the tabs General, Parameters, Settings and Advanced Parameters at the top

Screenshot: 2Win Scada 2.11.5, the Parameters tab of a Modbus TCP device; the address and port are example values.

About Slave Id: most directly connected Modbus TCP devices ignore this value or expect 1 or 255. If the analyzer sits behind a Modbus TCP → RTU gateway, enter the analyzer's address on the serial line here. If many serial devices sit behind the same gateway and the gateway runs in transparent mode, the ModbusOverEth connection type is a better fit; the details are on the manual's Modbus Serial over Ethernet page.

You can see whether the device connects on the Monitoring > Device States page. If the connection cannot be established, 2Win Scada tries again after 30 seconds; after repeated failed attempts this interval grows to up to 120 seconds. After correcting a setting, wait up to two minutes to see the result.

3. Define the first three tags

Click the Analizor1 device in the tree; the device's tag table opens on the right. The + button on the toolbar opens a new editable row. Enter the three rows below one by one and save each with the floppy disk button at the end of the row.

NameAddressData TypeUpdate Interval[s]UnitRead Only
Akim_L1400007Real1ASelected
Guc_Toplam400019Real1kWSelected
Enerji_kWh400101DWord5kWhSelected

Why these choices:

  • Address is written with 6 digits and the first digit shows the area: 4 holding register, 3 input register. Register 40007 in the document becomes 400007.
  • Data Type follows the type in the document: Real for a 32-bit floating point value, DWord for a 32-bit unsigned integer. Both occupy two registers; the tag takes only the address of the first register.
  • Length always stays 1 for Modbus tags.
  • Read Only is selected because measurement values are not written.

Tag Management page: the Channels tree on the left with the Pano1 channel and the Analizor1 device, the Analizor1 tag table on the right; Akim_L1 400007 Real 1 s A, Enerji_kWh 400101 DWord 5 s kWh, Guc_Toplam 400019 Real 1 s kW; Read Only selected, the Scale Max column under the Scale header

Screenshot: 2Win Scada 2.11.5, the three tags of the example analyzer; the device is connected to a Modbus simulator prepared for this guide. At this width only Scale Max of the scaling fields shows as a column; the others open with ....

Apply the multiplier with scaling

The example analyzer reports power in W and energy in steps of 0.1 kWh; we want kW and kWh on screen. The Scale fields in the tag row do this. Fields that do not fit on screen open below the row with the ... button at the end of the row. If Scale Max appears neither in the table nor among these fields, widen the browser window.

TagScale > Scale ActiveScale Min RawScale Max RawScale MinScale Max
Guc_ToplamSelected0100001
Enerji_kWhSelected01001

Scaling is linear: the raw value is mapped from the Scale Min Raw–Scale Max Raw range to the Scale Min–Scale Max range. The first row divides the raw value by 1000 (23,850 W → 23.85 kW), the second by 10 (1,284,567 → 128,456.7 kWh). Unless you select Scale Min Clamp Active and Scale Max Clamp Active, values outside the range are converted with the same ratio.

After entering the scaling, save both rows again with the floppy disk button at the end of the row.

When the tag list changes, the device has to be reinitialized. Click the Reinitialize Device button that appears next to the device in the tree.

4. Check the values

  1. Open the Monitoring > Tag States page.
  2. Select Pano1 in the Channels field and Analizor1 in the Devices field, then click Update.

The table shows the Value, Unit and Quality columns for each tag. If Quality is Good, the value is being read from the device correctly. Compare the value with the analyzer's own display.

Tag States page: Pano1 in the Channels filter, Analizor1 in the Devices filter; the table shows Akim_L1 41.5 A, Guc_Toplam 23.85 kW and Enerji_kWh 128456.7 kWh, all three with quality Good

Screenshot: 2Win Scada 2.11.5, Tag States; the values are read from the Modbus simulator, which returns the fixed values of the example map.

  • If the quality is Bad, the problem is in communication: check the IP address, the port, Slave Id and whether the addresses are defined in the device.
  • If the quality is Good but the value makes no sense, the problem is in interpretation: an address offset, the data type or the word order. We describe how to check this step by step in When a Modbus value comes in wrong.

5. Add a consumption log to the kWh counter

The analyzer's energy counter is a continuously increasing value. To see daily or monthly consumption you need a log definition that records the counter in the archive.

  1. On the Settings > Tag Management page, select the Analizor1 device and then the Enerji_kWh row in the tag table.
  2. In the Other Definitions section below, open the Logs tab and click the + button.
  3. In the General step, enter the following and click Next:
    • Name: Energy 1 min
    • Log Type: Cyclic
    • Interval[s]: 60
    • Log Value Type: Current
  4. In the Consumption & Run/Stop step, fill in the Consumption Calculation Parameters group:
    • Consumption Value Type: Cumulative
    • Unit: kWh
    • Factor and Divisor stay 1; we applied the multiplier in the tag's scaling.
  5. Click Save.

Log Definition window, Consumption & Run/Stop step: Run/Stop Data Basis None; in the Consumption Calculation Parameters group Consumption Value Type Cumulative, Factor 1, Divisor 1, Unit kWh; the Cancel, Back and Save buttons at the bottom

Screenshot: 2Win Scada 2.11.5, the Consumption & Run/Stop step of the log definition.

Cumulative makes the consumption be calculated from the increases between consecutive counter records. If the counter is reset, that step counts as 0; no negative consumption appears. The archive retention can be set per tag in the same window.

6. See the daily consumption

  1. Open History > Consumptions from the left menu.
  2. Click the Chart Settings button on the chart toolbar. On the Tag Selection tab, select the Enerji_kWh tag and the Energy 1 min log definition and click Ok.
  3. In the Filters section, select Day as the Consumption Period, keep Align To Calendar on and click Update.

The chart shows one column per day. Because the log was just defined, the first day covers only the time after recording started; full days begin the next day.

7. Show the values on a page

This step uses the screen editor (Professional package, Editor role). If your package does not include the screen editor, your integrator prepares the pages.

  1. Open Settings > Editor and select File > New in the top menu.
  2. Type Panel 1 Energy in the Name for a new page field, select Blank page in the Start section and click Yes.
  3. Open the Widgets tab in the left panel and add the Value label widget from the Basic group to the page.
  4. With the widget selected, type kW in the Unit field of the panel on the right.
  5. In the Bindings (Rules) section, click the Add binding (+) button and enter the following:
    • Tag Name: Pano1.Analizor1.Guc_Toplam
    • Binding Type: Direct
    • Property Name: processValue
  6. Repeat the same steps for current and energy, then save the page with File > Save.

Pages have no separate publishing step; a saved page can be opened right away. On pages a tag name is written as Channel.Device.Tag.

The sample project that comes with a new installation contains a ready-made Energy Analyzer page. You can draw on it when designing your own page.

The sample project's Energy Analyzer page for TR1: cumulative consumption (kWh); consumption yesterday, today, last month and this month; real-time load (kW) and power factor; line currents, line voltages and frequency; reactive power and phase active power

Screenshot: the sample project's Energy Analyzer page (TR1), simulated data; the history behind the consumption cards is sample data generated for the screenshot.

What to do next

  • If a value is not what you expect: When a Modbus value comes in wrong: byte order, multiplier, address offset.
  • The remaining measurements: Add the voltages, the other phase currents and the power factor the same way. If you have several analyzers of the same model, you can duplicate the device or prepare a device profile instead of entering the tags by hand for each device.
  • A communication alarm: The Quality tags button in the tag table adds the _ConnError and _TagQualityBad tags, which monitor the device connection; you can define alarms on them.

Related pages in the manual:

If you would like to see these steps with your own analyzer, we can show them in a demo meeting.

All guides