LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Smart Home / PV Surplus Control: Hysteresis, Timers and Thresholds...
Read this article in other languages:

PV Surplus Control: Hysteresis, Timers and Thresholds for Switching Loads

PV Surplus Control: Hysteresis, Timers and Thresholds for Switching Loads

Jump to the interactive example ↓

Find the bug ↓

Contents
  1. The Feedback Nobody Plans For
  2. Two Thresholds Instead of One
  3. Three Timers, Three Different Jobs
  4. Which Number Is Actually Being Measured
  5. What a Battery Puts In the Middle
  6. Loads That Modulate Do Not Have a Threshold
  7. Questions and answers
  8. Sources

Surplus control starts as one line: if the surplus exceeds two thousand watts, switch on the heating element. It is correct, it is obvious, and it produces a relay that clicks every ten seconds until something gives out.

The reason is in the sentence itself. The load consumes exactly the surplus that permitted it, so the condition that switched it on is false one measurement later. Everything below is about the fact that a control loop cannot use the same number as its trigger and its consequence without saying how far apart the two are allowed to be.

Two panels over ninety minutes: with one threshold the measured surplus oscillates as a square wave and the relay switches thirty-seven times; with two thresholds and delays it switches twice
The grey dashed line is the surplus without the load and is identical in both panels. Only the rule differs.

The Feedback Nobody Plans For

A two-kilowatt element switched on at a surplus of 2200 W leaves 200 W. The automation reads 200 W, finds it below the threshold, and switches off. The surplus returns to 2200 W, the condition is true again, and the cycle repeats for as long as the sun holds. Nothing is broken; switching the element on changes the very surplus that the rule checks.

The count is what makes it expensive. A contactor rated for 100 000 mechanical operations sounds generous until the loop produces one every few seconds. At the rate in the upper panel it is used up in about two months, and the failure mode of a welded contactor is a load that stays on all night.

Two Thresholds Instead of One

Hysteresis separates the switch-on point from the switch-off point far enough that the load’s own consumption fits between them. The on threshold is the load plus a reserve; the off threshold is not the same number but a small amount of import, which is the only honest sign that the surplus has actually run out.

Text
on    surplus ≥ load + reserve     held for ≥ 3 min
off   import  ≥ 200 W             held for ≥ 5 min
      and runtime ≥ 15 min

2000 W element, reserve 200 W
  on at a surplus of 2200 W
  after switching on: 2200 − 2000 = 200 W surplus  → no reason to switch off
  without hysteresis: 200 W < 2200 W                → off again immediately

The gap between the two thresholds has to be at least the rated power of the load. Anything narrower and the load’s own draw crosses back over the off point, which is the same oscillation with more arithmetic in front of it.

Three Timers, Three Different Jobs

ParameterWorking valueWhat it prevents
On thresholdload + 200 Wa load that draws more than is available
Off threshold200 W of importswitching off on every passing shadow
On delay3 minreacting to a gap between two clouds
Off delay5 minswitching off during a cloud that is about to pass
Minimum runtime15 minshort cycles on a heat pump or compressor
Minimum pause10 minan immediate restart after switching off

The two delays are not symmetric on purpose. Switching on late costs a few minutes of export at the feed-in tariff; switching off late costs a few minutes of import at the retail price, which is three to four times as much. So the off delay is the one to keep short if either has to give.

Minimum runtime is the parameter that gets left out and the one that matters most for anything with a compressor. A heat pump or a fridge-like load pays for a start with wear and with a burst of inrush current, and hysteresis alone does not stop a rule from starting it four times an hour on a broken-cloud afternoon.

Which Number Is Actually Being Measured

Surplus is a property of the grid connection, not of the roof. The number to read is the meter at the house connection, signed: negative for export, positive for import, or two separate sensors that never both show a value at once. Anything derived from inverter production alone is blind to the household consumption underneath it and will switch a load on into a running dishwasher.

Two details decide how well that reading behaves. Smart meter interfaces report at their own pace – between two seconds and thirty – and a rule that samples faster than the meter reports is comparing a fresh value with a stale one. And short averaging is worth more than precision here: a five-second mean of the grid power is a far better trigger than an instantaneous reading that is mostly kettle.

What a Battery Puts In the Middle

With a battery in the house, the surplus at the meter is what is left after charging, which means the battery and the switched load are competing for the same watts and the winner is whoever the rules let go first. Give the battery priority and the element never runs; give the element priority and the battery never fills before evening.

The arrangement that survives a winter is a state of charge condition on top of the power condition: the load may run only above a certain charge level, so the battery gets the morning and the load gets the middle of the day. That single extra condition also stops the case nobody notices – a load happily consuming surplus that the battery had already stored, discharging it at a round-trip loss of ten to fifteen per cent for no gain at all.

Loads That Modulate Do Not Have a Threshold

A wallbox does not switch, it scales – but only within limits, and the lower limit is the one that turns it back into a switching problem. Six amperes is the minimum charging current, which is about 1.4 kW on one phase and 4.1 kW on three, and below that a car does not charge slowly, it does not charge at all.

So the on threshold for a three-phase wallbox is 4.1 kW of surplus, not zero, and everything between zero and that figure is a range in which the only options are one phase or nothing. Switching between one and three phases is itself a load change of nearly three kilowatts, which needs its own hysteresis and its own minimum runtime – the same three parameters as the heating element, applied to a decision that looks like a smooth dial and is not.

Questions and answers

Can a moving average replace hysteresis?

No, the two solve different problems. An average smooths out brief spikes such as those from a kettle, but the load that has just switched on lowers the surplus by its full power, and once the averaging window has passed, the rule sees exactly that value and switches off as before, only later. The five-second mean from the article therefore belongs in front of the hysteresis, not in its place.

What happens when two loads, each with a rule of its own, see the same surplus?

If the surplus is enough for either load but not for both, and the on delays are equally long, both switch on at the same moment and together draw more than is available. The meter then shows import, both off delays start, and after the minimum runtime both go off again. It is the same oscillation as a single load without hysteresis, one level up: each rule is correct on its own, but neither knows that the other is counting on the same watts.

The meter solves the problem by itself if the rules decide one after the other. It sits at the grid connection and sees the sum of all loads, so once the first load is running, only the remainder is left for the second. Staggering the on delays is enough for that, for example three minutes for the preferred load and six for the other, as long as the gap is longer than the time the meter takes to report the first load. Switching off works the other way round: the lower-priority load gets the shorter off delay, so that under import it is switched off first and the preferred one keeps running.

How long does a contactor last once minimum runtime and minimum pause are in place?

Many years, and the figure can be worked out. With a minimum runtime of 15 minutes and a minimum pause of 10, a full cycle takes at least 25 minutes, so at most 2.4 cycles per hour are possible. Ten hours of surplus a day give 24 cycles, or 48 operations if every switch-on and every switch-off is counted separately. The 100 000 operations from the article then last a good five and a half years, even if on every single day one cycle followed the next at the shortest permitted interval.

Without the two timers, the number of operations depends on the weather and on the meter’s reporting interval and has no upper limit; with them it is capped, whatever the clouds do.

Learn by trying

Why does the relay switch so often?

One sequence, two rules: compare a single threshold with separate on and off thresholds. Adjust the gap and count the state changes.

Changes with one threshold
Changes with two thresholds
Eleven readings in time order
ReadingOne thresholdTwo thresholds

Both start off. One threshold: on at or above the on threshold, otherwise off. Two thresholds: on at or above the on threshold, off only below the off threshold; between them, keep the previous state. Fixed readings before the switched load consumes power. No feedback, minimum run time, measurement errors or delays simulated. This shows state logic, not a complete PV controller.

This module runs in your browser and does not send or store your input.

Reference ↗

Learn by trying

One minute: can you spot the mistake?

On at 2,000 W, off below 1,500 W. The relay is already on; the next reading is 1,800 W. What happens in this model?

Reference ↗

Find the bug

Explore

Find the bug

A problem, two clues and your decision. Examine the clues first, then see what your fix changes.

  1. The problem
  2. Examine the clues
  3. Test a fix

Read the related article →

PNG with settings, result and article link. Created locally only when you click.

These exercises calculate in your browser. The learning module does not send your answers.

Explore more experiments →

Terms you can try

Explore

Terms you can try

A short explanation and a small experiment make each term easier to understand.

Hysteresis

Switching on and off use different thresholds. Between them, the previous state is retained.

Read the related article →

Quick explanation

Read the related article →

These exercises calculate in your browser. The learning module does not send your answers.

Explore more experiments →

Your learning path →

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA to protect against spam.

Write a comment

Experience with other devices or integrations and questions about the setup are welcome here.

The email address is not published. Required fields are marked with an asterisk.