Searchlight panel is a custom turnout control panel for a friend's layout.
Building a control panel for a large layout requires a lot of wiring. Each remotely controlled turnout requires at least 2 or 3 wires, plus wiring for the LED indicators. This rapidly multiplies into a "rats nest" for even moderately large layouts. My friend's layout has 27 individual turnouts and 4 crossovers, totalling 31 control points. Handling all 31 control points with a single CDU and a set of SPDT switches (using a common return bus wire) will require some 62 wires be run from the panel to the layout.
As an additional feature, my friend wants a wall-mounted LED track schematic display. This will require an additional 62 wires (or more) be run from the control panel to the display panel, if all is done the "simple" way.
There are probably more efficient ways of handling this, in terms of the wiring.
My solution is to introduce a microcontroller into the mix. The micro will use an addressing scheme and a time-multiplexed signal bus (or a set of them, really) to cut down the wiring being passed around. A second simple microcontroller in the display panel will manage the LED display.
The turnouts will be directly driven by small driver cards that handle eight turnouts each. Each card will have an assigned address, and will share an 8-bit control bus back to the micro. The driver cards could each contain their own local CDU (and I may design the board that way), but there will also be provision for a single master CDU for all the turnouts.
The control panel switches will be wired via a bus as inputs to the micro in groups of 8. The micro will poll each group of 8 switches in round-robin fashion to check the position of each switch. When a change in switch position is detected, the micro will address the correct driver card and turnout. This will trigger a FET switch that will direct the CDU output to the correct turnout. At the same time, the micro will send a message to the LED display controller to update the display.
At boot time, it is possible that someone may have manually changed a turnout position. To account for this, the display controller will keep track of which turnouts have been moved since the last time it was powered on. At boot time, for each turnout, it will either light both LEDs or neither, to indicate that the turnout position is unknown. Each time it receives a "turnout change message", it will update its status and light the correct LED for the turnout position. In this fashion the user will be warned of the unknown state at boot, and this will be automatically updated as operations progress.
Note that this is not foolproof. The system still cannot detect if someone manually changes a turnout while the system is active. This issue will have to be addressed in the operating rules for the layout, as without some form of feedback from the turnouts (which is not available at this time), run-time manual turnout moves cannot be detected.
Here are proposed definitions for the various buses in the system
All defined bus cables are multi-wire flat ribbon cable with IDC headers. Standard spec is 24ga. but larger wire is allowable. Cable connectors are 0.10" dual row IDC female, mating to matching pin-headers on the boards.
The switch input bus is a 16-pin ribbon cable that connects all of the switch input boards in parallel to the microcontroller. Each switch input board provides 8 inputs, and has a unique bus address (set by DIP switches on the board). The bus is an 8-bit data, 4-bit address bus allowing up to 16 boards, or 128 switches.
The bus is clocked, and operates in a simple master-slave relationship. The processor (master) sets the address and R/W bits, and pulses the CLK. At the CLK high, the input board either latches the value on the DATA lines (R/W == W) or drives the value of its input pins onto the DATA lines (R/W == R). When CLK falls, the input board reverts the DATA lines to a tri-state condition.
Pin Description
1
+5V
2
DATA_0
3
DATA_1
4
DATA_2
5
DATA_3
6
DATA_4
7
DATA_5
8
DATA_6
9
DATA_7
10
Addr 0
11
Addr 1
12
Addr 2
13
Addr 3
14
CLK
15
R/W
16
GND
Logic HIGH indicates diverging route (switch is thrown), LOW indicates main line route (switch is closed).
This bus runs from the microcontroller to the output modules. Each output module has an assigned address, and responds only if the address lines match its address. This bus is clocked. Changes are only made on the rising edge of the CLK line (which is really a latch enable). Note that the lower 3 address lines indicate which individual output is to be modified, while the upper 5 address lines indicate which board is being addressed. This ensures that the full CDU output is routed to only one output at a time.
Pin Description
1
+5V
2
CDU_POS
3
CDU_GND
4
OP_ADDR 0
5
OP_ADDR 1
6
OP_ADDR 2
7
BD_ADDR 0
8
BD_ADDR 1
9
BD_ADDR 2
10
Reserved
11
Reserved
12
TO_POS
13
CLK
14
GND
15
GND
16
GND
BD_ADDR selects an output module from among all the modules on the bus. OP_ADDR selects one of the 8 outputs on the selected module. TO_POS contains the new turnout position for that specific output. CLK triggers the output change event, and CDU_POS/CDU_GND carries the CDU pulse. There is no memory on the output module.
The remote LED display board contains its own small microcontroller. This allows us to use a simple serial interface between the boards. Because of the possibly long cable routing, RS-232 +/-12V signaling will be used. We will evaluate whether a different, simpler interface could be used, since it is desirable to provide a LocoNet interface, and multiple UART microcontrollers are hard to find these days. Other options are SPI, I2C or CAN bus, or a simple clocked serial interface.
Pin Description
1
+5V
2
MC_TxD
3
MC_RxD
4
GND
MC_TxD and MC_RxD are defined from the perspective of the primary microcontroller. That is, the LED controller transmits on RxD and receives on TxD. This convention is indicated by the "MC_" prefix. +5V is supplied by the primary controller, and is optional. The LED controller need not use it.