Since i accidentally discovered the awesome cheaty potential of the humble double ramp (automatically provides acceleration to minecarts, up to derail speed if one ramp has an impulse effect) i wondered about its possible applications. Self-derailing cells take a minecart, cycle it through a mere 3x2 tiles and shoot it out its 'exit' after a number of ticks. Depending on the parameters and direction of the minecart going in, that interval ranges from 90 to 200 ticks. Chaining several of these after one another has a nasty habit of imparting very unusual start parameters for different cells, so a long cycle may have highly unexpected return times.
1. The Oscillator
So, to get started, i carved a nice long track of self-derailer cells into a pristine level of stone:
Main loop to the right. As you can see, i engraved twelve chained-up self-derailers, but in the end blocked the twelfth - the one in the upper right corner - because the return time was too long. With only eleven, the cart makes the full cycle in almost exactly two days. Yes, an array of 35 by seven tiles, over two levels, and a cart takes a full two days (~2400 ticks) to get around _once_.
The self-derailer is the simple three high by two wide array you see here so often - the tracks engraved on the upper level are clearly visible. The arrays on the far right all receive the cart from the south (coming up a ramp) and send it out to the north. Here, the ramps all have a 'hanging loop' engraved consisting of a W->N and a S->W track corner. The cart always enters the pit from the south, getting down ramp and apparently impulse acceleration. If it's under derail speed, it leaves the pit to the west and cycles back to the south. Once it reaches derail speed, it leaves the cell to the north. Sometimes, the cart jumps off the ramp and slams into the far wall, landing on the northern ramp in the pit and climbing out via double-ramp shenanigans. It _can_ exit onto the 'middle' tile, thus that track corner on the upper level is necessary.
The bottom level is just a mess of up ramps and very short track bits, so i won't show it. There are two track-operated pressure plates down here, one to pick up the two-day full return signal and send it to the counter arrays, the other to send an extra tick to flip the daily counter. I had linked up the 'week' counter before the first testing run, so didn't want to establish another seven hatch links.
2. Counting the days
Now we got our regular tick, but how to turn that into an actual readout?
Turning a single tick into a regular signal is possible in many ways, but the next step is of course a machine that turns a single tick and _advances_ from one regular signal to another. I had messed around with powered systems relying on hatch covers, but the double ramp glitch allows for much more reliable and compact hatch-switched counters. I'm sure there are other, much more elegant and probably less convoluted and spacious counting systems, but i guess i'm kind of stupid and can't think on the necessary abstract level to even understand. So i came up with my own counter. You see the first one i ever built to the left, and of course, it's an unholy mess. To make it hopefully somewhat understandable, let's look at the array that counts the fortnights and cycles once per season:
So, what do we see? A bunch of self-derailers, that's right, but here they only serve to introduce a delay to the actual counting mechanism: a simple double ramp which bounces a cart against a ramp on a wall, over a pressure plate to give a permanent signal. The ramp away from the pressure plate is covered by a hatch, and once the hatch opens, the cart barrels out the other end and makes a beeline for the next pressure plate. If i let it run just like that, it'd arrive long before the hundred ticks recover time of the original signal were up and the hatch at the new place closed. The cart would just zoom through it. But with the derailer, we can delay the cart's arrival - it's occupied long enough that it'll arrive only when the hatch cover is already closed and will be caught in the new 'holding cell' until the next input arrives and opens the hatch again.
A hatch cover could _also_ be used to block a cart's escape from a derailer - put it over the 'exit' ramp, and it will keep bouncing out on the middle tile without ever reaching derail speed. However, if you open the hatch, the cart takes significantly longer than one hundred turns (180 or so) to escape, by which time a single-tick signal would already have expired and the hatch would be closed again. I haven't tried yet what happens if you cover the 'back' ramp with a hatch.
So, by combining those two devices - 'latch'/holding cell and derailer/delayer - i got a device that, upon receiving a 'one-pulse' signal which times out after the customary one hundred ticks (like from a cart passing over a pressure plate on a long cycle) moves the cart from one location to the next and _only_ the next, reliably.
Of course, there are too many days (or pairs of days, what my oscillator counts) in a year to reasonably handle with a single counting loop of 336 or 168 counter arrays, but that's easily rectified. All that's needed is a circular counting array that has another plate which the cart only passes once per full counting cycle. The signal of that plate is then sent to another counting loop counting the next larger units (here of time). This also saves a lot of expense on hatch covers and mechanisms and time, because in this setup, the pressure plate giving a signal to the counting loop must be linked to _every_ hatch cover in the loop, taking two mechanisms and quite a bit of time for each job.
So, to count the pairs of days and put out a signal every fortnight, i built the seven-counter mess seen in the first picture. Fortnights are counted by the loop above and seasonal signals sent to what's seen on the right here:
On the left, there's a simple two-counter activated twice per full cycle of the oscillator, so i can count days. It has no outputs apart from the readout.
On the right, there's the season counter. The dark pressure plate is held down by the cart, which is currently in the pit. And this is plate number one, corresponding to spring (of the third year in this fort). The basic counter is probably easiest to explain here: on the top right, we have from left to right an EW up ramp against a wall, straight EW track with a pressure plate, a double-ramp pit (still plain EW track) with a hatch cover over the eastern ramp to keep the cart contained, yet another bit of flat track for when the cart is allowed out. It will then enter the self-derailer, spend ~100 ticks there and eventually escape to the east, along a short track leading south and turning back west, where it then emerges from the ramp and falls into another double-ramp pit. By the time it arrives, the hatch will be closed again and it will bounce against the wall and keep the pressure plate active.
All the pressure plates within the holding cells are completely unnecessary for the operation of the device, they only provide readable output if you don't want to look into the counting machine itself and check where the carts currently are. For the actual counter operation, you just need the one pressure plate which sends its signal to the next counting loop.
It's not as if the readable output i've devised were all that much to look at, mind:
From left to right: day, pair of days, fortnights, seasons. Counting from 'top' to 'bottom', the niches for the year counter are already mined. Each 'display' is just a hatch cover on top of an engraved floor which opens as long as the related pressure plate is held down.
Allowing no migrants past the hardcoded waves and without invaders, i started the first mining designations at the end of the first year, primed the day, double-day and fortnight counters in Obsidian of the second, kicked the cart into the oscillator on the first of granite of the third year and put the season counter online about two months later. The year counter should be build- and activatable without switching any part of the clock off. And counting years is not the limit, by stacking two five-counters and one four-counters on top of what you have, you can always multiply your counted units by a hundred; three such steps would give you a clock that would only switch back to start after a million years.
On a less momentous note, have a double-ramp based binary randomiser:
and without the hatches and pressure plates:
Takes any input, opening both hatches and ouputs one of two possible signals. Once input ceases and the hatches close again, the cart returns to the no-signal middle stretch, awaiting new input. If the input is random(ish), the output should be as well. An easy example would be the popular citizen-triggered pressure plate in front of the dining room.
And because i promised useless pictures of nothing but ramps, have a look at those ramps: