How can I get this redstone blast door to do what I want?

I'm working on expanding my Minecraft Redstone experience and contraptions. Here, I have a 2 blocks high x 3 blocks wide section of a tunnel with a track approaching it that is meant to act as a "blast door" or "flood lock". The minecart arrives at the detector rail, the three pistons in the ceiling and floor retract, and the one in the side pushes the rail out, delayed slightly. Perfect. enter image description hereenter image description here

The problem, however, is when the cart moves through the gate and the blocks return to their original location. The yellow block that the rail is resting on gets pushed up, taking the rail up with it (and both sides) immediately. Then, the side piston retracts, taking the yellow wool block sideways, snapping the rail into three pieces. enter image description here

The wiring is fairly simple (which is probably my downfall).

This is the wiring for the "lower" pistions. The redstone torch (next to the detector rail) turns off, retracting the pistons. enter image description here

The wiring for the upper section is equally simple. The redstone goes up and onto the area where the two glass sections are, hitting the repeaters and triggering the pistons. enter image description here

Finally, the wiring for the track piston. Delayed and inverted this is most likely to be the issue. enter image description here

What can I do (is it even possible) to get this to work?


Solution 1:

I've made a video of a working example:

All you need are properly calibrated repeaters (4 ticks each), a "short-cut" for the door pistons and an inverter on one of the system parts.

Solution 2:

What you need is for the doors the change both before and after the track moves. What you want is a separate track of repeaters to keep the doors open for longer so that the track retracts before the door closes.

Solution 3:

Adding a second connection to the blocks in addition to the other one but with a delay slightly longer than the railtrack one should do the trick.