I've made an obsidian farm on my last few fortresses and in every case, it's gone rather smoothly. So I decide to automate the sequence this time. Surprisingly, the logic I constructed worked flawlessly.But Murphy reared his ugly head causing his own brand of fun.
First, the overall design of the factory.
Just a simple 20x20 pit a few Z levels deep. Each level has a drawbridge granting access (the bottom level has 2 drawbridges. One granting access to the fortress proper, the other granting access to the caverns. That way if something nasty spawns down there, I can use the obsidian farm as a killing chamber for unwelcome guests). At the very top of the pit is 4 10x10 retracting bridges. At two corners on the same edge are 1x1 drawbridges acting as floodgates for magma and water. At the opposite corner of each of those drawbridges are fluid sensors which will be described later.
In any case, the operation goes as follows.
1. Close the entrances to the pit and close the retracting bridges at the top.
2. Open the drawbridge for magma until the top is completely full of 7/7 magma.
3. Close the magma drawbridge, and open the retracting bridges.
4. Close the retracting bridges and open the drawbridge for water. Wait until full of 7/7 water.
5. Close the water drawbridge, open the retracting bridges.
6. Finally, open the entrances to the pit and proceed to mine the newly created obsidian.
Have done the above many times without a problem. So I figured automation was the next step. Upon consideration, I decided that the logic involved 5 states. For this description, the following terms are used:
Drop bridge - The retracting bridges that support the fluid while it's being supplied. These bridges are magma safe.
Magma source - The bridge controlling the flow of magma onto the drop bridge. Open = magma flowing.
Water source - The bridge controlling the flow of water onto the drop bridge.
Entrances - All bridges granting access to the casting chamber. Will control them as a single unit.
1. Idle - Entrances open. Magma and water sources closed. Don't care about the drop bridge.
Transition to Magma fill when control lever is toggled.
2. Magma fill. Entrances closed. Drop bridge closed. Magma source open. Water source closed.
Transition to Magma drop when full of magma.
3. Magma drop. Entrances closed. Drop bridge open. Magma and water sources closed.
Transition to Water fill when empty of magma.
4. Water fill. Entrances closed. Drop bridge closed. Magma source closed. Water source open.
Transition to Water drop when full of water.
5. Water drop. Entrances closed. Drop bridge open. Magma and water sources closed.
Transition to Idle when empty of water plus a delay long enough for stuff at bottom of pit to be converted to obsidian.
(e.g. long enough to the water to actually hit the bottom of the pit).
Nice and easy. Looking at the opening and closing of the drop bridge, it became fairly obvious that since the magma and water source bridges were both drawbridges and the drop bridge a retracting bridge that I could simple connect the drop bridge to the same triggers as I connect the magma source bridge and the water source bridge. So when the trigger for the magma source goes "off" the magma source is actually open, while the drop bridge is closed. So with two triggers (one for magma, and one for water), I could link each trigger to the appropriate source bridge and both triggers to the drop bridge and the drop bridge is handled automatically. No need to handle it separately.
Detecting full and empty required a couple of fluid sensors. I wanted them to reliably detect when the drop bridge was full, not merely covered with some depth of fluid. The random "skittering" of fluid levels was my concern. So I placed each fluid sensor at the opposite corner of the drop bridge from the fluid source that it was detecting. And Has flow going into the sensor via a diagonal connection. I figured that by doing that, I wouldn't get 7/7 fluid unless that corner of the drop bridge has been covered with 7/7 fluid for quite a while. The design was
######
#X^╬## Floodgate, pressure plate (set to trigger on 7/7 fluid), drawbridge.
####╔═
####║+ Corner of drop bridge
The drawbridge and floodgate are controlled by the same trigger so when one is open, the other is closed. Happily, they're also connected to the same trigger as what controls the fluid. So when magma is pouring in, the appropriate fluid sensor has its diagonal connection open and visa-versa.
So I figured that to detect a full condition, all I needed to do was see the appropriate pressure plate go active. As for the empty condition, simply detecting that the pressure plate was inactive wasn't enough. I had to detect the falling edge of the pressure plate. So the overall set of logic constructions I needed were 6 in all.
3 newton cradle memory cells. Instead of using power, gears and rollers, I instead used a 2x1 pit with a hatch cover at each end to provide the needed movement. A nice simple design using no power. One cradle was linked to the magma source and drop bridges. Another to the water source and drop bridges. And the third to the entrance bridges.
1 edge detector triggering on either edge of the control lever. So when the control lever was toggled, a single pulse would be sent out. For this I used the design at
http://dwarffortresswiki.org/index.php/User:Larix/MPL/3#Double-action_switch The pulse generated was sent to activate the entrance bridges newton cradle and the magma source newton cradle.
1 falling edge detector triggered by the magma sensor. For this I used the same design as above except I split track leading from the NW hatch cover & pit into two paths using derailment so I could place a pressure plate on the return track and only get a pulse when the magma sensor went inactive. That pulse was sent to activate the water newton cradle. The magma sensor was also connected to the magma newton cradle to deactivate it when the sensor tripped.
1 falling edge detector triggered by the water sensor. Same design as above. It's output was linked to deactivate the entrances newton cradle. And the water sensor was also connected directly to the water newton cradle to deactivate it as well.
So. Now for the introduction of Murphy.....
Throw the lever. The newton cradles for the magma source and the entrances both toggle, the appropriate bridges open and close and magma starts to fill. Nice.
Soon after the drop bridge is covered with magma, the magma source cradle toggles, appropriate bridges open and close and magma drops to the bottom of the pit. Soon afterward, the water cradle toggles, bridges open and close, then water begins to flow. Nice again.
Soon after the drop bridge is covered with water, the water source cradle toggles, bridges open and close. And water begins to drop. Going according to plan.
A SECTION OF THE CAVERN HAS COLLAPSED
WTF?!?!?! I've never gotten that warning before on my obsidian farm. Something odd is going on. Hit space to unpause things and let 'em continue.
After a few more COLLAPSED messages, things settle down and I can examine the situation.
The newton cradles and all the bridges, floodgates, and whatnot are all set as expected. The thing actually went through the complete cycle flawlessly. But the expected layer of 20x20 obsidian isn't quite right. It's mostly obsidian, but there are randomly scattered pockets of 7/7 magma within it. And on the Z level above, there's a few bits of 1/7 magma also randomly scattered. Hmm. I've never seen this before with my manually controlled obsidian farms. So I contemplated the situation and tried to figure out what happened.....
Well, when I was controlling things manually, I would notice after a magma drop that at the bottom, I would mostly see 7/7 magma with a few 6/7 magma tiles randomly skittering about while on the Z level above, there would be a few 1/7 magma tiles also randomly skittering about. Eventually, the 6/7 and 1/7 tiles would sit on top of each other and convert to 7/7 tiles until the bottom layer become full of 7/7 magma tiles with no 6/7's or 1/7's skittering about. So I think that when I was controlling things manually, there was enough time for this consolation to occur, while the automated system was too fast and the water dropped, reacting with the 1/7 tiles a Z level too high, causing the cavein notices when the newly formed obsidian blocks fell 1 Z level. This also caused the consumption of water so there were a few tiles in the main pool that didn't get wet and solidify. Ugly.
Now what to do to solve this problem? I see several different solutions. Each with advantages and drawbacks.
1. Put a longer delay between the dropping of magma and dropping of water. This would replicate what happened with I was doing things manually, but getting the delay right would be problematical.
2. Don't drop the magma. Instead have it sourced at the bottom of the pit in the first place. This would prevent two layers from being formed even temporary and avoid the problem entirely. However, it would limit me to casting a single layer of obsidian only and I sometimes would cast 2 or 3 layers on top of each other, then mine them all out. This would work with the minimum amount of effort, but limits flexibility.
3. Drop less magma. If enough magma was dropped so that the pit would be covered with at least 2/7 magma, but not enough to be covered with 7/7 magma, a second layer of 1/7 skitters ought not to last long enough for the water to fill up. This would allow me to cast multiple layers before digging. But creating the "short drop" is a problem.
I'm going to attempt to use solution 3. The "short drop" will be by having a 16x16 drop bridge placed 1 Z level about the current 20x20 drop bridge. I'll treat the 16x16 bridge just for magma and the 20x20 bridge just for water. Since the bridges are open when the appropriate fluid source is closed, the magma drop should just pass through the empty space that the water drop bridge occupies and it ought to be able to flow the 2 tiles to completely cover the bottom of the pit and in doing so result in an average fluid level between 4/7 and 5/7 which shouldn't be able to support a second later of skittering 1/7's for any reasonable length of time. No logic changes needed.