There are always multiple ways to skin any cat, even when limited to only 4000 series CMOS.
If you simplify this to it's essence, you want to latch a switch state. The all too popular flip flop comes to mind, but that only provides two output states. What you need is a parallel D type (data type) shift register or latch with 3 or more bits. The manual switch both sets up the new conditional data and clocks the new data into the latch or register.
Things to consider are set up time for the input data to be valid, typically with respect to a clock edge. The 40174 latches on the positive going clock edge. From looking at the data sheet clock timing diagrams, they reference everything to 50% of clock voltage, while the data input appears to be processed through a Schmidt trigger, i.e. valid low needs to be <30% and valid high needs to be >70%. This is useful for noise immunity but for this application looks like the clock would switch before the data is valid. The diode drop in series with the clock helps in the right direction but may not be enough?? Since the circuit as drawn is tested and works apparently, perhaps there is some switch bounce and later clock pulses actually latch in the data after it has time to set up.
From the data sheet it appears we could benefit from a slightly delayed clock. A small RC in series with the clock might add a little delay to insure the data has set up reliably before the clock pulse comes along to latch it. In general slow clock edges are problematic because noise can cause multiple clock hits, but in this case multiple clock hits will just latch the same data so will look stable at the output.
Using DPDT relays to provide some extra logic is clever, but limits the solution to only 3 states and is hard to expand to more inputs. In general for such things it's good advice to KISS (keep it simple).
I was a big fan of 4000 series logic a few decades ago, but these days I'd be inclined to use a micro... while something this simple is overkill for even the simplest micro.. Of course once you add a micro, you will find other things to do with it.
It's useful to understand latches and shift registers because they are often the glue used with micro's to interface with the outside world.
JR
If you simplify this to it's essence, you want to latch a switch state. The all too popular flip flop comes to mind, but that only provides two output states. What you need is a parallel D type (data type) shift register or latch with 3 or more bits. The manual switch both sets up the new conditional data and clocks the new data into the latch or register.
Things to consider are set up time for the input data to be valid, typically with respect to a clock edge. The 40174 latches on the positive going clock edge. From looking at the data sheet clock timing diagrams, they reference everything to 50% of clock voltage, while the data input appears to be processed through a Schmidt trigger, i.e. valid low needs to be <30% and valid high needs to be >70%. This is useful for noise immunity but for this application looks like the clock would switch before the data is valid. The diode drop in series with the clock helps in the right direction but may not be enough?? Since the circuit as drawn is tested and works apparently, perhaps there is some switch bounce and later clock pulses actually latch in the data after it has time to set up.
From the data sheet it appears we could benefit from a slightly delayed clock. A small RC in series with the clock might add a little delay to insure the data has set up reliably before the clock pulse comes along to latch it. In general slow clock edges are problematic because noise can cause multiple clock hits, but in this case multiple clock hits will just latch the same data so will look stable at the output.
Using DPDT relays to provide some extra logic is clever, but limits the solution to only 3 states and is hard to expand to more inputs. In general for such things it's good advice to KISS (keep it simple).
I was a big fan of 4000 series logic a few decades ago, but these days I'd be inclined to use a micro... while something this simple is overkill for even the simplest micro.. Of course once you add a micro, you will find other things to do with it.
It's useful to understand latches and shift registers because they are often the glue used with micro's to interface with the outside world.
JR