Sunday, December 1, 2019

Friday, October 25, 2019

Get your head out of the Cloud(s) and design complex shapes PCB using Free and Open Source Tools

This post will show how to use the CAD program Sketchup to design an arbitrarily complex PCB shape that will be post processed with Inkscape so that Fritzing will accept it as a board outline and produce Gerber files that can be sent to a PCB Fab for production.

The 2019 Saintcon Cybersecurity Conference Badge is an Enigma Machine.


https://www.saintcon.org/2019/content/list/?type=presentations

The badges can be interconnected and form a circle in the shape of an Enigma Machine Rotor Wheel when 26 of them are put together.


We are currently designing a new Universal Enigma Machine Simulator.

https://hackaday.io/project/165559-at-mega-enigma-a-2560-pro-mini-enigma-simulator

Let's design a new PCB shape for this project. Fritzing accepts specially designed SVG files as PCB outlines. We need a way to design the SVG files first.

Sketchup is a 2-D and 3-D capable CAD program that's easy to use and can produce dimensionally accurate designs ready for laser cutting or 3D printing.

Sketchup has recently stopped updating the downloadable version and gone to the cloud. The free cloud version does not support exporting to SVG or downloading from the Extensions Warehouse.

Been using Sketchup to design enclosures for a while


Once an enclosure is designed and the finger joints drawn, the faces are selected, exported to SVG and placed in a Ponoko template for laser cutting in 3mm Birch Plywood.

https://www.ponoko.com/design-your-own/products/laser-cut-enclosure-for-arduino-enigma-simulator-with-engraved-enigma-logo--12132


Recently I have started using Sketchup to design objects for 3D printing as well.
https://www.thingiverse.com/arduinoenigma/designs


The goal is to make a new PCB Shape for this. The dimensions of the rectangle are 139mm by 171mm.


This post expands upon a previous one showing how to do a custom shape using Inkscape and Fritzing. First, Inkscape is used to generate an SVG file with three layers (board, silkscreen, silkscreen0). Fritzing will use this SVG file as the PCB outline.

https://hackaday.io/project/91895-sinclair-scientific-calculator-emulator/log/144392-how-to-design-a-custom-pcb-shape-for-fritzing-no-more-sharp-corners

Let's get started...

1:

Use the circle tool to draw a 26 segment circle. Press C, type a number, then type S26 to select 26 segments and finally draw the circle. The semicircular shape is drawn by first drawing a circle and then attaching two circle segments to the sides. The portions of the circle that are not needed are erased and we are left with a wavy contour.


 2:

The same technique is used to draw a 26 side circle, the width of the segment is set to 140mm by measuring it with the tape tool and then 140 is typed to resize the measurement to the desired value. The height of the PCB shape is set to 171mm. Then the width of the top of the shape is measured and the wavy shape in step 1 is resized by using the tape tool and copied and pasted to this file.

The bottom of the shape is flat but it can be made into a semi-circle by selecting the circle and specifying that it will have 96 segments instead of 26.


3:

Here is the final shape. The width at the bottom is 140 mm and the height of the rectangle is 171mm.


4:

Using an export plugin, the shape is saved as an SVG file.


5:

Open Inkscape and load the SVG file generated in the step before.


6:

Go to File-> Document Properties and click on Resize Page to Drawing or Selection. This step can be omitted.


7:

Using the Fill and Stroke tool, color the inside of the PCB. Any color is fine. Select something easy on the eyes. The PCB is rotated as well. (Rotating the PCB is also optional, it can be done at the end in Fritizng). Add three layers, name them "board", "silkscreen" and "silkscreen0". These names are for display only, the file will need to be edited to locate the XML "id" property and set it to match the display names.

 8:

Fritzing does not use the XML label property. It needs the ID property set. For that we need to edit the XML that makes the SVG file and change the layer ID properties.

Go to Edit->XML Editor, or press CTRL+SHIFT+X

Look for a line that says  inkscape:label="board", click on it.

Click on the "id" attribute on the right, click below the 'Set' button and type "board" without quotation marks and then click on the "Set" button.


9:

Repeat for "silkscreen" and "silkscreen0" The layer attributes should now be as shown below.


10:

Open Fritzing, Click on the PCB tab, click on the default PCB and on the Inspector window, click the "load image file" button.


11:

Navigate to where you saved the Inkscape SVG file and select it.


12:

A warning dialog will be shown, click OK and the PCB should be displayed. If it is sideways, click on "rotation" on the Inspector window and set it to -90


13:

An existing design is copied from another file into this. Notice that the shape of the PCB is accurately dimensioned.


14:

Rearrange any parts, save the file and export for production, select "Extended Gerber..."


15:

I prefer the look of tented vias, covering with soldermask the plated holes that connect traces in different layers.

This article shows the difference between tented and exposed vias.

https://hackaday.io/project/91895-sinclair-scientific-calculator-emulator/log/123664-12252017-finished-routing-the-board-and-submited-for-production

The steps:

-Save Work
-File->Export->For Production->Extended Gerber, create "tented" folder
-Routing->Select All Vias
-Press Delete key
-Export Gerbers to no-vias folder
-File->Revert

-Copy maskTop and maskBottom, silkTop and silkBottom files from no-vias to tented folder



16:

The mask and silkscreen files from the no-vias folder are copied to the vias-folder. This will ensure that the vias are covered with soldermask and if text is drawn above them, the silkscreen will show.


17:

The Gerber files are put together in one ZIP file and uploaded to OSHPark.com

And it is a fail. Instead of a purple board, we get a white one. The contour is open. Time to find where.


18:

Finish the import process at OSHPark, save the defective board and click on the board image, look for discontinuities in the outline. Here we have found one.


19:

Go to Sketchup and add lines in the problem area, delete any doubled up lines and repeat from step 4. This step might be difficult. Sketchup may decide that the contour is no longer closed even though it appears so. Keep adding lines and deleting doubled up lines until the contour closes again.

When repeating the setup process in Inkscape, this time the shape was not rotated and the document was not resized (steps 5-6). Instead the PCB was rotated -90 degrees in Fritzing.


20:

Repeat the Gerber export process and inport to OSHPark.

Success. It took a couple of tries, but finally we are rewarded with a purple board.

 

Finish the import process and then click on the board, make sure things look ok.




Here is an example of a 3D printed design being turned into a PCB. We will start with this 2-D Kokopelli figure and follow all the steps in this write-up.


And we get rewarded with a white board, another failure. Click on the board image and look for discontinuities in the outline.


The discontinuity was found in the lower arm elbow.


Going back to Sketchup, a circle with more segments was added to the lower elbow and the import steps repeated. This time we get rewarded with a properly rendered board.

This board will not manufacture 100% as drawn given the limitations of the routing bit used to cut the outline of the board. Sharp inner corners like the one where the lower arm touches the body and the flute will have a rounded edge.


Future work:


Monday, October 21, 2019

UKWD added to Mega Enigma, an Universal Enigma Machine Simulator

This simulator already had 5 UKWD rewirable reflectors, 4 were available to be used with the M3 machine, the other with the KD. The D reflector wiring can be changed in the field. The 5 reflectors included are examples of known wirings used at some point in time.A mechanism was needed to change the actual wiring of the reflector in this simulator.

Adding an item now to the menu system is easier than developing it from scratch. It is just a matter of inserting an item in the existing menu system. The UKWD sub menu has two special features, it is skipped if the currently selected machine did not have a D reflector, and the user cannot leave that menu until the pairs specified are correct.

The UKWD pairs can be displayed in two notations, Bletchley Park (BP)  and the German notation used in the official key sheets (UD). Complicating things is the fact that both notations run in different directions and that a different pair of letters are missing from each, B-O from BP notation and J-Y from UD notation.

The simulator uses BP notation internally to calculate the path through the rotors, but it gives the option to show the UKWD pairs in both UD and BP notations. This led to the following gems:

const __FlashStringHelper *BPTOUD = F("A-ZXWVUTSRQPON-MLKIHGFEDCB");

const __FlashStringHelper *UDTOBP = F("AZYXWVUTS-RQPNMLKJIHGFED-C");

The first string comes straight from the Crypto Museum pages.


Starting with the black letters in the outside (BP notation), it records the blue letters on the inside (UD notation).

The second string was pre-computed for this project instead of dynamically generating it for each search. Starting with the blue letters in the inside, it records the black letters on the outside.

Precomputing the UDTOBP string makes translating different pair of wires with the same initial letter (C-W and C-T) as easy as doing three table lookups. Notice that C-W(BP) bridges contacts 2-22 and C-T(UD) bridges 24-7. They are completely different wires, they are grouped by the initial letter for convenience only.

Some work remains to be done to check the validity of the reflector pairs and to allow editing the pairs in UD mode.

Read more about the Umkehrwalze D (UKW-D) here:
https://www.cryptomuseum.com/crypto/enigma/ukwd/index.htm

Delve into the code to make this work here:
of particular interest are:
 EnigmaGUI.ino: case 2 in doMenu()
 Enigma.ino: translateBPtoUD() function
https://gitlab.com/arduinoenigma/megaenigma/tree/master

This project's Hackaday.IO page:
https://hackaday.io/project/165559-at-mega-enigma-a-2560-pro-mini-enigma-simulator

Daniel Palloks Universal Enigma:
The authors are very grateful for this simulator, as it provided the rotor strings and it is used extensively to check the accuracy of Mega Enigma results.
http://people.physik.hu-berlin.de/~palloks/js/enigma/enigma-u_v25_en.html

Thursday, October 17, 2019

Monday, September 30, 2019

The Mega Enigma, an Universal Enigma Machine Simulator is feature complete

The menu system has been completed.

All of the enigma settings (machine type, rotor types, ring settings, wheel settings) can now be changed. The plugs, being physical, are not settable via the menu.

A lampfield / keyboard self test feature has been added.

The lampfield brightness can now be changed.

When the settings are changed, they are saved to EEPROM

Pressing the menu button for a few seconds zeroises the machine by returning it to a default configuration and saves that to EEPROM, deleting the previously configured machine. Might write a separate byte to EEPROM to indicate that a memory wipe is in progress in case it is interrupted. Upon boot, the machine will check this memory location and if set, resume wiping EEPROM.

The new cases have arrived, they need assembly.

Demo Video coming soon...

https://www.instagram.com/arduinoenigma/

https://www.instagram.com/explore/tags/megaenigma/

https://gitlab.com/arduinoenigma/megaenigma/tree/master


Saturday, September 21, 2019

Universal Enigma Engine for the Arduino Mega Enigma is working

The Arduino Universal Enigma Engine now handles settable reflectors on 4 wheel machines like the Enigma D, Swiss K, Rocket (R), Tirpitz (T), A-865, G-111, G-260 and G-312. The only features left are the UKW D and the programmable stepping rotors.

Here is a table with the characteristics of each machine.


Here is an older video showing how double stepping on lever machines and gear stepping works. At the time, geared machines did not encode correctly, now they do.


More posts on instagram:
https://www.instagram.com/explore/tags/megaenigma/

Source Code:
https://gitlab.com/arduinoenigma/megaenigma/tree/master


Saturday, September 14, 2019

Mega Enigma Progress: M4 Works

The four rotor M4 Enigma Machine is working 100%. Now lets get the other 20 machines working.

An interesting thing about this simulator is that it is continuously calculating the path through the rotors for the current key pressed.

The hardware allows for multiple key presses and the software is written to use this functionality. For example, if the key A is pressed, the rotors are advanced when they stop, the result of encrypting that letter is shown. If another key is pressed, the rotors stay put and the result of encrypting that letter is also simultaneously shown on the plugboard.

As in the real machine, the keys must be kept pressed until the rotors stop spinning to illuminate the lampfield. Releasing the key immediately turns off the lampfield. Brief key presses advance the rotors, but do not illuminate the encrypted result.

Another thing that is possible is changing the rotors while a key is pressed. The lampfield is updated to show the new encrypted result for the same key with the current rotor position.

If two keys are pressed and the rotors are changed, the two lamps in the lampfield are updated.

A feature that is still not implemented is turning off the lampfield if a key and its encrypted key are both pressed. Let's say that C is pressed and it encrypts to F, if the F key is also pressed without releasing C, both the C and F lampfield lights should turn off since the Enigma Machine circuitry connects the lamps to the rotor maze through the normally closed contact in the key, pressing that key opens that contact.

The plugboard is also continuously scanned, inserting (or removing) a plug while a key is pressed will update the lampfield if that plug is part of the encryption path.

These features make this simulator one of the most electrically accurate out there.

A bonus feature is that the Mega2560 Pro Mini  at the heart of this project uses the same ATMEGA16U2 as the Arduino UNO for USB connectivity. If you happen to have an External Lamp Field for your original Touchscreen Arduino Enigma, it will work with the Mega Enigma as well.




View this post on Instagram

A post shared by Arduino Enigma (@arduinoenigma) on

Source code:
https://gitlab.com/arduinoenigma/megaenigma

View more pictures on Instagram:
https://www.instagram.com/explore/tags/megaenigma/



Sunday, July 28, 2019

Programmable Seven Segment LED Tester is complete

The conclusion to https://arduinoenigma.blogspot.com/2019/06/a-seven-segment-led-tester.html

Here is the finished Seven Segment Tester. All of the available Arduino Nano pins, except for analog input pins A6,A7 and Serial Port pins D0 and D1 are connected. This leaves us with 18 pins to bring to the 3M Zero Insertion Force (ZIF) socket. Any display up to 9 pin DIP can be tested.

Here are some pictures of the device testing a 16 segment display, a 7 segment display and a 3 digit 7 segment display. The common cathode and common anode versions are programmed as test patterns.

Once the Arduino is programmed, the device can work standalone using a 9v battery.














The base is a reused enigme simulator box lid. 


The OSHPark render of the bottom of the board.


A render of the top of the board. 


The boards as they came from Oshpark.com



Here is a video of the test patterns for a 16-segment LED display and a three-digit seven-segment display.


This design may also be used to test IC, it can supply power and ground to the device under test, put values on some pins and verify that the output from the chip is correct.

Saturday, June 1, 2019

A Seven Segment LED tester

The seven segment displays required for previous projects had, on rare occasions, defective segments. In order to test them all, some contraptions were devised.

Here is a calculator without the displays soldered. Testing the display involved inserting the display in the PCB and running a special program that cycles through all the digits.



This is another rig to test a single seven segment display for the Art Installation Project. This one simply illuminates all the digits simultaneously. The Arduino UNO is simply providing 5V and all the digits are hardwired with jumper wires.



Faced with the prospect of testing the 16 segment displays for the Mega Enigma, building another single purpose jig was not an attractive option.


Most of the Led listings on AliExpress shows the displays being tested on some sort of ZIF socket. We will set to build something that works like that.




The following socket was found:


Here is the datasheet for the socket, we'll design a PCB based on these dimensions and adjust it later if needed.

And here is a preliminary PCB design. It is a very simple design where the bottom 9 pins on the socket are connected to an Arduino Nano.




Here is a preliminary design for a laser cut base. This design shares an edge between two pieces to minimize laser cutting time and therefore cost.


Once the socket arrives, the design for the tester and its base will be finalized. This will be a low cost tester, notice only the bottom 9 pins are wired, and that is good enough for the 16 segment displays. A later design might use the Mega Pro Mini and wire all the segments in the socket.