Pretty Good Extra Utilities Solar Generator Controller
Published: 2020-12-30 14:19:15

---
title: Pretty Good Extra Utilities Solar Generator Controller
published: true
date: 2020-12-27 13:05:00 UTC
tags: 
canonical_url: https://kevincox.ca/2020/12/27/solar-generator-controller/
---

<main><p><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#my-solution">Skip to the Solution</a></p>

<h2 id="background"><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#background">Background</a></h2>

<p>The <a href="https://ftbwiki.org/Solar_Generator_(Extra_Utilities)">Extra Utilities Solar Generator</a> is an interesting Minecraft generator. It requires no input and generates power depending on the current sunlight (which is primarily based on the time of day). The aspect that makes it interesting is that when it is collecting sunlight it doesn’t transmit any power. This means that it will charge itself up during the day and will discharge either at night or when manually toggled via a redstone signal. Furthermore switching between the two modes has a transition period where it is nether charging or transmitting.</p>

<p>I assume the intent is that it can get you a decent source of power early on especially for “interactive” uses, but they won’t passively provide huge amounts of power to something like a quarry and aren’t really a great option to spam down for late-game power. Assuming you don’t touch them all all they will fill their buffer during the day, and unload at night. Meaning that you only get 1 buffer of energy (1kRF) per game day. However they take much less than a day to charge so if you want to get maximum power from the generators you need to toggle the discharge during the day.</p>

<p>Early-game it makes sense to just slap a <a href="https://minecraft.gamepedia.com/Lever">lever</a> on the Solar Generator for on-demand power however it soon makes sense to automate the process. I have seen simple solutions using a light detector. However this is both mostly unnecessary (since they discharge at night anyways) and won’t give you max throughput as it only performs a single charge cycle per day.</p>

<p>I aimed to do something a bit better. It will simply charge until full, discharge until empty, then repeat. The main goal is to continuously do full charge+discharge cycles, minimizing the time wasted in the transition period or by charging when already full. This has a couple of imperfections but it is close enough for me:</p>

<ol>
  <li>Optimally it would go into night with a full charge (assuming we aren’t skipping nights) as there is plenty of time to discharge during the night. So a better system would switch to charging before nightfall even if not completely discharged to maximize collected power during the day. However implementing this properly requires a complicated comparison between the time of day and the charge level and needs to take the fluctuating charge rate into account so I decided to skip this.</li>
  <li>If there is nothing pulling power and the stored charge is low it should start charging again. Otherwise it will just sit at low power doing nothing, then when something actually starts to use the power it will only get a small amount before the solar generator flips back into charging. This is very complicated to implement as you would need to track the time since the last change of charge level (charge level is reported in 16 steps). Furthermore since redstone signals degrade with distance it would be very difficult to implement this for the lower charge levels where this feature is most important. However I think many factories pull constant power anyways so this is a lot of effort to improve a minor edge case.</li>
</ol>

<h2 id="my-solution"><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#my-solution">My Solution</a></h2>

<p>My solution is fairly simple, I suspect it could be tweaked to a more compact layout. However the total build cost is quite low.</p>

<p><img src="https://ipfs.io/ipfs/QmNriYhSEeXrqGvjiKQ4AdX25of2ENcJS9pf5QNS82Bp1b/plain.png" alt="image of circuit" crossorigin=""></p>

<h2 id="extent-detector"><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#extent-detector">Extent Detector</a></h2>

<p><img src="https://ipfs.io/ipfs/QmPdshn17W8znSmzF54up8ayfMbqzZP4tAozJzWioM3Roq/extents.png" alt="image of circuit with extent detector highlighted" crossorigin=""></p>

<p>The circuit detects when we are at either extent of the battery’s charge. The generator produces a redstone signal between 0 and 15 for the charge level of the internal battery. The left branch detects the zero case and the bottom branch detects the 15 case. By combining these together we can lock the <a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#latch">latch</a> for every value but these two extents.</p>

<h3 id="detect-0"><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#detect-0">Detect 0</a></h3>

<p>This simply uses a <a href="https://minecraft.gamepedia.com/Redstone_Repeater">Redstone Repeater</a> to take the 0-15 output and produce 0 for 0 and 15 for anything else. This is then negated with a <a href="https://minecraft.gamepedia.com/Redstone_Torch">Redstone Torch</a> to produce 15 for 0 and 0 for everything else.</p>

<h3 id="detect-15"><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#detect-15">Detect 15</a></h3>

<p>This is a simple comparator against a redstone torch to produce 0 for 0-14 and 15 for 15.</p>

<h2 id="latch"><a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#latch">Latch</a></h2>

<p><img src="https://ipfs.io/ipfs/QmNgjiirbxAdgj1dhunbNDqhEJCstUjd1JiFVXqu9UvqLB/latch.png" alt="image of circuit with latch highlighted" crossorigin=""></p>

<p>The most important part of the circuit is the latch. This ensures that the state is only changed when the storage is full or empty. This uses a native Minecraft feature where two Redstone Repeaters next to each other form a <a href="https://minecraft.gamepedia.com/Redstone_Repeater#Signal_locking">multi-block flip-flop</a>.</p>

<p>When the latch is unlocked we use the value from the <a href="https://kevincox.ca/2020/12/27/solar-generator-controller/#detect-0">Detect 0</a> condition to set the output to <code>charge != 0</code>. This way when the charge is 0 we disable transmission (start charging) otherwise we enable transmission (this is always 15).</p>

<p>One important detail is to change the <a href="https://minecraft.gamepedia.com/Redstone_Repeater#Signal_delay">delay of the output repeater</a> to 3 ticks. This ensures that the correct value is latched.</p>