RetroBrew Computers Forum
Discussion forum for the RetroBrew Computers community.

Home » RBC Forums » General Discussion » WWII Enigma Machine (Not a computer, but really retro :-))
WWII Enigma Machine [message #10121] Tue, 30 August 2022 00:12 Go to next message
rhkoolstar is currently offline  rhkoolstar
Messages: 276
Registered: October 2015
Senior Member
Time for something different. An electronic implementation of the mechanical military Enigma machine. It includes version I, M3 army and M4 navy. It aims to be as close to the original design both in dimensions (although scaled down) as in 'logic', including quirks.
I'm not sure if this would be considered a computer. It is certainly a computer precursor and about as retro as you can get Smile
Not much computing power is required, so it is based on a ATMEGA328, Arduino (pro mini) style, augmented with two 8 bit shift registers. This concept makes it more approachable and easier to modify.
This design uses a modified version of arduino/libraries/Adafruit_GFX/glcdfont.c. This file is included. T and Z characters are cleaned up and
b and c are changed into beta and gamma.

I mainly used surface mount parts because they are cheaper, but also because this makes the board a lot cleaner and easier to route.
All of the existing designs I found use 16 segment LED displays (one uses nixie tubes). These are too big and too expensive. 5x7 dot arrays suffer from the same disadvantage. I settled on a .91 inch SSD1306 128x32 OLED display which is much cheaper and closer to scale size.
All of this fits easily on a 100x100 mm PCB using dimensions scaled down from the original (mostly).

Enclosed are schematics, KiCad files gerbers, Arduino sketch and a terse manual.
A note on the PCB layout. I wired the internal switch wires on an internal PCB layer, to facilitate routing. This layer should not be included in the ZIP file for manufacturing.
I do have a few extra PCBs, but I'm not shipping outside of the European Union as shipping is cost prohibitive. If you want to build this you are better off ordering the boards yourself.

/forum/index.php?t=getfile&id=2799&private=0
/forum/index.php?t=getfile&id=2800&private=0
Re: WWII Enigma Machine [message #10123 is a reply to message #10121] Tue, 30 August 2022 22:20 Go to previous messageGo to next message
cheshirenoir is currently offline  cheshirenoir
Messages: 14
Registered: June 2022
Junior Member
Nice work there.

I love seeing projects like this.

Chesh
WWII Enigma Machine... and Morse Coder firmware for prototype testing [message #10124 is a reply to message #10123] Fri, 02 September 2022 11:14 Go to previous messageGo to next message
jayindallas is currently offline  jayindallas
Messages: 110
Registered: June 2021
Senior Member
Nice creation!

I like that the pcbs are black, as it maintains the look of the original enigma machines.

The idea of using an 1900s communications system and making a retro-fusion version with Today's technology was cool.

It reminded me of something I used to do in my assembly language back int the early '80s. When writing firmware for my designs... I would add a Morse code routine, as a useful tool to test out prototype boards. By sending Morse code through a LED, buzzer, or even a relay contact, you could quickly discover how far your code ran on a untested prototype, before failing due to {firmware,prototype pcb,soldering,assembly,design} problems.

It was a lot quicker than using a logic analyzer with all the necessary physical hook-ups. You could quickly skip pass what was working and discover what was not working. In debugging the latter, you could either add more debug Morse code messages to bound the failure or grab the logic analyzer, whichever was more likely to be the minimum activity required to resolve the problem.

The Morse code messages were *JUST A BRIDGE* until the system was capable of sending text messages to a terminal, display or printer.

What I'd do is insert a couple lines of ASM code to print a debug message if the runtime got that far. Once a progress-point message was successful, I'd just comment it out and move on.

Morse code was better than just blinking 5 times or 2 times as you could send informative messages. And once you had a serial link to a printer or terminal or other display resource, you just commented out the the Morse code CALL in PRTIMM and use the other message display resource.

EXAMPLE of "Print_Immediate" and a Morse_coder routine for Z80:
...	(prior code here)
	;-------------------------------;
	call	Print_Immediate		; call print immediate string to current selected output 
	ds	"Sram OK"		; the return address actually points to the string, not code
	db	0			; string termination sentinel
	;-------------------------------;
...	(next code here)		; this the the next code instruction and PRTIMM pushes this address 
					; onto the stack and returns
...
;-----------------------;---------------; 
			; print the string at the return address to the selected portal.
Print_Immediate:	; then restore the return address or program counter (PC) to the next instruction below the CALL.
			; this code located with jump relative internal accessible range.
			;---------------; 
	pop	hl			; popped return address is actually the address of the immediate string
	jr	GetChr			; jump into loop to process next character from string
	;-------------------------------;
SndChr:	push	hl			; save the message character pointer on the stack while sending chr to portal
;;;	call	Serial			; uncomment if sending character to terminal, display or printer
	call	Morse			; uncomment if sending character to Morse coder
	pop	hl			; restore the message character pointer
				;-------;
GetChr:	ld	a,(hl)			; get next string character
	inc	hl			; bump pointer to next address
	cp	0			; test for null termination
	jr	nz,SndChr		; jump if another character to send it to portal
				;-------;
	jp	(hl)			; else short-return, hl->pc
;-----------------------;---------------; 
			; Next block is a Table of 36 acceptible ascii characters that can be sent via Morse code. 
Tmorse:			; Lowercase letters will be converted into upper case letters before using this table.
			; The letters are ordered by English frequency-of-use to speed up searches.
			; The 10 numbers are simply appended last. Separating the numbers and punctuations not worthwhile here.
			; If the character is not found within the following string, control will return to Print_Immediate
			; The English Letter Order is from:
			;	"CRYPTANALYSIS, a study of ciphers and their solution"
			;	by Helen Fouche Gaines
			; Most books on cryptanalysis have a table like this.
			; Numbers are mostly constidered random, except ZERO, which appears often like "$1.00"
	;---------------;---------------; 
	ds	"ETAONISRHLDCUPFMWYBGVKQXJZ0123456789"
	;---------------;---------------; 
			; Table of 36 encoded Morse code characters in the same order of the ascii search.
			; When a acceptible character is found in Tmorse, its encoded Morse code character
			; is simple found by adding another 36 to the HL pointer.
			; The Morse code character encoding supports up to 5 Morse keystroke (per character).
			; It does not support any punctuation, not worthwhile here.
			;               _______________________________________
			; ENCODING:    | 0="."  1="-"  0=unused | Keycount 1:5 |
			;              | b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
			; "C" = _._. = |__1_|__0_|__1_|__0_|__0_|__1_|__0_|__0_| = A4h = dash dot dash dot (b3 is unused)
	;---------------;---------------;                   "C"
	db	01h,81h,42h,E3h,82h,02h,03h,43h,04h,44h,83h,A4h,23h,64h,24h,C2h,63h,B4h
	db	84h,C3h,14h,A3h,D4h,94h,74h,C4h,FDh,7Dh,3Dh,1Dh,0Dh,05h,85h,C5h,E5h,F5h
;-------;---------------;---------------; 
			; Register A holds the ascii character from the print_immediate string
Morse:			; If the character is not found within the Tascii block, the program will quickly return
			;---------------;
	cp	20h			; if a space is found, add a Tgap3 delay between words
	jp	z,InsertGap3		; spaces insert a delay between Morse words then return to Print_Immediate
					; search character is in register a. make lowercase letters uppercase.
	cp	5Fh			; if greater than 5Fh convert to uppercase. non-letters are rejected within 7Fh:40h
	jr	m,ScanChrs		; skif not lowercase range, skips mask if uppercase or numbers
	and	11011111b		; lowercaser letters become uppercase letters, b7 ascii should always be a 0
ScanChrs:	;-----------------------; scan the Tascii string for letters and numbers that Morse will send
	ld	hl,Tascii		; prepare search: hl points to ascii tables of Morse code characters acceptible
	ld	bc,36			; prepare search: bc is the size of ascii table search
	cpir				; z flag if found, else bc=0 if not found
	ret	nz			; return on nz, character not found in allowable Morse set. return ignores the character.
				;-------;
	ld	bc,36			; value to bump pointer from character to its Morse encoded byte
	add	hl,bc			; hl now points to Morse encoded pattern/count data byte
	ld	a,00000111b		; mask for get the Morse count field only
	and	a,(hl)			; register a now holds only the Morse count byte
	ld	b,a			; move the Morse count to b (counter for djnz loop)
	ld	a,(hl)			; read again for the dot/dash pattern + unused 0s + Morse counter
KeyTheChr:	;-----------------------; Key the Morse code pattern of dots and dashes for the accepted ascii character
	rlca				; shift next dot/dash into carry flag
	ld	d,TDot			; set delay time for dots by default
	jr	nc,KeyingNow		; skif not carry because T_Dot is loaded
	ld	d,TDash			; else set delay time for dashes (3 times a dot duration)
KeyingNow:	;-----------------------;
	[INSERT: Morse signal ON]	; start the Morse key (a dot or a dash)
	call	Delay			; delay time based on register D
	[INSERT: Morse signal OFF]	; end the current Morse key
	ld	d,TGap1			; set delay time between dots and dashes
	call	Delay			; delay time based on register D
	djnz	KeyTheChr		; send next Morse keystroke until b=0
				;-------; the character has been sent
	ld	d,TGap2			; load gap between characters
	call	Delay			; delay time based on register D
	ret				; exit Morse, character sent, return to Print_Immediate for next character
	;-------------------------------;
InsertGap3:				;
	ld	d,TGap3			; load gap between words (when a space is detected)
	call	Delay			; delay time based on register D
	ret				; exit Morse, delay between words done, return to Print_Immediate for next character
;---------------------------------------;
With this subroutine/function I could just write prototype test routines and put in the runtime status message inline. It was a lot easier/faster than maintaining a block of string messages, giving each a unique label and adding the labels or parameter for every call to Print_Immediate.

[Updated on: Mon, 05 September 2022 09:39]

Report message to a moderator

Re: WWII Enigma Machine... and Morse Coder firmware for prototype testing [message #10128 is a reply to message #10124] Thu, 08 September 2022 09:16 Go to previous messageGo to next message
rhkoolstar is currently offline  rhkoolstar
Messages: 276
Registered: October 2015
Senior Member
I could not leave well enough alone, so I designed a case for it in openScad (file below). there are 7 separate parts to print. By commenting out the relevant parts, the separate items can be exported. The key stems are lengths of 3mm polystyrene rod (ebay). Letter mask is a printed sheet of paper to be fitted between the lamp mask and the lamp case (PDF below). The lamp case should be printed upside-down, because the top layer is very thin. the purpose of the key braces is to keep the key stems upright and prevent rotating the keys. the key stems should press-fit into the braces and the key caps. The holes are 6-sided to facilitate this.

I currently have all the parts 3d printed and am busy sanding and painting.

More later.....

/forum/index.php?t=getfile&id=2807&private=0
  • Attachment: enigma.png
    (Size: 42.33KB, Downloaded 341 times)
  • Attachment: enigma.scad
    (Size: 6.56KB, Downloaded 142 times)
  • Attachment: LAMPBOARD1.pdf
    (Size: 13.68KB, Downloaded 150 times)
Re: WWII Enigma Machine... and Morse Coder firmware for prototype testing [message #10133 is a reply to message #10128] Wed, 14 September 2022 08:09 Go to previous message
rhkoolstar is currently offline  rhkoolstar
Messages: 276
Registered: October 2015
Senior Member
... and this is what it looks like now

Now all it needs is a wooden box Smile
/forum/index.php?t=getfile&id=2810&private=0

[Updated on: Wed, 14 September 2022 09:44]

Report message to a moderator

Previous Topic: CFFA1 (for Apple I owners)
Next Topic: Nortel Call Processor NT9D19AB (68040)


Current Time: Wed Mar 19 01:46:47 PDT 2025

Total time taken to generate the page: 0.00625 seconds