Power distribution between battery and PV inverter

Hi, thank you guys for the amazing open source project.

We are currently using OpenEMS to manage our battery and PV inverter using the controller io.openems.edge.controller.symmetric.balancing and io.openems.edge.controller.pvinverter.selltogridlimit.

Our purpose is to keep grid consumption >=0 W (reverse power to the grid is not allowed). In the experiment, this goal was achieved. However, we found that PV and battery inverter would compete for power generation.

Let’s say the office load is 1000 W, then PV would generate, for instance, 700 W and battery would generate 300 W. But the irradiance is enough for the PV to generate more than 1000 W. We do not want the battery to generate power while the PV is capable to generate it all by itself.

I have read the code and understand that these two controllers are indenpent from each other. The xxx.balancing controller will control the battery inverter while reading the meter. The xxx.selltogridlimit controller will control the PV inverter while reading the meter. Is there any method to meet our control purpose while ask the PV inverter to generate most of the power if it is capable of? Is there any other controllers that I am missing?

I am aware that OpenEMS is designed to be modularized. Different components (controllers, devices, etc) can be grouped to achive a specific function. But it seems there are sometimes when message passing between components is needed.

Let’s say we have only 2 battery inverters (no PV inverter) and we use 2 xxx.balancing controllers. Both controller would read the meter and control the output without knowing each other’s exsitance. If a 1000 W load is attached to the system, then both controller will read 1000 W grid meter power and set each battery inverter to generate 1000 W more power. This will generate 2000 W more power and the grid meter will read -1000 W and the controllers will try the balance again and again…

We are currently considering implement one single custom controller to control our 2 PV inverters and 1 battery inverter. I am not sure is this the best way so I want to hear from you guys.

Thanks!

Hi Jin Zhang and welcome to the Community.

It’s always amazing to hear how OpenEMS is used around the world; and by the way congrats for winning against our German team in the world cup :wink:

The problem you explain is indeed one of the more complex ones, that we are currently looking into how we could optimize them. The planned approach includes a global mathematical model with an optimizer/solver… but it is still in the very early phases.

In practice we prefer solving the “0 W” (or any other) feed to grid limit using a Hybrid Battery-Inverter (like a GoodWe ET).

If that is not an option, you could try to solve it by setting different limits to the Controllers with a hysteresis, i.e. set the PV-Inverter (via Sell-To-Grid-Limit) to “max 0 W feed-in” and the Energy Storage Controller to “100 W buy-from-grid” - maybe using a Peak-Shaving-Controller instead of Balancing… but I would have to think a bit how this would have to be configured in detail.

For your second example with two Energy Storage Systems there is already such a mathematical model in place, that takes care of this. In this scenario you configure both systems as ess1 and ess2 and add an EssCluster ess0. The Balancing Controller is than configured for this ess0 which internally takes care of distributing the power between the two ESS (depending on the defined strategy in the Ess-Power-Component).

Apart from that it is also a very valid approach to create a specific Controller for your use case if that solves the issue for you!

I’ll be glad to hear more about your project and provide help and input if possible. Please keep us updated here!

Regards,
Stefan

Thank you. That’s very useful information! Sorry for the delay. I will report the progress.

Finally we choose to implement custom controller for our purpose. As mentioned, it’s generally not allowed to feed power back to the gird here in Japan. Therefore we need to consider reverse power seriously.

I have tried the official controller with the standard PID filter. The problem is saturation would lead to slow response of inverters. Hence we implement the custom controller together with a custom incremental PID filter for better response time. The output of the incremenetal PID filter is set to be no higher than the current inverter output power plus a small constant. This could potentially lower the efficiency but speedup the response time since PID filter output can drop much faster than before when saturation happens.

There is the device called reverse power relay (RPR) in Japan to monitor reverse power and send alarm signal when it happens, as fast as 0.1s. We also want to intergate RPR in OpenEMS. But according to my understanding, OpenEMS handle events synchronously. The alarm signal from RPR is asynchronous. Is it possible to make OpenEMS response to RPR signal asynchronously? Sure it’s possible to read the RPR signal in every 1 second cycle. I am just curious is it possible to be even faster, 0.1s delay for instance, without shorten the cycle time (1 second is the limit for meters, inverters).

Thanks!

Thanks for following up.

If you have suggestions on how to improve the existing PID, I am very happy to hear them. In rest your solution sounds absolutely ok.

So if I understand you correct, you receive a ‘digital input’ signal which would have to trigger a Modbus request (‘lower/stop PV production’), right?

100 ms sounds tough for this in the current architecture (slow Cycle-time, process image, Java,…) - though not impossible.

If I had to do it I would try to see if the following approach works:

  • hard wired signal from RPR to inverter digital input (this is what we do with “Rundsteuerempfänger” in Germany). The signal would trigger PV reduction to zero or to a defined percentage level of max power.
  • use software to avoid this situation in the first place, e.g. via a PID filter and slow ramps

Regards,
Stefan

Thank you for the information!
We have also considered the first approach. The problem is we want finer control (reduce power output) instead of sending the shutdown signal directly, which seems very hard with current OpenEMS framework. For the second approach, we also applied to the PID filter to limit the PV output’s increasing rate. But reverse power also happens when power consumption drops suddenly, which can not be noticed in advance. Therefore we may need to use the first approach.
For the PID filter, we implement the incremental PID filter to prevent saturation.

	public int applyPidFilter(int input, int target) {
		// Pre-process the target value: apply output value limits
		target = this.applyLowHighLimits(target);

		// Calculate the error
		this.errorN0 = target - input;

		// Calculate P
		var outputP = this.p * (this.errorN0 - this.errorN1);

		// Calculate I
		var outputI = this.i * this.errorN0;

		// Calculate D
		var outputD = this.d * (this.errorN0 - 2 * this.errorN1 + this.errorN2);

		// Sum outputs
		this.output += outputP + outputI + outputD;

		// Post-process the output value: convert to integer and apply value limits
		this.output = this.applyLowHighLimits(Math.round((float) this.output));

		// apply tracking margin
		if (this.trackingMargin != null) {
			var upperLim = this.trackingMargin * (this.highLimit - this.lowLimit) + input;
			this.output = Math.min(this.output, upperLim);
		}

		return (int)this.output;
	}

The accumulation term is moved from the original I term to this.output and this.output can be limited to be no higher than current output plus a constant, as denoted by this.trackingMargin. In this way, the modified PID filter can react much faster.
Finally, we are considering join the OpenEMS Association e.V. and could you tell me how to apply?
Thanks!

Thank you for the insight. We will check if this improvement to PID could be used generally.

Regarding the immediate write to a Modbus Register; which from my understanding is the most obvious problem currently for your approach: there is currently an open PR to optimize scheduling of Modbus Tasks in the Modbus Bridge. It could be possible to introduce some kind of ‘Immediate’ priority for writes, so that they are executed ASAP. Would that help?

Regarding a membership, please send a mail to office@openems.io. Mr. Peter Eckerle, our Head of Office at the Association, can answer all your questions. Also see OpenEMS Association e.V. – OpenEMS. Thank you very much for considering a membership and supporting our idea of an open-source energy management for the 100 % transition to renewables!

Regards,
Stefan

That’s an interesting topic to be explored in the future. The modbus register should support some kind of rapid shutdown command.
Currently we apply the traditional method of sending alarm to DI input of inverters. The benchmark is also done and result shows around 0.2 second latency for the inverter from full power output to 0 W output.
For the membership, I will contact via the email address.
Thank you!