
Information on ordering a commercial kit or assembled and tested unit of this circuit is available from the TracTronics Price List.
This is the third in our series of articles describing a set of electronic building blocks we have designed to control our model railroad layouts: Rich Weyand's N&W Pocahontas Division, Bill Pistello's Union Pacific, and the Reid brothers' Cumberland Valley System. In the first two articles we discussed SwitchWitch, a twin-coil switch machine drive circuit, and SwitchLock, a stall motor switch machine drive circuit. This time we will discuss SwitchMap, a diode matrix control circuit.
SwitchMap is fundamentally different than our other electronics modules in that it is not a circuit in itself. It is a circuit board that allows you to design your own circuit for your application. It enables you to build one or more diode matrix circuits which map push-buttons and other controls onto the devices to be controlled. We will discuss diode matrices, present the board layout, and explain how to design your own diode matrix for your application.
We are presenting these circuits both as circuit diagrams and as circuit layout patterns, allowing readers to breadboard or etch their own circuits. For those who do not wish to breadboard or etch these circuits, both kits and assembled & tested units are available from TracTronics, 1212 South Naper Boulevard, Suite 119, Naperville, IL 60540 (708-527-0000). As before, thanks to our friends Steve and Scott Ackerman of ACS in Sarasota, Florida (813-377-5775) for the excellent layout work on these circuit boards.
The theory and operation of diode matrices, also known as diode-switched matrices or diode-blocked matrices or diode-and arrays, have been documented several times in the hobby press, but for those who have not seen it before, we will discuss it here. This section can be rough going for those who are not into electronics, but you don't need to understand this section to use the diode matrix board. You can skip ahead and follow the instructions in the other sections.

There are many situations in which a controlled device, such as a switch machine, needs to be actuated by more than one control. For push-button control of the simple yard ladder of Figure 1, for example, the first switch needs to be set to the normal position when selecting any track other than the first one. We can say that the first switch needs to be set to normal when 2 is selected or track 3 is selected or track 4 is selected, etc. This is actually the logic function OR as well as the standard English use of 'or'.
In many model railroad controls, as well as in many prototype railroad controls and other types of controls, the control inputs are active when they are low, or held to ground, instead of being active when they are high, or at the supply voltage. When using control inputs which are active when low the sense of the logic changes, and is called negative logic. In our yard ladder example, we can say that the first switch should not be set to normal when track 2 is not selected, and track 3 is not selected, and track 4 is not selected, etc. This is actually the logic function AND as well as the standard English use of 'and'.
So what we really want is a way to build multiple-input AND and OR gates to control our yard ladders and implement other logic. Multiple-input AND and OR gates can be built with diodes, and in practice, both in integrated circuits and in discrete board level circuits, they often are. The equivalent circuits in Figure 2 actually implement the same logic functions; in fact, in logic diagrams, the diode circuits shown would be drawn as the AND or OR gate equivalents shown.

A diode matrix is a way to build several multiple-input AND or OR gates on the same board. The inputs to all the gates are laid across the board in one direction, and the outputs of all the gates are laid across the other side of the board at right angles, as the rows and columns of a matrix. A diode can be installed anywhere an input crosses an output. If the diodes are installed pointing from the outputs to the inputs, that is, so the current can flow from the output to the input, an AND gate is formed. If the diodes are installed pointing from the inputs to the outputs, an OR gate is formed. All of the diodes connected to any output form a logic AND or OR of the inputs they connect, and each output of the matrix is the output of one of these diode 'gates'.
The diode matrix for the ten-track simple yard ladder of Figure 1 is given in Figure 3. The 10 inputs, marked T1 through T10, connect to 10 selector push-buttons, one for each yard track. The other side of all ten push-buttons is connected to ground. The 18 outputs, marked N1 through N9 and R1 through R9, are the Normal and Reverse inputs for each of the switch machine control circuits. For twin-coil machines with SwitchWitch control circuits, the outputs N1 through N9 connect to the I1 inputs of 9 SwitchWitch circuits, and outputs R1 through R9 connect to the I2 inputs of these same 9 SwitchWitch circuits. Use the enhanced SwitchWitch circuit from the first article.

For stall motor switch machines with SwitchLock control circuits, the outputs N1 through N9 connect to the A inputs of 9 SwitchLock circuits, and outputs R1 through R9 connect to the B inputs of these same 9 SwitchLock circuits. Since there are four SwitchLock circuits per module, only three SwitchLock modules are required to drive the nine stall motor switch machines of the ten-track simple ladder, leaving three circuits to drive other switch machines.
Note that the matrix circuit can be read very easily. For push-button T7 depressed to select Track 7, for instance, outputs N1, N2, N3, N4, N5, N6, and R7 will be connected to ground, activating the drive circuits for switch machines 1, 2, 3, 4, 5, and 6 to their Normal positions and for switch machine 7 to its Reverse position, while the drive circuits for switch machines 8 and 9 are unchanged. A group of control push-buttons can be mapped to a set of switch machine driver circuits in an arbitrary way by this technique, by simply putting in a diode wherever a push-button is desired to activate that switch machine direction. Routes through yards, into engine terminal tracks, or to reset mainline switches for through trains can be programmed into a diode matrix in the same manner to simplify operator controls.
The SwitchMapTM circuit board etch pattern is given in Figure 4. We are not giving a schematic diagram for SwitchMap because the etch pattern is self-explanatory. The rows of the matrix are laid out horizontally across the back of the board and the columns of the matrix are laid out vertically down the front of the board to form the diode matrix. The matrix size on the board is 10 by 18, perfect for the ten-track yard ladder discussed above.

The diodes we use in the SwitchMap are 1N4000 series rectifier diodes (Radio Shack #276-1653 contains 25). Control of SwitchWitch and SwitchLock circuits does not require these 1 Amp diodes, but they are cheap and will take quite a bit of abuse. The diodes in the SwitchMap are to be mounted in a vertical position, rather than the more common horizontal position for electronic components. This is to allow the SwitchMap board to be kept very small; the board would have to be four times larger if the components were laid out horizontally. The diodes are to be mounted as shown in Figure 5. The component placement pattern is shown in Figure 6; the circle represents the body of the diode, as seen end-on, and the line represents the lead which bends over the top and down through the board. Figure 6 also shows the diode layout on the board to build the ten-track yard ladder matrix of Figure 3.

For the most common case of active-low logic and the inputs on the short side of the matrix, such as our ten-track yard ladder example, the banded end of the diodes should be down, as shown. The thing to remember is that the banded end of the diodes should be toward the ground in your circuit (in our example, toward the push-buttons), and the non-banded end should be toward the positive drive voltage in your circuit. If you are in doubt as to which way the diodes go, put just one diode in and try it. If you are wrong, nothing will short out or hurt anything, but the circuit will not be completed and nothing will work. Reverse the diode so the banded end is up and try again. Don't put them all in until you are sure you know the right way to orient them! Desoldering 50-plus diodes is not a lot of fun.
Note that this is a double-sided board, which makes alignment of the two sides important if you etch your own. Iron on one side and drill two of the holes at opposite ends of the board, then iron on the other side with the two hole pads lined up on the two holes. If etching your own boards, components mounted on the board need to be soldered on the side which connects to the horizontal or vertical trace which forms the matrix.
This module, like most of the rest of the modules in the series, includes connectors instead of soldering the lead wires directly to the board. As we explained last time, we put quite a bit of thought into what kind of connector we wanted, and settled on the Molex KK156 series. These connectors are durable, and will take quite a bit of abuse without bent pins and the like. We did not use screw terminals because we wanted to be able to remove and repair or modify units without having to disconnect and reconnect a dozen or more wires from the screw terminals. You will need a crimp tool for the KK156 connector pins; this tool is Digi-Key WM9903-ND. Dial 1-800-DIGIKEY.
The connectors for the SwitchMap circuit board are:
Header J1: 10-pin, Right Angle Header is Digi-Key WM4508.
Housing J1: 10-pin, Connector Housing is Digi-Key WM2108.
Headers J2 & J3: 9-pin, Right Angle Header is Digi-Key WM4507.
Housings J2 & J3: 9-pin, Connector Housing is Digi-Key WM2107.
28 Connector Pins: Connector Housing Pins is Digi-Key WM2300.
We put connector pads on all four sides of the SwitchMap board to allow more than one matrix to be constructed on one board. If you need multiple small matrices, say four 5 x 9 matrices, you can cut the traces on the board as shown in Figure 7, and then mount connectors on all four sides of the board. If you are building just one matrix on the board, you only need to put connectors on two adjacent sides.

If you need a larger matrix than 10 x 18, the mounting holes and connector pads have been laid out so that multiple boards can be bolted together to form bigger matrices. Cut short lengths of wire and solder them into the connector holes on the edge which will connect to the second board. Arrange the boards so these wires extend through the connector holes on the second board, line up the mounting holes, and bolt the boards together with #6-32 x 1/4" machine screws and #6-32 nuts. The mounting holes won't line up if one of the boards is turned around with respect to the other, so if they don't line up, rotate the second board 180 degrees. Finally, solder the wires onto the connector pads of the second board. 20 x 18, 10 x 36, 20 x 36 and larger matrices can be built in this way. Figure 8 shows a 20 x 36 matrix created from four boards; a small 0.3" x 0.3" triangle must be cut off the inside corner of each board so that they will overlap.

The SwitchMap circuit can operate both SwitchWitch circuits and SwitchLock circuits from the same diode matrix, so you need not have the switch machines controlled by one diode matrix be all twin-coil switch machines or all stall motor switch machines. You can mix and match them in one matrix.
There is another neat application for the SwitchMap board, used in combination with the SwitchLock modules from last time. In the ten-track yard ladder example, once you have selected a track by depressing the appropriate track selector push-button, the switch machine drive circuits, either SwitchWitch or SwitchLock, power all of the necessary switch machines to the proper alignment to align the proper track. But five minutes later, how do you know which track is currently aligned? You can just hit the appropriate selector push-button every time you want a track, of course, but it would be nicer to know which track is currently aligned with a glance at the panel. What we have in mind is a control panel something like that shown in Figure 9, where the lighted LED shows us that track 7 is aligned.

What we will do is use one SwitchLock circuit to control an indicator LED for each track; for our example we will need ten circuits -- two modules plus two of the leftover circuits from before if you used SwitchLock modules to drive stall motor switch machines, or three modules if you used SwitchWitch modules to drive twin-coil machines. We will connect one LED to the X output of each SwitchLock circuit as explained in the last article, and we will control the SwitchLock circuits with another SwitchMap board.

Figure 10 shows the diode layout on the SwitchMap board to control the SwitchLocks driving the LED indicators. The inputs marked T1 through T10 are connected to the selector push-buttons, as before. The outputs marked O1 through O10 will turn off the LEDs, and are connected to the B inputs of the SwitchLock circuits for each of the 10 LEDs. The A inputs of the SwitchLock circuits are connected directly to the 10 selector push-buttons, to turn on the LEDs when the appropriate push-button is depressed.
Note that each push-button will turn on one LED, the LED indicating the selected track, and will turn off nine LEDs, all LEDs except the one indicating the selected track. Each time a push-button is depressed, the connection from the push-button to the A input of one SwitchLock circuit will turn that LED on, the connection from the push-button through the SwitchMap board to the B inputs of nine other SwitchLock circuits will turn those nine LEDs off, and the connection through the other SwitchMap board to the SwitchWitches or SwitchLocks controlling the switch machines will align the desired route.
One problem with electronic controls on any layout is electrical noise. A model railroad typically has a great deal of electrical noise. Long wires on electronic control inputs act as antennas, picking up the electrical noise from motors and switch machines on the layout. The only noise-sensitive signals on the circuits presented thus far are the A and B inputs of the SwitchLock modules. When using SwitchLock modules, try to keep the length of the wires on these signals short, and do not route them in the same cable bundles with track power leads or switch motor leads. The best thing is to locate the SwitchLock and SwitchMap modules close to the control panels to which they are connected.
Proper grounding is also important. Connect all the grounds within each system first: all the switch machine grounds should be individually connected to one ground wire which connects to the switch machine power supply, all the track common rail leads should be individually connected to one ground wire which connects to the throttle grounds, and so on. Finally, all the power supply grounds for the various systems should be individually connected to one good master ground, like the ground on your water pipe.
If you take the above precautions, your electronics should be free from electrical noise effects. If you still have problems with noise on SwitchLock inputs falsely triggering your switches, you can do one more thing. Solder 0.1 uF ceramic disk capacitors from the A and B inputs to ground for each of the SwitchLock circuits which are falsely triggering. These should be soldered directly on the back of the SwitchLock circuit boards for the best results.
The SwitchWitch units are not noise-sensitive.
When the power is applied to a control panel which uses SwitchWitches to control twin-coil switch machines, the switches will remain in the positions they were in when power was shut off. When power is applied to a control panel which uses SwitchLocks to control stall motor switch machines, however, the flip-flops in the SwitchLocks can wake up in either position, and switch machines will change position to match. You can control the position which SwitchLock controlled switch machines assume on power-up.
Determine the routes you wish the switch machines to assume when power is turned on. In the ten-track yard ladder example, this will probably be the runner, or thoroughfare track. Solder a 0.1 uF ceramic disk capacitor across the push-button for each power-up route. This capacitor will slow the rise time of this control input when power is turned on, in effect pushing the button for you.
If you have already added 0.1 uF capacitors to some SwitchLock circuits to kill a persistent electrical noise problem, you may need to use a larger capacitor to enforce a power up route. Use a 1 uF tantalum capacitor across the push-buttons for the power-up routes. Make sure you have the polarity correct, with the marked positive lead of the capacitor on the side of the push-button which connects to the SwitchLock.
Also be aware that you should not shut off the power on your layout with rolling stock parked on switches controlled by SwitchLock modules. When the power comes on, and the SwitchLock modules wake up in either position, some rolling stock could be derailed.
Bill and Wayne Reid currently have two diode matrices on their Cumberland Valley System, one for each end of Shomo yard. One is a six push-button matrix controlling five twin-coil switch machines using SwitchWitches, and the second is a seven push-button matrix controlling six twin-coil switch machines using SwitchWitches. This application was shown in the first article.
Bill Pistello's Riverside Yard has a total of 21 switches controlled by 19 push-buttons, using 4 diode matrices. The matrices are contained on one SwitchMap board which has been divided into smaller pieces as described above. This application was shown in the second article.
Rich Weyand's Williamson Yard has a total of sixty switches controlled by seventy push-buttons, using 10 diode matrices. The matrices are contained on seven SwitchMap boards, two of which have been divided into smaller matrices as described above. Four yard ladders, both yard throats, yard leads, cabin tracks, engine pockets, and house tracks are all diode matrix routed from two control panels, which combined are only 6-1/2" deep by 32" long. A glance at the panels indicates all valid routes, and any alignment into or out of the yard takes no more than two push-buttons.
We designed the modules in this series with open-collector outputs and active-low inputs so we can more easily interface them to a computer or to command control later if we want to, although none of us currently has any plans to do so. For you computer hobbyists and command control guys out there who are now wondering if SwitchWitch and SwitchLock would make good driver circuits to interface your machine to the layout, these modules were actually designed with that in mind.
This article concludes the first section of the series, which describes what we did for switch machine control on our layouts. In this section, we have presented a control circuit for twin-coil switch machines, a control circuit for stall motor switch machines, and a diode matrix control circuit board for programming route selection. We've described how to use these circuits for controlling switch machines, programming route selection, and indicating aligned routes.
In the next article we will begin a new section of the series, train detection and CTC block signal control. This section will last for four articles, in which we will present a block signal control circuit, two different types of train detectors, and a high-current flasher circuit. As with the switch control circuits, these circuits have all been designed to work together to form a complete system, but they can also be used separately. Also as before, we will provide circuit patterns and schematic diagrams, and discuss how we have successfully used the circuits on our layouts.
If you have any questions about the switch control circuits, or worse, get stuck while trying to use them, write or call us at TracTronics and we'll help you out. Otherwise, we'll see you next time!