Thursday, April 6, 2017

The MeinEnigma Enigma Machine Kit - Hardware



In this blog post I'll talk about the hardware inside the MeinEnigma. As I was not the designer, I don't know all the design intent and history behind the unit, and may make some incorrect statements, so take everything here with a grain of salt. Some hardware changes are also possible after I write this (as a user of an early beta release of the kit). For reference, my PCB is marked 2016-08-13 Rev 0.9.

If you don't have the schematics for the unit in front of you (and you likely don't unless you purchased a kit), some of this may be harder to follow. I'll try to keep things at a reasonably high level.

While the hardware design of the MeinEnigma is not open, you do receive schematics as part of the documentation and the unit was designed using all Open Source tools, including the KiCad electronic design program and LibreOffice office suite, running on the Open Source Linux platform.

The Arduino controller uses Open Source software and the MeinEnigma's firmware is free software licensed under the GNU General Public License.

Introduction


The system is built on three double-sided printed circuit boards and can accommodate either through-hole or surface mount technology parts for most of the discrete components like resistors, capacitors, diodes, and LEDs. The boards are connected together via ribbon cables.

It is a modular design where the Lamp and Key board and Plugboard could be replaced by different modules in the future or to allow it to be used for a different application. The software also works if most of the hardware is not present. In fact, the software will run on a standalone Arduino board, and still function as an Enigma machine through the serial port.

I would say this is a conservative design, in the sense that it doesn't cut corners to reduce size, cost, or reliability. There is ample space on the PCB between components, the physical size being based on the original Enigma machine.

It has no less than three fuses, uses suppressor diodes, good power supply filtering, IC sockets, and a boost converter, all of which could have been omitted or replaced with cheaper parts to bring the cost down, but reduce the quality and/or reliability.

Let's look at each of the three printed circuit boards in detail.

Main Board


The main board is the most complex of the three PCBs. I'll break the description down into its functional blocks.

Power Supply

The unit can be powered in several ways. External power is connected using screw terminals, and a battery holder is provided that accepts two AA batteries. It will operate from any external voltage from 1.5 to 4.5 volts. On my unit I measured the typical current consumption as around 250 mA, which increased quite a bit when sounds were being played.


The Arduino and other digital circuitry requires a regulated 5 volts. This is provided by a boost converter which steps the external voltage up to a constant 5 volts. The boost converter is pre-assembled on a small circuit board. These little boost converters are impressive -- they are essentially a switching power supply in a tiny package and are quite low in cost. They are much more efficient than a traditional analog regulator chip, which means less drain on the batteries.


There is a large 4700 uF filter capacitor between VCC and ground, located near the sound board, which I suspect is the most electrically noisy and power hungry component.


The function switch connects the battery when in any of the positions other than the fully counterclockwise OFF position.


The unit can also be powered from the USB port on the Arduino. This can be connected to a computer or a USB power supply. In this arrangement the unit will still be powered on, even when the function switch is in the OFF position.

It is safe to power the unit simultaneously from USB and batteries (which will happen, for example, if you connect the Arduino to a PC to program it or use the serial interface). A Schottky diode makes sure that USB power does not flow back into the boost converter. In this case there will still be some current drain on the battery to power the boost converter, so you might want to remove the batteries if you plan to power it from USB for long periods of time.


The circuitry is protected from overloads by three fuses, one in the battery circuit, one at the output of the boost converter, and one on the Arduino. These are polyfuses, a relatively new type of device which will "blow" when there is a current overload, but will reset when the power is removed and allowed to cool down for a period of time. Keep this in mind if you short something and the unit stops working. It may appear dead, but come back to life again after a period of time.

Arduino


The design is based around the low-cost Arduino microcontroller, and uses a commercially available Arduino Nano (or equivalent clone). The controller is an ATmega328 AVR chip with 32KB of flash memory, 2K of SRAM, 1K of EEPROM and runs at 16 MHz. It has 8 analog I/O pins and 22 digital I/O pins. It also has an I2C interface which is used in the MeinEnigma. The USB port provides an FTDI USB to serial interface.

The Arduino is mounted on connectors so it can be removed. Note that there is a small reset switch on the board which is handy for restarting the system.

The MeinEnigma uses all of the Arduino's I/O pins, and makes heavy use of the I2C interface to control the keyboard, LEDs, and plugboard.

Function Switch


A 6-position rotary switch controls power and the MeinEnigma's operating mode. The original Enigma had a similar rotary switch for controlling power (on, off, battery, and external power).

The mode function uses a rather ingenious circuit that only requires the use of one of the Arduino's inputs. It connects an analog input to different positions in a resistor divider and determines the switch position based on the voltage measured.

In case the user wants to mount the switch in a case, a small PCB is provided. The switch could be mounted on this PCB, and then wired back to the main PCB where holes are provided for a 5 pin header.

Sound Module and Speaker



Sounds are provided using a DFPLayer Mini sound module which is controlled by a serial interface to the Arduino. It contains a MicroSD card with MP3 files on it. Serial commands from the Arduino instruct it to play sounds on the SD card. The unit directly drives a small speaker which is mounted on the PCB. Pads are provided on the board to connect an external speaker (or two) or amplifier as well as jumpers which can be cut to disable the on-board speaker. The data sheet I found listed a power output of 3 Watts which is quite respectable.

Buzzer


Morse code output is produced by a small piezoelectric buzzer. It is not possible to control the volume in software and I found it quite loud. A workaround is to cover the hole in the top with a piece of electrical tape.

Real-Time Clock



A DS3231 real-time clock module allows the MeinEnigma to implement the clock mode feature that displays the current time. The module is controlled by the Arduino using an I2C interface and maintains the time even when the unit is powered off using a CR2032 coin battery mounted on the module.

Rotors



Rotation of the four rotors is sensed using four rotary encoders which output quadrature pulses when turned. The levels are sensed by digital inputs on the Arduino. The Arduino can determine when and how far a rotor is turned, and the direction, but not the absolute position. It is also done using interrupts so the Arduino does not have to constantly poll the encoders. The encoders uses up eight of the Arduino's I/O pins. These encoders also have a pushbutton built in to the shaft but this feature is not used.

Display


The display uses 4 16-segment alphanumeric LEDs which can display letters and numbers as well as a decimal point. Some digital gates on the board (a 7402 and a 4002) are used to handle controlling the decimal point.

The displays and the four buttons next to them are controlled by the Lamp and Key board and will be described later.

Big Red Button



The big red switch is there for fun, and as described in my previous blog post, provides a kill switch function. An interesting feature is that it works even when the unit is powered off! Two of the switch contacts connect power when it is pressed, and the other pair drive one of the Arduino's input pins.

Lamp and Key Board



This PCB is physically the largest but does not have a lot of circuitry. It has the 26 keyboard keys and 26 LEDs. These are controlled by an HT16K33 chip which is a "RAM Mapping 16*8 LED Controller Driver with keyscan" intended for just this type of application. The chip is controlled by the Arduino over the I2C bus, allowing the keys and LEDs to be controlled by only two serial lines. The keyboard scan circuitry also requires some resistors and steering diodes.

The I2C bus signals pass through this board and go to the plugboard using a 4 conductor ribbon cable.

Plugboard



The plugboard detects the arrangement of up to 13 jumper wires connecting pairs of the 26 banana jacks. It uses two MCP23017 "16-Bit I/O Expander with Serial Interface" chips. These provide GPIO pins which can be controlled over I2>/sup>C.




Each jumper input has a transient voltage suppression (TVS) diode connected between and ground, to protect the MCP23017 ICs from any voltage transient or spikes, such as could be generated from static electricity when handling the cables. Below each banana plug is a dummy plug connected to ground which is there in case the user wants to use cables with two-pin jacks to more closely match the original Enigma machine.

Modifications and Future Plans

The unit has a few more features intended for future expansion or modification, described in the draft "Modder's Guide" which I had access to.

The main board has pads for an HT16K33 chip that can be used to control the buttons and display on the main board. Normally these are controlled using the chip on the Lamp / Key board, which requires the large ribbon cable to connect all of the relevant signals. With the HT16K33 on the main board, the interconnection between boards could be just a 4-wire cable for I2C and power and ground (and pins are provided for these connections).

The main board provides pins for three 4-pin connectors for I2C that could be used to expand the system to control more devices.

Pins for a small header are provided that, when shorted, will lock the machine so settings cannot be changed. This would allow you to add a locking switch in the case with a key so that, like the original Enigma, the settings could only be set by an officer with the key. The machine operator could then only set the rotors and encode/decode messages, but not be able to set or determine the machine settings.

There are additional mounting holes to accommodate a cover over the lamp board, for example to make a unit that more closely resemble the original Enigma.

There are also some jumpers provided to allow changing the I2C addresses so that the unit could support multiple Keyboard and Lamp boards or plugboards.

Summary



I hope this description of the hardware design was useful. In the next blog posting I'll talk more about the software running on the unit.

References

  1. MeinEnigma website: http://meinenigma.com
  2. Source code: https://github.com/lpaseen/meinEnigma

No comments: