#Basic Solar Array & Backup Generator Control Script # by SemlerPDX Dec2022 define MinPowerRatio 0.25 #25% Battery Charge, adjust as desired define MaxPowerRatio 0.75 #75% Battery Charge, adjust as desired define StationBatteries -1388288459 #Large Station Batteries define CableAnalyzers 1036015121 #on power line from solar array to batteries define SolidGenerators 813146305 #Solid Fuel Generator(s) #Signal Wire connection facing 0 (North, see offset note below) define SolarArray -1545574413 #Heavy Dual Solar Panels (basic dual == -539224550) #Signal Wire connection facing 180 (South, see offset note below) define DaylightSensor 1076425094 #Sensor face pointed towards sky #Offset value is relative to array & sensor orientations listed above, is NOT the ONLY way define RelativeOffset 90 #0, 90, 180, or 270 (see solar tracking guides) define MorningV 165 #point at morning sun to get this Vertical value define MorningH 186 #point at morning sun to get this Horizontal value main: yield #Engage generator(s) if charge is below minimum until above maximum lb r0 Batteries Ratio Average lb r1 SolidGenerators On Maximum select r1 r1 MaxPowerRatio MinPowerRatio slt r0 r0 r1 #Check time of day lb r1 DaylightSensor SolarIrradiance Maximum #Engage Backup only when solar panels are in darkness sgt r0 r1 sb SolidGenerators On r0 #Reset panels facing East at night blt r1 1 resetAngles #Follow Sun (during daytime only) lb r0 DaylightSensor Vertical Maximum lb r1 DaylightSensor Horizontal Maximum add r0 r0 RelativeOffset add r1 r1 RelativeOffset sb SolarArray Vertical r0 sb SolarArray Horizontal r1 j main resetAngles: #Point array at morning sun sb SolarArray Vertical MorningV sb SolarArray Horizontal MorningH j main