Fronius Hybrid with Modbus TCP

Fronius has three options for reading data from the Symo Hybrid inverter -

  1. Fronius Solar API

  2. Push Service

  3. Modbus TCP

The Fronius Solar API and Push Service is discussed in other How-To's (Fronius Symo API Query, Energy Manager of Fronius Takeover in Loxone).

Modbus TCP offers faster update rates than the Solar API. It also allows control over the inverter/battery that is unavailable by other options.

Modbus TCP could be considered the raw, 'low-level' data that informs other data streams. For this reason, some of the computations that would otherwise occur within the inverter, need to be carried out within the Miniserver Config instead.

The end-state is to have the following functions -

 

 

Introduction

The authoritative document from Fronius can be found at the following link by entering in the 'Search & Find' field Fronius Datamanager - Modbus TCP & RTU.

A downloadable file (Fronius Modbus Wiki.Loxone) is provided at the link below. This project file should be opened as a separate project alongside the currently active project. Items can be copied/pasted from one project to the other. Note that the broad logic is directly transferable to the Fronius Gen24. The Gen24 however has different IO addresses for the Modbus actuators and sensors. As a general rule, Gen24 actuators and sensors are +40 from the Symo Hybrid.

ie. Symo Hybrid Stor_Ctl_Mod IO Address = 40318

+40

Fronius Gen24 Stor_Ctl_Mod IO Address = 40358

When developing logic for the Fronius Battery, ensure the battery is not in the ‘Energy Saving Mode’. In this state, the battery is unresponsive to commands and can take up to 10 minutes to wake-up. The ‘Energy Saving Mode’ is indicated by clicking on the 'i' symbol within solar.web.

Loxone Config Download

 

 

Please leave comments or questions in the Loxforum thread -

https://www.loxforum.com/forum/faqs-tutorials-howto-s-aa/132379-fronius-hybrid-with-modbus-tcp

1. Populate the Energy Monitor function block with all required inputs.


                                                    Loxone                                                                                                        Fronius Solar.web

                              

 

The Energy Monitor function block will accurately reflect the Fronius Solar.web interface but without the inherent delay of the Solar.web animation. Update rate is typically 10 seconds with a wired ethernet connection to the inverter.

a. Setting Modbus TCP in the Fronius inverter

Navigate to the IP address of the Fronius Hybrid and select the MODBUS tab. Make the settings as per the screen-capture below. Save and reboot the Hybridmanager ('System information' - 'Datalogger Restart').

 


b. Adding Energy Monitor function block and Modbus templates.

After inserting the Energy Monitor function block in the Config, ensure under 'Properties', 'Data source', 'Block Inputs' is selected.

In the Periphery tree, select 'Miniserver Communication' and from the menu ribbon, select 'Modbus Server'.

 

 

In the Periphery tree, a new entry 'Modbus Server 1' will be created. Click on 'Modbus Server 1' and enter the IP settings of the inverter with the Modbus port at the end. Set Timeout to an initial setting of 500ms.

Download the attached Template files (MB_Fronius Hybrid.xml and MB_Fronius Smart Meter.xml) and copy them with Windows Explorer into the following directory -

C:\ProgramData\Loxone\Loxone Config xx.x.xx.xx\Templates\Comm (where xx.x.xx.xx is the current version of the installed Config)

 

                    

 

Save the current Loxone project and close Loxone Config. With the template files appropriately saved, Loxone Config can be restarted and the new templates will be available.

Go back to the Periphery tree and click 'Modbus Server 1' created earlier. From the menu ribbon, select 'Sensors and Actuators', 'Device Templates' and select the 'Fronius Hybrid' entry.

 

         

 

Repeat this process, but this time select the 'Fronius Smart Meter' from the templates. On completion, the expanded Periphery tree will look as follows -

 


Click on the Fronius Smart Meter (2) modbus device and under Properties, (Modbus Device), set Modbus address to 240.


          

 

Click on the Fronius Hybrid (1) modbus device and under Properties, (Modbus Device), check that the Modbus address is 1 (default setting).

 


c. Connecting the Sensors to the Energy Monitor function block.

The Modbus inputs to the Energy Monitor function block are connected as per the image below. The 'Fronius Modbus Wiki.Loxone' can be referenced for further details. Refer to the tab 1. Energy Monitor.

If any of the Sensors or Actuators are clicked, the Properties window displays relevant information about the input.

 

 

The Memory Flag inputs '1_DCW_kW' and 'Bat Chrge_Dischrge' will be created below.

 

d. Creating the Memory Flag inputs.

The creation of the memory flag  '1_DCW_kW' and 'Bat Chrge_Dischrge' is complex and requires some background information.

The output of the inverter can be provided by all solar DC, all battery DC, or a combination of both. The Total DC power of the system is termed DCW. The value DCW has inputs from two sources -

  1. String 1 = PV Input (1_DCW)

  2. String 2 = Battery (2_DCW)

When discharging the battery, DCW = 1_DCW + 2_DCW

When charging the battery, DCW = 1_DCW - 2_DCW

These three values are further modified by a value called Scale Factor (DCW_SF). Scale Factor changes the placement of the decimal place. A change in Scale Factor from -2 to -1 will increase the values by a factor of 10. A change in Scale Factor from -2 to +1 will increase the values by a factor of 1000.

Together, the four values are time critical with respect to each other to ensure an accurate display in the Loxone Smart Home.

Further complicating the issue is a limitation of the value '2_DCW' (the battery input or output). The value does not contain a sign to indicate whether the battery is charging or discharging; only the rate is displayed.

Due to this limitation, the two equations above need to be utilised to 'sign' the 2_DCW value.

The 'Fronius Modbus Wiki.Loxone' file contains the logic to synchronise the timing and signing of the values. Refer to the tab 1. Energy Monitor.

 


e. Correcting Modbus Polling Sequence

The Miniserver polls the Modbus analogue sensors in the order they were created. In this wiki, the Modbus sensors have been created from a template and the original creation order has been lost.

To rectify the issue, the 4 time critical Modbus sensors (DCW,   1_DCW,   DCW_SF,   2_DCW), need to be re-created 'by hand', in that order. 

To create the sensors 'by hand', click the 'Fronius Hybrid' modbus device and select 'Analogue Sensor'. 

 

                     

 

Refer to each existing Modbus sensor and duplicate all information. Append '_New' to the sensor name to differentiate it from the old. Replace the 4 'old' Modbus sensors with the 4 new ones.

When complete, the Liveview in Loxone Config will show the four Modbus values (DCW,   1_DCW,   DCW_SF,   2_DCW) going into the analogue memories updating in sequence. A delayed trigger will fire Tr on the analogue memories and push all 4 values through together. This results in a consistent application of Scale Factor to the applicable values.

 

 

f. Work-around when Inverter is Sleeping or in Standby - Solar Array Size Required

The Fronius Modbus Wiki.Loxone file above includes a work-around for the conditions when the inverter is sleeping (Energy-Saving Mode) or in Standby. When the battery is discharged and there is no solar production, the inverter sends a null value of 65535. This is wrongly displayed as 655.4 Watts in the Energy Monitor 'Production'. The Status Block pictured below corrects this anomaly.

There will also be irregular times when the flow of Modbus data gets corrupted. On these occasions, the spike in production can last for a fraction of a second. Whilst short-lived, the spike can severely distort the scale on Production graphs. The Status Block also serves to identify these spikes and replace the false value with a 5 minute moving average of solar production. A spike is identified as any value that is greater than the capacity of the solar array. The value in the Status Block of 8850 watts should be changed to match the installed DC capacity of the users solar array.

 

g. Optimising Modbus Polling

There is a limit to how many Modbus sensors can be polled in a given time period. This limit will be affected by many different variables in the home network. Factors such as wifi versus wired connection, age of equipment, router speed etc. can all impact how quickly sensors can be polled. A Miniserver Gen 2 can handle far more sensors at a given polling rate than a Miniserver Gen 1. Settings within the Loxone Modbus Server allow the polling to be optimised. The critical field that needs to be assessed is the Timeout value.

 


Modbus polling failures are visible within the Loxone Monitor. To open the monitor, select the 'Diagnostics' tab, then select 'Debug Information'. Set the drop-downs to the following configuration -

The Loxone Monitor will appear after 'Apply’ is selected. Enter the IP address of the inverter in the Filter box to minimise unnecessary information. If the Modbus Server Timeout value is set too short, an error will be visible as depicted -

 

 

A typical failure will indicate that a previous polling request has been sent, but the response has not been received until after the next polling request has been sent. 

The fix is to increase the Timeout value in the 'Properties' field of the Modbus Server 1.

The aim is to have the Timeout value as small as possible, but not too short that errors occur. Experiment with 50ms changes in the Timeout value until the minimum value is ascertained. The wiki file has the Timeout set to a default of 500ms. The best Timeout value this writer could achieve was 450ms for his Hybrid inverter and network. The Timeout value for an ancillary, ethernet connected, 10 year old Fronius inverter was required to be set to 4000ms.

 

Polling Cycle

Each Modbus sensor within the Template file has a Polling Cycle set to a default of 10 seconds. The Miniserver will try to achieve this polling interval, however if it can't, it will self-regulate to achieve the maximum polling possible. For example, all sensors can be changed to have a Polling Cycle of 5 seconds and the Miniserver will still successfully poll all sensors, however at a polling cycle that is achievable.

The wiki file has 18 sensors that are being polled with a Timeout of 500ms -

18 x 500ms = 9000ms (9 seconds).

We can see that these 18 sensors will take at least 9 seconds to cycle through as a minimum.

 

The wiki file includes a tab to assess the exact performance of the Modbus polling (4. Modbus Optimisation). This logic will measure and display the maximum achieved polling rate.

 


To see the maximum polling rate achievable with the number of sensors created -

1. Find and set the minimum achievable Timeout,

2. Set all Modbus sensors to the minimum value of 5 seconds,

3. Observe the 5 minute average in the Hybrid Modbus Polling Rate depicted above,

4. Set the polling rate of all sensors to the 5 minute average plus some margin.

 

Step 4 is not essential, however setting the polling interval to an achievable value will ensure that there is a known and consistent refresh rate of the Modbus data. The image above would suggest a Polling cycle of 10 seconds.

 

Conclusion - Both the 'Timeout' value and the 'Polling Cycle' can be considered as a 'tuned-pair'.  The default Template settings of 500ms Timeout and 10 seconds Polling cycle 'should' work successfully for a wired network with a modern Hybrid inverter.


2. Control the battery charge rate and discharge rate.

 

a. Charge Limit, Discharge Limit or Both

The Fronius instructions for controlling the battery charge rate and discharge rate can be found on page 94 (Basic Storage Control Model) by searching for the document Fronius Datamanager - Modbus TCP and RTU. This document refers to the attributes Charge Limit and Discharge Limit. These are measured in percent and can be confused with the Storage Charge Level (also measured in percent). Both Charge Limit and Discharge Limit adjust the rate of charge/discharge in percent. Storage Charge Level (often referred to as SoC) refers to the useable battery level in percent.

The register StorCtl_Mod controls the charging or discharging behaviour -

 

StorCtl_Mod = 1 (activates Charge Limit)

StorCtl_Mod = 2 (activates Discharge Limit)

StorCtl_Mod = 3 (activates both Charge and Discharge Limits)

 

b. Battery Charging/Discharging Options

The battery charging options can be considered to fall into four quadrants that define the direction of energy flow -

Charge Limit with positive value (0 to 100%) - Charges the battery from solar, up to the maximum rate applicable to the battery size (which is dependent on the number of modules installed),

Charge Limit with negative value (-100% to 0) - Discharges the battery to the household needs, followed by the balance going to the grid if excess flow is present. The battery will discharge over and above the set percentage if household needs are present.

Discharge Limit with positive value (0 to 100%) - Discharges the battery to the household (up to the maximum rate applicable to the battery size, or the household requirements - whichever is the smaller value).

Discharge Limit with negative value (-100% to 0) - Charges the battery from the grid, up to the maximum rate applicable to the battery size.

 

In all cases, 100% reflects the rate available based on the number of battery modules installed -

For a 12kWh Fronius Solar Battery (8 module system), 100% = 6656 watts; 50% = 3328 watts

For a 6kWh Fronius Solar Battery (4 module system), 100% = 3328 watts; 50% = 1664 watts

 

For other Fronius inverter/battery combinations (ie. Gen 24), the value represented by 100% can be ascertained by polling the Modbus register WchaMax.

 

Both Charge and Discharge Limits - If it is desired to discharge the battery at a constant rate (ie. ~3328 watts on a 12kWh system), StorCtl_Mod should be set to value 3. Concurrently, Charge Limit should be set to -50% and Discharge Limit should be set to +50%. With these settings, the Discharge Limit will prevent the battery discharging greater than 3328 watts (even when household demand is greater), while the Charge Limit will ensure the battery continues discharging at 3328 watts (even when household demand is less). The setting is represented in the Loxone app as follows -

 

 

Both Charge and Discharge Limits (continued) - If it is desired to charge the battery at a constant rate (ie. ~3328 watts on a 12kWh system), StorCtl_Mod should be set to value 3. Concurrently, Charge Limit should be set to +50% and Discharge Limit should be set to -50%. With these settings, the Charge Limit will prevent the battery charging from the sun at greater than 3328 watts (the excess will be fed to the grid instead), while the Discharge Limit will keep the charge rate at 3328 watts if the sun is insufficient (using grid power if required).

 

The control logic and user-interface is included with the above Fronius Modbus Wiki.Loxone file, refer to tab 2. Battery Charge Control

 

It is recommended to retain the layout and position of all components on the tab '2. Battery Charge Control'. This page will be added to in subsequent downloads with additional features.

 

3. Alter the minimum battery reserve.

The battery State of Charge (SoC) is a percentage that is calculated from the Watt-Hours available in the battery. A browser call can be made to the following address to see the raw data that informs the SoC -

http://IP_Address_of_inverter/components/readable

 

The two values to refer to are -

a. Estimated_Capacity_Maximum 

b. Estimated_Capacity_Remaining

 

Estimated_Capacity_Maximum is a measure of the storage capacity in Watt-Hours of the battery and will reduce with battery age. Estimated_Capacity_Remaining as a proportion of Estimated_Capacity_Maximum will give a percentage value. This is the SoC.

It can be seen that the SoC value will give an accurate percentage of useable capacity as the battery ages over the years.

 

The Fronius Battery has a minimum SoC of 0% with default 'automatic' selection. With 'Emergency power Operating mode' in automatic, this becomes a minimum of 7%.

In practice, the battery never discharges completely to 0% SoC. It will stop discharging when a minimum cell voltage is reached at 2.70 volts. This equates to between 1-4% SoC.

 

The MinRsvPct Modbus actuator can be found in the Symo Hybrid template file under 'Actuators'. Create a Virtual Input that adjusts between 0-100 with a slider. The formula is as depicted in the image -

Note that MinRsvPct can be changed via the Modbus command or via the inverter settings webpage (Min SoC in the Energy Management tab). Whichever interface has the higher value will take priority.

An effective option is to set Min SoC in the inverter settings webpage to 0%. The Modbus command will then always take priority with one exception -

If the Emergency power Operating mode is set to Automatic, this will also override the Modbus command (if Remaining battery capacity is set to a higher value than MinRsvPct). Given that the minimum SoC available in Emergency Power Operating mode Automatic is 7%, the Modbus command is only effective to a minimum of 7% also.

 

4. Automating Battery Charge Control

 

Refer to tab 2. Battery Charge Control in the included project file. The provides a framework for modification to suit user requirements. Each component of the battery behaviour (Storage Control Mode, Charge Limit and Discharge Limit) can be varied using values in the associated Status Block. 

A Schedule block is incorporated and attached to each Status block. This is a common requirement for most installations. Automated battery charging may have different requirements for different seasons. The Schedule Block makes use of a separate Operating Mode for each month. This allows different analogue values to be output throughout the day and across the seasons.

 

a. Sunrise-Sunset Solar Schedule

 

In the Schedule pictured above, analogue values are output from AQ as follows -

Midnight to sunrise - Value 1

Sunrise to sunset - Value 2

Sunset to midnight - Value 3

Across the seasons, a separate analogue value is output from AQm as follows -

January Value -7

February Value -8

March Value -9 etc.

 

By utilising these outputs, different charging rules can be effected in the applicable Status Blocks.

Note that copying the Schedule block from the wiki file into the active project won't work. The Schedule block is very complex and relies on pre-existing 'Operating Modes' and 'Operating Times' to be available in the Config. If you do wish to copy the Schedule block, you must first -

  1. Manually create twelve 'Operating Modes' exactly as pictured - (1. January Solar     2. February Solar     3. March Solar etc.)

  2. Manually create twelve 'Operating Times' - (1. January Solar Schedule     2. February Solar Schedule     3. March Solar Schedule etc.)

  3. Each 'Operating Time' needs the Assigned Operating Mode set to the applicable month. ie. 1. January Solar Schedule - 1. January Solar - Time span every year - 1/01/2020 to 31/01/2020

  4. Only after these manual entries are completed can the Schedule Block be copied into the active project and bring the times pictured above with it.

 

 

b. Time-of-Use Solar Schedule

 

An alternative charging regime may involve Time-of-Use periods. For this Schedule, analogue values are output from AQ as follows -

Low Tariff - Value 1 from Sunday to Friday 2200 - 0600,

Low Tariff - Value 1 from Saturday 1200 - Sunday 0600,

High Tariff - Value 2 for all other times.

 

In the Fronius Modbus Wiki.Loxone file, an example is displayed for Low Tariff control. Discharge Limit is set to 0% (the battery will charge from the sun but won't discharge to the household) when cheap electricity is available from the grid. When High Tariff periods resume, normal discharge from the battery occurs.

Alternatively, Discharge Limit could be set to -100% to charge from the grid in Low Tariff periods, with discharge from the battery occuring in High Tariff periods. Many variations of arbitrage can be effected where rules allow.

 

5. Automation in the Loxone App

A useful tool is to have a switch in the Loxone App to enable automation features. The following control set is provided in the Fronius Modbus Wiki.Loxone file -

 

 

With Charge Control AUTO switched to On, Storage Control Mode, Charge Limit and Discharge Limit will be controlled by the scheduling detailed above.

 

Some special programming in the Config is necessary to effect the automation of the controls. This method of control ensures that the Loxone App will always reflect what is occurring in the back-ground automation. Whatever automation logic is developed, the net result is to change the indications in the Loxone App. These changes then flow through to the actuators.

A Virtual Output will control the associated Virtual Input (the Virtual Input being what is visualised in the Loxone App). In effect, this is an invisible, internal connection between the components in the Loxone Config.

 

a. The Virtual Input must be created first. In the example below, the item 05. Charge limit is demonstrated. This Virtual Input can be adjusted between -100% to +100%.

b. Refer to the properties of the Virtual Input. The 'Connection' line will specify a value. In this case it is VI2. Note this value for future reference.

 

c. Now create the Virtual Output.

d. The Virtual Output parameters must include the Username, Password, Miniserver IP and Port in the format depicted below -

 


e. The Virtual Output Command is set up as follows -

 

 

f. The Virtual Output Command for ON must include the 'Connection' (VI2) noted earlier. This is written /dev/sps/io/VI2/<v>

 

Whenever values are now passed through the Virtual Output, they are transferred to the Virtual Input. This method can also be applied to switches in the Loxone app as a means of feedback.

 

6. Inverter Status Feedback

The attached Fronius Modbus Wiki.loxone file includes a tab called Rate Limit Status. This logic creates the following entry in the Loxone app -

 

 

The preceding section described how the back-ground automation updates the Loxone App interface. This is what the Miniserver 'thinks' the inverter is doing. The actual status of the inverter is processed by Modbus read sensors. This is displayed at 02. Rate Limit Status.

 

Please make comments or questions in the Loxforum thread -

https://www.loxforum.com/forum/faqs-tutorials-howto-s-aa/132379-fronius-hybrid-with-modbus-tcp