-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New InputFilter class #590
Conversation
This is great! Thank you! When will it hit a release? Thank you |
de02af9
to
1fcd5d8
Compare
I think the reason for this change got lost in between the other conversations, could you clarify the use case? I am not totally sure this is an appropriate change. To my mind the primary use case for the shaper is for things like load balancing and controlling the maximum current that can be delivered. It is much more of a safty feature and should be fast to react, both in terms of switching the current down and back up again. That is the reason we created this as a separate module rather than trying to make the divert fit that use case. At a minimum, I think to accept this PR it would need to be configurable and the default to be off, but waiting to hear the input on the use case. |
Like discussed, the main use case for this is to ensure that a safety feature is not responsible for a fast wear out of the relay! Attenuating the number of times that the relay goes on and off when the power consumption is going up and down! Like stated, a low pass filter would help, only when the relay is off and need to go on, because when the power is lowering, the ideia is that is instant! It's preferable that the power goes down and only some minutes latter goes up... Than waiting or delaying lowering the power and risk a power cut! Tks for all the time and attention dedicated to this issue |
Then IMHO the solution is to add the smoothing on activation as with the divert, so off instantly then apply the smothing to the recovery. I don't even think we should apply any filtering to the reduction of the current at all, even optional. |
That being said is it not reasonable to expect that the EVSE should be installed in situations where it is gauranteed at least 6A? Hense the Shapper having to turn off the current should be an exception should it not? |
In my personal situation I get a lot turn off while charging and continuing to use the house to other activities! And I have 32 Amps... A lot of people here in my country don't go over 20! In that situations the shaper is a must have! Ensuring that while the house is consuming more that the charger is lower or off... And when late at night that most of the house is idle, the charger can go full power! |
Ok point accepted, 32A for the entier property is fairly easy to use up if that is typical in some locations. I very much think that the correct solution to this issue is a configurable smoothing on the attack. I have never found a case yet where an arbitory time is the correct solution to a problem. |
At this point I'm good with either solution... If that results on my relay not going on and off several times because of momentary spikes or lows! |
It already goes to disable immediatly. It just takes 5mn to start again or more if needed until it's stable enough to start. I also have only 39A available and can override easily with my eletric heaters in winter. But it never got to the point of beeing under 6A , so couldn't test it |
@jeremypoulter , thinking of future shaper rewrite to prepare it for handling thermal throttling too and beeing more configurable. edit: I'm doing some test now, and I see an important point. Live power data are not updated in a regular interval. edit: don't merge yet, I have almost done doing the filtering and configurable part. Just have to test |
I did this to take update interval in the loop: `
|
I wouldn't do either, the thermal throttling should just be a separate module and both should create claims so can live outside of the EVSE manager and call it |
The math should be the same as already discussed elsewhere. The module needs to know the update interval of the power data in minutes and the time constant then needs to be a configurable value also expressed in minutes. Zero means no filter (immediate action). Every time the module wants to update the current setpoint it should get the last update interval in minutes and use this formula to come up with the filter factor: The result alpha is the filter factor used by the OpenEVSE today. So the implementation of the filter does not need to change. Only that the filter factor is now calculated instead of entered directly. I have not yet tried the @jeremypoulter idea of using the attack and decay filter factors yet because the weather here is so bad my PV installation barely produces enough power to cover my home's low power state: From @jeremypoulter simulation graphs I now think I better understand how the filters work and if my understanding is correct, I believe what @jeremypoulter proposes, using the attack/decay, is close to what is requested:
Elsewhere on this site we have a discussion where I request to add a configurable minimum disable time. So we adapt to new legislation and tariff structures. Or avoid using more power than the home installation allows. This should not be hard, as it almost exists today. There is a random timer for enabling the OpenEVSE to implement some kind of reacceleration scheme, avoiding all OpenEVSE's to enable at the same time. The configurable minimum disable time can be just the minimum value used in the random number generator. Is my understanding correct @jeremypoulter ? Based on the above understanding I have the attack filter factor set to 0.033 (5 minutes time constant) and the decay filter factor set to 0.5 (about 15 seconds time constant), allowing for some debouncing while high power duration is too short to trip safeties or get registered as a 15 minute sustained peak. |
Do we really need to let the Tau beeing configurable ? ( or just set in #define , i use 10 sec as time reference interval ) |
Yes, Tau needs to be configurable. I will try to clarify. First recapping above: Every time the module wants to update the current setpoint it should get the last update interval in minutes and use this formula to come up with the filter factor: Tau is the exponential filter constant in minutes. This is essentially the same intended functionality as the filter factors that are configurable now for attack and decay. Only the new function for these configurable parameters would become the filter time constants in minutes rather than the filter factors straight. In the time domain, the effect of the filter using only the filter factor as @jeremypoulter described depends on the rate at which the calculation is executed. This can easily be understood as follows: in the current implementation, when the filter calc is run, the new filtered value for a filter factor of 0.1, is calculated as 90% of the previous filtered value + 10% of the current unfiltered value. Every time this runs, the filtered value is updated accordingly. So one can see that the filtered value will move twice as fast in the time domain if the calculation is done at half the period. E.g. if you calc this every five seconds, the filtered value will move twice as fast as if the calc is done every ten seconds. So the behavior in the time domain also depends on the calc period. To transform the response of the filtered value to a fixed behavior in the time domain, the filter factor needs to be compensated for the calculation period. E.g. the filter factor needs to be changed so that the effect of a 10% share in ten seconds is the same as two x% shares in 2 times 5 seconds. So yes @KipK you could fix DeltaT to 10 seconds (0.166 minutes), but that assumes the update frequency of the data comes in exactly every ten seconds. And as you described before, that is not always the case. There is a timer that keeps track of the MQTT update period already. You can use that value just before the last update, in minutes, for the deltaT. The exponential function is needed for accuracy with the smaller time constants, as the simplified expression is an approximation that is only valid for tau much larger than DeltaT. Below is a graph showing the exponential and the approximation |
in fact I did it a bit differently. Any cons ?
This should be done ( or @pdhoogh formula ) for Divert too. For now Divert code depends too of a fixed data time interval |
@jeremypoulter I've rebased the PR with filtering and configurable UI is ok on shaper branch too. we now can just use timer based pause if the filter ratio is set to 1 using current_shaper_min_pause_time, |
Do I see correctly that you switched the variable names and see tau as the calc period, not the filter time constant? |
no EVSE_SHAPER_FILTER_TAU is a constant of 10 sec ( ideal world update refresh ) current_shaper_smoothing_factor is configurable over ui, default set to 0.03 "updt_time" is the real time we got between the last 2 update And there's also a current_shaper_min_pause_time set in the config, to add a minimal pause. |
Was thinking about this a bit, normally you would have a higher on value than off to stop this, eg off at 6A on at 6.5A. might be worth a try for both the shaper and the divert. Probably should think about splitting out the filtering/set point code into a common class... |
taking time to read @pdhoogh filtering explanations above ( quiet interesting thanks for that ) I'm trying to implement that now |
…ferent values and get the results back
damn, we were trying to simplify the setup, and will end with more parameters than before :) |
Here are the presettings I propose then :
|
I don't need more presets. The intention is now clear to me and I'm fine with it. |
@KipK I think those will work. Can you update the expected test results then I think this is good to go. |
I'll try to find some time tomorrow to update those. |
Maybe we could write a script to generate those tests.... |
yes if you can, I see there's a lot of data to update manually on this file. |
we're good to go. |
Good to go when the UI changes are merged |
@jeremypoulter I've merged inputFilter changes in master gui, we're ready to go on this one. I'll rebase newflags thereafter. |
Following #587 issue + discussion
Changed for a new generic inputFilter class not dependant of fixed sample frequency.
This will calculate automatically previous filter ratios depending of data submission delta ( thanks to @pdhoogh for taking time to explain what looked like dark magic to me )
Should probably fix some of the issues posted with graphic showing unprevisible divert results
shaper ok
Divert ok
UI2 gui ok (shaper branch)
UI1 gui ok (OpenEVSE/openevse_wifi_gui#98)