Guys,
I have my 3 inverters feeding me information - one part of which is state of charge (SOC) of the batteries that are attached to each unit.
These will slowly creep out of sync over time - i would like a way dynamically vary the SOC to try and balance them all up
So lets say
- AvailableSolar = 3000w
- Number of inverters online = 3
- SOC1 = 30, SOC2 = 34, SOC3 = 38
At the moment i am taking the AvailableSolar and dividing it by the number of inverters online to give me a charging rate that is then converted to a percentage for each inverter - they are all given the same rate - so 1000w per inverter translates to 20%
What i would like to do is (as a first crude measurement)
Find the inverter with the highest SOC
Find the inverter with the lowest SOC
Take 20% of the charge away from the inverter with the highest SOC and give that to the lowest inverter
So my function at the moment spits out (every 10 seconds) a single number - lets call it 20 in this case - which is telling each inverter to charge at 20% rate
So i would like to take the Highest SOC inverter and take 4% to to take it to 16 and add that 4% to the lowest to take it to 24%
So my question is how do i with the 3 inverters identify which one has the highest and lowest SOC
I thought i could read the global variables into function variables such as below and then put them into an array -this is not working - but surely there must be a simpler way ?
let sbpleftsoc = global.get("Battery.SBP-Left-SOC");
let sbpmiddlesoc = global.get("Battery.SBP-Middle-SOC");
let sbprightsoc = global.get("Battery.SBP-Right-SOC");
let inverterssoc = [sbpleftsoc, sbpmiddlesoc, sbprightsoc]; // Get max value of an array in Javascript
node.warn("inverterssoc = " + inverterssoc);
msg.payload = Math.max.apply(null, inverterssoc);
Craig