good afternoon youtube it's just after 12 noon and my diversion loads have kicked in i guess this one
just turned off clamp one i think the refrigerator just started but here's diversion load two running
and i've cleaned up the code and actually last night i moved all the code that i have
for diversion load two over to diversion load one so they're both running the identical same code
and you can see here i've got minus 10 watts so this should bump up by about one percent maybe two
just depends on the rounding i guess it went up two percent so now we're minus three watts
so i think the diversion load is trying to chase the hybrid inverter is a hybrid
inverter the battery charging current is probably tapering off so this excess power keeps climbing
every 15 seconds and so the diversion load is trying to keep up with that and i think i've
got all my old logic removed i had kind of a mix of old and new logic in here because initially i
took my original logic that worked off of the whole house power and used that for diversion
load one and then i got that roughly working and then i moved that code over to diversion load two
and then modified it to get it working so in the process i found a lot of my old logic had some
assumptions built into it the main fact that i was working with was my old home energy monitor only
reported absolute value power so 100 watts coming into the house looked like 100 watts leaving the
house my old code tried to prevent the power going below about 25 watts by turning on an extra light
bulb i think it was a 75 watt bulb so once i replaced my home energy monitor and finally got
it configured to read negative power i was able to get this code working where it just exactly tracks
this power so the way everything is driven this home energy monitor takes a snapshot of the power
coming into the house at the main breaker panel and then produces this report with the two clamps
and then based on that the code that's controlling this runs and then figures out from this reading
here if it's negative i need to increase the diversion load if it's positive like it is now
see i overshot a little bit so this is going to go down by maybe three percent yeah went from 28 to
25 although that is too little now so it's going to probably go up to here it'll probably go from
25 to 27 because that was minus 11 now it's plus three and i'll show you why that happened here
i did a measurement of the dimmer percentage from 10 to 100 and then measured the watts and you can
see it's not exactly linear so down at the low end it's really low like 10 should be 60 watts and 20
should be 120 but it's only 89 actual watts so we're a little low down here and then up at the
top end we're a little low too the problem is yeah it's not quite a linear load so that's why
sometime overshoot undershoot but it tries to keep it within roughly six watts of zero let me
show you the logic that i have here so i finally figured out a good way to show this here this is
the p-leg program logic event generator and this is their main screen so you have your logic inputs
conditions actions device triggers schedules timers properties counters all of that and this
relationship graph i've looked at it before it was always a little confusing and i finally figured
out how to make it work a little better here let me rearrange these and then i'll come back with
okay i think i got everything to fit so this is the logic this is diversion load two i have the
exact same logic for diversion load one so i'll just go over one of them if we can go up to legend
the dark green is a trigger then you have a schedule or timer properties device properties
and then there's conditions and actions and then notifications this guy here is kind of the core of
the whole control algorithm this is what i call my clamp check timer so this is just a one shot
interval timer that runs for some period of time it goes true and then after that interval it turns
off so basically the logic here is if it's during the daylight the power is below one
watt and the timer is not already running start the timer and what it does if you look here
the time value is two seconds so it says wait two seconds and then you can see the timer feeds into
all of these other conditions one is restart the timer and one is change the diversion load
so those are the end actions but what happens sort of in parallel is you've got these device
properties here this property is a copy of what the power on line two is and then this property
is what is the dimmer set to right now and then this is that variable that i put in there the 6.54
watts per increment on the dimmer this is an integer zero to a hundred this is
a floating point this is a floating point this increment it computes a floating point
increments it could be 6.2 increments or 0.5 or 0.1 this logic here computes a floating point
value for the dimmer so it might come back and say okay the dimmer is 22.1
and then this condition here takes a look at the dimmer setting which maybe it's 22
as an integer and compares it to 22.1 and says ah that's not really significant it's got to
be at least one dimmer step higher or lower and then decides if the change is significant i call
the change load and if it's not significant i just restart the timer this action here just starts the
timer again with a 15 second delay and likewise this starts the timer with a 15 second delay
but it also writes this new diversion load setting to the light dimmer which then populates this
variable with the new setting and then 15 seconds later the energy meter reads the power again
this number updates all of these calculations happen and then two seconds later because this
timer is running two seconds behind the power meter approximately timer will expire and then
it will have a new value here and then it does the same check do i have to update it or not and
whichever one it takes it starts the timer and it just runs and runs and then the only
other thing that happens is at the end of the day when this afternoon schedule expires
this one won't run this one won't run the timer expires it never gets restarted and everything
goes to sleep overnight basically wakes up the first time the power drops low and then it sits
here and spins this timer every 15 seconds all of these numbers get computed and then when the timer
interval stops it either changes the load or doesn't change it that's pretty much how it goes
oh i bet let's see let's look here see i bet my freezer was running and then it shut off because
we went negative here so now we're at plus 190 let's see what happens here because it completely
shut this off sometimes the numbers here don't update this number updated but these two here
haven't that's where sometimes you can't quite go by what the web page displays yeah there we
go now it finally updated so we were minus 170 so it cranked in 176 watts to cancel out that
176. and we didn't get quite get there there was another 16 so it bumped it up by a couple percent
and now we should be pretty close to zero and still minus eight okay it's going to bump it up
another one went up to 31. so yeah the one slight difference i have between diversion load one and
two is i have this one with a two second delay when it starts up this one has a four second delay
so the idea is this energy meter reports a sample every 15 seconds and that is what will wake up
these two diversion loads and when this one wakes up it waits two seconds before it does anything
and when this one wakes up it waits four seconds so when they both are running together
there'll be an update two seconds later this one will change and then another two seconds later
this one will change okay youtube i saw clamp one go like to negative two watts i don't know
somehow there's something running in the house today that's preventing it from going negative
see if we can get this to click on there we go it went to one percent so yeah it looks
like diversion load one is working with the new code because before my old code increment this
by five percent increment so i went five 5 10 15 and now i have my floating point increment
code so you see it went from zero to one and then back to zero now minus nine so it's going to bump
it up to two percent or one one or two percent i guess one yeah it went from minus nine to plus
eight roughly now that'll probably cause it to go back to zero and there it goes back to zero
and you can see this one has a slightly longer delay i have about four seconds delay between
when this reading happens and when anything with the dimmer happens or minus seven right there so
this should go to plus one and there we go which is six watts but yeah i thought i'd show you that
show you the relation graph hopefully that clears up how all of this is working
and yeah really cleaned up the code when i started getting negative
watt readings that was a huge game changer just made all the difference in the world because now
there's just one function to update the load and then another function to not update it basically
two main functions here plus a bunch of support calculations yeah i hope you enjoyed that if you
have any questions post up in the comment section down below here and as always thanks for watching