This project was started as an idea to replace the innards of my ageing Uhlenbrock IntelliBox (early original version) as it stopped working properly a fair while ago, even though I've subsequently replaced it with a Roco Z21 unit. It was also an exercise for me in PCB design. Actually, it still is, as it's not really finished yet: having made some mistakes/omissions, revised versions have been created. But the basics can be seen below.
(double-click to enlarge)
The schematics (or diagram if you prefer) is made with Kicad, an Open Source and thus free PCB design suite. Sadly, it lacks the option of exporting the schematic as image, so I'd had to take a detour making one. This required transforming the original output several times, which caused the resulting image to be slightly blurred. To minimise the impact of that, I created a larger drawing, which may fill your screen completely if you click on the image above. Sorry!
Before embarking on a tour of the schematics, first a look at the circumference. You'll notice it has letters and digits on the edge. This creates a convenient grid to refer to if you're searching components. I'll use it too.
We'll start with the power supply, in the top-right corner (A-5/6). A barrel jack allows the use of a box-standard laptop power brick, 15-18V DC will do. Diode D1 (Schottky type for its low forward voltage loss) protect the circuit against wrong polarity. U2, a 5V voltage regulator, provides the circuit with a stable power source. Capacitor C2 covers any current peak requirements for the driver chip while capacitors C3 and C4 provide some suppression of unwanted AC signals on the power lines. To the left (A-4) is the actual driver chip, the LMD18200T. The small capacitors are required to drive the output MOSFETs properly, so shouldn't be omitted!
Below that is the keypad (B/C-4/5). This is a 6x5 matrix, containing 6 rows and 5 columns. Most keys are designated, but I'd forgotten a few. As the construction of the matrix isn't clear, I've redone it in a subsequent revision. (taking a sneak peak, the current matrix for the keys is a 5x8, that's 40 push buttons) In the matrix, each row has a push button to connect it to one of the columns. To prevent short circuits by simultaneous key-presses, between each row and the button there's a diode to prevent this. Difficult to spot and (partially) addressed in the current revision of the diagram. You'll notice the rows and columns have letter/digit combinations assigned to them. These are called labels, and the program knows that equally named labels are to be connected on the resulting PCB. As such, it's just a convenient method to de-clutter the schematics for human eyes.
Below the keypad is an LCD (C-5). It says 16x2 but it should have been a 16x4 display. Sadly, I haven't found a symbol for that in the Kicad libraries, so 16x2 will have to do Either side, an array of resistors and capacitors, each with labels for the keypad columns. (C-4/6). In grid B-3 a pair of rotary encoders with switch. The latter is actually a small push-button under the shaft of the encoder. These are used to control the speed and direction of a loco. Having 2 means you can control 2 loco's simultaneously. Pushing the button when the loco has any speed-step >0 will result in an emergency stop for that loco, if speed is zero, then the loco changes direction. Right on the edge, B-6, a row of led's with their resistors. You'll notice these too carry labels. That's because they are also in a matrix, but separate to the keys, hence the different names. The careful observer would notice 2 combinations are missing, these are on the opposite side of the diagram (B-1). We'll get to those a little later.
Now, the "main event", U1, the microcontroller. This is the Amtel ATmega2560 chip. I used it as replacement for the Arduino Mega2560 board I originally envisaged using. Again, Kicad doesn't have a symbol for it yet, so instead I used the chip itself and subsequently had to build up the required paraphernalia for it to work, being the 5V power supply and the clock- and reset circuitry. Both can be found in the top left corner (A-1). You'll also find the 'missing' leds there (one green, one red), as well as another pair of push buttons. These are the Stop and Go buttons, which disable/enable track power respectively. Using the chip directly meant also implementing the ICSP header. ICSP means "in circuit serial programming" and is an industry standard for (re-)programming microcontrollers w/o having to remove them from the circuit they're used in. The header is bottom-right to the chip. As said, all of that is provided by the Arduino Mega2560 board, so in practicality you'd only need the driver chip, keypad- and led-matrix.
I've selected the various in/output pins for the various functions they'd perform on availability on the aforementioned Arduino board headers. This means you can simply plug them in w/o having to worry the code needing altering if you change between the board and using the chip directly. The pin-count is as follows: 30 digital I/O pins (excluding the ICSP header) and 6 analog pins. Theoretically you can use the more powerful Arduino Due board as it's pin-compatible, but this requires a redesign of the led matrix (the Due ports cannot supply as much current as the ATmega family can) and a considerable change in the code, basically a re-write!
This concludes the hardware tour of the diagram. In the next post I'll describe how the matrices work.