Sunday, June 28, 2020

Lessons learned from the last few projects

It is said that a picture is worth a 1000 words. This post condenses two years of learning into some instagram posts. 

Quoting another maker: "Just look, maintaining internal silence, until the meaning of my work becomes clear".

Here is a sample of my abilities before embarking on the projects on this page. This board was autorouted by Fritzing.
https://www.instagram.com/p/BRt6_bBhZ64/

Enigma Uno

Keep part count low. Every added part adds complexity to a kit.

How to design laser cut enclosure with finger joints using Sketchup and Inkscape


Pay attention to how the grain runs on the wood. In Ponoko, it runs from left to right. All the vertical pieces tend to crack when a nail is driven into them.

External Lamp Field

How to use charlieplexing to illuminate a large number of LED <n> output lines control n*(n-1) LED

Route PCB using horizontal lines in the front and vertical lines in the back



Do not solder/work when tired:

Sinclair Scientific Calculator:

Pins A6 and A7 in the Arduino Nano are analog input only. They can be used to read buttons provided a pull-up or pull-down resistor is used.

Route tracks on seven segment display modules by laying down horizontal tracks under the displays and vertical lines in the back to connect the same pins on each LED module together.

Sometimes it is necessary to eliminate the current limiting resistor in order to obtain decent brightness out of LED modules (older style bubble LED displays).

When unsure how something will fit, order a small board and try different spacings. You do not need to provide holes for all the pins. Be considerate of Oshpark and size your board so they don't lose money on shipping:

How to design LED and Keyboard multiplexing circuits in order to drive and read the largest possible number of displays and buttons. What happens when multiple keys are pushed at the same time.

If this is the first time you are doing something, breadboard it

Don't forget the mounting holes, make sure the PCB has four holes in the corners. Holes are free.

Don't forget any extra holes for things like lid hinges. Again, holes are free.

A PCB does not have to be square. It can have gently rounded corners or other shapes. The inner sharp corners shown here are impossible as the board fab house will cut the outline of the board with a rotating bit, they will come out webbed. 

Tent those vias

The Arduino VIN pin takes anywhere from 3.9V to 12V. Operation from 4 AAA to a 9V battery is possible. A power switch can be used to select between two power sources. They do not need to be the same voltage, as long as only one is connected at a time.

Measure battery endurance to find out how long will a device run on batteries., either use a light sensitive CdS cell and an external arduino to record changes in resistance or save a value evey minute to EEPROM

Test displays before soldering. Assemble one device and keep the displays unsoldered or make a dedicated device with a Zero Insertion Force (ZIF) socket.

Put years / version numbers on the PCB. Text is free.

LED Dimming using PWM

Use solder with water soluble flux, makes cleaning things easier

7 Segment Digits can be vertically scrolled. The bit representation of the digits can be rearranged so a shift left or shift right will move the bits from the previous to the new segment.

MegaEnigma/PicoEnigma:

14 Segment Displays can be vertically scrolled:

Use the F("") statement to store data tables in program ROM.

Pin D13 is connected to an external LED that can bias the pin. Avoid connecting this pin as an input. Either remove the LED or always set the pin as output and write high or low to force it to a known value.

Print a PCB design to paper and make sure components fit:

Don't trust Fritzing

Do not AliExpress when tired, you may buy a bag of unneeded components 

Sometimes soldering is the right solution, sometimes gluing is the right solution

Use the internal pull up resistor in order to connect the end of one or more push buttons to a pin, the other end to ground. Set the pin as input and write high to it. Reads 1 if nothing is pushed, 0 if pushed.

Use a fast pin library to read I/O. May need to write a wrapper function with a select statement to translate the pin number to the named variable used to access the pin.

Twist ties can be used to keep a top hinged lid in place, just make sure the PCB has a hole to secure it. Holes are free.
 
If your project has only LEDs and push buttons, there is no need for any extra external components. With careful coding they can be connected directly to an Arduino.

Use state machines as much as possible. Need to read many keys, that's one state machine. Need to drive many leds, that's another state machine. Need to do some time consuming processing and want to keep the keyboard and leds refreshed, split the time consuming task into simpler tasks using a state machine.

Route a PCB using the horizontal in front/vertical in back rule, then use vias placed under the components to minimize the amount of copper in the front layer.  

A daughter board can be used to hide the Arduino and the power connections on your project. It is cheaper to have 2 boards smaller than 100x100mm than one large board.

The new oshpark afterdark service can be used to embed some color on your boards. Try adding some logos or text to the copper layer.

Double check everything, why do we have a small logo on a side panel. Where are the hinge pockets

Double check your connections:

Try to put a standard Arduino power jack on your pcb

Try to put a battery compartment on your enclosures:

A 2 way switch can be used to select between an internal battery compartment and the power jack

Saturday, June 27, 2020

Pico Enigma and Mega Enigma Simulator Test Strings

Test strings to verify the correctness of PicoEnigma and MegaEnigma encryption:

To use the following string, press the menu button and change the machine to one of the models listed below, then paste the string into the Arduino Serial Port Monitor. The !AAA at the beginning changes the wheels to a know position before the lowercase characters are decoded. All of the test strings will result in AAAA when pasted to the correct machine. 

Machine Test String
I A !AAA sqcxf kbqcs rhjmm xtbuf zdmfc piinr dzwcs vutrv rbzus wgfcn cinio
I B !AAA ftzmg isxip jwgdn jjcoq tyrig dmxfi esrwz gtoiu iekkd cshtp yoepv 
I C !AAA twtvp tyixf fppyw svuso lidxh bbdok ztlzn fdube olqxf lhkhw vypem 
M3 B !AAA ftzmg isxip jwgdn jjcoq tyrig dmxfi esrwz gtoiu iekkd cshtp yoepv 
M3 C !AAA twtvp tyixf fppyw svuso lidxh bbdok ztlzn fdube olqxf lhkhw vypem 
M3 D !AAA jgtzx leioy lpwbe hfspo xlbrz zcbgo zfxvf hqjkj fkhmq ndvhr qzczi 
M3 D1 !AAA uipgp ofxtk mkeve tnbwq ohxgu keqoj bzvuc qqufm yfdgj udiuc kfzwq 
M3 D2 !AAA mnkhg vrjgm qrixe nolyc nxvow hdcfx ruqnb zqodc ixppd pdcwb oethu 
M3 D3 !AAA cfomw uxwfg cukke jyzom puzur rosde wsdmt kqqyo jznyi bdrxm ytbpr 
M4 B !AAAA ftzm gisx ipjw gdnj jcoq tyri gdmx fies rwzg toiu iekk dcsh tpyo 
M4 C !AAAA twtv ptyi xffp pyws vuso lidx hbbd okzt lznf dube olqx flhk hwvy 
N !AAA qwscm ijhvv vlrhx igxcw oddwu wzsjq wvfsk kxnqf gjqjn rupge ojrtv 
S !AAA zgdyt swlpz gmjdu zqqzd ewjzj drxpr whwmg jzvek uvnbe ptrkw hgfox 
D !AAAA hlkud thsyv icwnz wwdmw kgeog zyeqi hdtww lzeeu eifjx pgbke hiubr gcufi
K !AAAA inrkj yxuku tpiil mlqrg dofum bxrtz egtki tytpm zdzni usesg zyido 
R !AAAA tepwb pytxx msyid pumxb rqlwo nrzrf pikxr bdzcf oywyj uhumf unykn 
T !AAAA wlznv crjqp pgbdv nxgmg jgxcc iuwor lzcku oukit blizr ctoiu irfnt 
KD K !AAA wchug kzzsf nkioe liwwr ocksi etxxq pzfic euzff cwvsu fwmdg ertbn 
A865 !AAAA egwzq hddmg kuwqt xhuqv xrztx kehje gqtjo jkerw mpdec rttsv puejq 
G111 !AAAA qkuib bgtis ofzts jgmxi efgpi ubeuo bhujy ckssh jtxte wygmv nixec 
G260 !AAAA cknul qypie mmxyg htegz cdlvg tyxdb zgnvs kvqyh glvmz pyceu yczpn 
G312 !AAAA gjuiy cmdgu vttff qpzmx kvctz usobz ldzum hqmjx wtzwm qnnuw idyeq 

The test strings have been verified against Daniel Palloks Universal Enigma Machine Simulator and will also return all A if the wheel changing string !AAAA is removed and only the lowercase characteres are pasted.


To test the strings with either Pico or Mega Enigma using a computer.

1) Plug in either simulator into a computer.

2) Open The Arduino Serial Monitor

3) Press the red button, MACH will be displayed and illuminated in the lamp field

4) Use the up/down keys below the rotors or press K until KD K is displayed.

5) Press the red button repeatedly to exit the menu until all the lights in the lampfield turn off.

6) Copy the whole string on the KD K row: !AAA wchug kz...

7) Paste it into the Serial Monitor, all A will be displayed.


To test the strings with either Pico or Mega Enigma 

1) Press the red button, MACH will be displayed and illuminated in the lamp field

2) Use the up/down keys below the rotors or press K until KD K is displayed.

3) Press the red button repeatedly to exit the menu until all the lights in the lampfield turn off.

4) Start typing the whole string on the KD K row: "wchug kz..."

5) The letter A will be illuminated in the lamp field.


To test the strings with Palloks Universal Enigma:

1) Open this link:

2) On the drop down menu on the top right corner of the page, select KD (rewirable UKWD).

3) On the list above, copy the text on the KD K line starting from wchug kz...

4) Paste it on the input side of the Universal Enigma Machine Simulator. The output panel on the right should display all A.

Sunday, June 7, 2020

Assembly Notes for PicoEnigma

Pico Enigma Assembly Notes:

Top Board Assembly:

-Insert Buttons into PCB (1 red button under Enigma Logo, the rest, black)
-Solder one leg of Buttons while pushing down the PCB to keep them in alignment.
-Verify button alignment
-Solder the rest of the buttons.
-Test LEDs
-Insert LEDs into Lamp Field (short leg points towards buttons, long leg on display side)
-Double check short leg of each LED is in bottom hole.
-Solder one side of LEDs while pushing down on the PCB to keep them in alignment
-Verify LED alignment (double check LED polarity again before committing to soldering them all)
-Solder the other leg of the LEDs
-Verify the 14 Segment Displays
-Insert 14 Segment Displays on PCB (ensure the dot points down towards the lampfield)
-Solder one pin of each 14 Segment Display
-Verify 14 Segment Display alignment
-Solder the other pins
-Break 2 strips, 10 pins long from the double pin header.
-Fully insert the pin strips (short side up) from the bottom of the PCB,
-While pushing down on the PCB, solder 1 pin.
-Verify the pin strips are fully inserted and aligned properly.
-Solder the rest of the pins.
-Insert the power switch
-While pushing down on the PCB and watching the alignment, solder one pin.
-Verify alignment
-Solder the rest of the pins
-Trim the LED legs
-Trim the Power Switch legs very short, otherwise it interferes with the power connector.

CPU Board Assembly:
-Program the Arduino Mega
-Prepare a 10 pin length, a 4 pin length, a 2 pin length and 1 pin length of header pins.
-Insert the pin headers, long side towards flag side of CPU Board. Plastic headers should be on the non-flag side of the board.
-Insert the Arduino Mega on the short pins. The Arduino should be on the non-flag side of the board.
-Flip the board flag side up and while pushing down, solder 1 pin of each header.
-Flip the board, verify alignment and solder 1 pin of each header to the Arduino.
-Solder the rest of the pins.
-From the long female pin header, break 4 x 10 pin lenghts, clean the ragged edges.
-Insert the female pins on the Arduino side of the CPU Board
-Temporarily mate the Top Board to the CPU Board
-Solder one pin of each female header
-Verify the alignment and solder the rest of the pins.
-Separate the CPU Board
-Insert the Power Connector on the Arduino Side of the CPU Board
-Flip the board and tack solder one corner of each pin. Do not apply excess heat to this connector.
-Allow to cool and go back and finish soldering the pins. Do not apply excess heat to this connector.

PCB Bring Up (Initial Power Up)
-Mate the top board to the CPU Board
-Using a 9V battery and a male power plug, apply power to the board
-Flip the power switch to the EXT position.
-The board should power up and display AAAA (if not, check the solder joints, make sure the Arduino is powered up, connect to the board using the Arduino Serial Monitor at 9600 baud, upon powerup it will display PicoEnigma in the Serial Monitor)
-Repeatedly push the red menu button until V16 is shown. 
-Push one of the buttons adjacent to the 14 Segment Displays.
-The display should change to 8888 (if not, check the solder joints of the buttons)
-The lamp fields LEDs will turn on sequentially (if not, check the solder joints).
-Press each key, the corresponding lamp should turn off. (if not, check solder joints)
-Once all the keys have been pressed, the simulator will return to AAAA, use the buttons above and below each letter to change them. Verify the X and T letters display properly. In addition to 8888, this tests all segments. If one segment is not working, check the solder joints).
-Separate the CPU and Main Boards and clean the solder flux (if using water soluble flux, simply wash the boards under running water while scrubbing with a toothbrush)
-Dry the boards thoroughly, use a blower or canned cleaning duster to blow all the water from under the Arduino, the push buttons and the display.
Once the boards are thoroughly dry (do not rush this step), power them up and repeat the key/led test procedure above. If a key does not work or a single key turns off multiple lamps, dry those keys thoroughly.
-If the boards have mouse bites, this is the time to sand them off. Dry, clean and re-test the boards.

Battery Compartment Assembly:
-Locate the base piece of the case. Insert 4 screws in each corner of the battery compartment.
-Drive the screws in until they barely protrude from the other side.
-The first battery compartment piece has a hex nut opening, this allows retaining washers to be used on the battery door.
-Align the holes on the battery compartment piece on the protruding screws.
-While firmly pressing the battery compartment piece to the case base piece, drive the screws in, one at a time, ensure the battery piece is tight against the base piece. Drive the screws in until they begin to slightly protrude from the battery piece.
-The next battery compartment piece has a small round opening. Drive the screws in.
-The next piece will have a hex nut opening, install a nut in each opening. Drive the screws in.
-Install the rest of the pieces, Drive the screws in.
-Finally, install the flat piece with the single hole. The hole needs to be on the same side as the enigma logo and the power switch. Drive the screws in.
-Once the screws heads reach the case base piece, tighten them until the taper sinks into the base piece but do not over-tighten (hard woods such as walnut crack easily).
-Install a 9V battery on a power plug. Cut off and dispose of the male barrel plug (cut one wire at a time), The wires coming off the battery need to be as long as possible.
-Insert the leads from the battery into the battery compartment hole. Insert the battery into the compartment, wire first, the connector will be on the side opposite the hole. 
-Fold the battery leads flat against the top of the battery compartment.
-Fold them down the long side of the battery compartment.
-Install a tie wrap on outside of the battery compartment, holding the battery leads against it. This will prevent pulling on the solder joints if the battery is pulled.
-Put a piece of tape over the battery wires to prevent the keyboard buttons from cutting into them.
-Disconnect the battery
-Solder the battery wires to the CPU Board (separate from main board first).
-Install the battery
-Close the battery compartment.

Assembly:
-Install the 25mm brass standoff on the main board, use the plastic screws to attach them.
-Tie a simple knot on the twist wrap that serves to hold the lid in place. Insert from the bottom of the main board. Apply a drop of glue to the bottom of the board to secure the knot in place.
-Put a piece of tape over the keyboard pins to prevent them from cutting into the battery wire.
-Once the glue dries, connect the Main Board to the CPU Board (the CPU board needs to be connected to be battery compartment at this point). Ensure the Main Board pins are driven all the way into the CPU board headers.
-Using brass screws, secure the standoffs to the case base plate. 
-Turn the power switch to the INT position, the simulator should power up, if not, check the battery lead solder joints.

Case Assembly:
-Prepare the lid pieces, remove any remaining laser film.
-Install the screw that will hold the other end of the twist tie on the side piece. The screw should be above the hole in the PCB where the other side of the twist tie is installed. If using hardwoods, drive the screw in half a turn, then remove it and drill out the hole. Walnut cracks easily and if the screw is simply driven in, it will crack the side piece in half. Cut the tip of the screw off and install on the drilled hole.
-Mock assemble the lid piece, making sure the Enigma logo is to the inside and that the piece with the hinge pockets is near the Enigma Logo. The side piece with the screw should be on the left side of the lid, screw facing up.
-Moisten a paper towel and clean your fingers, cleanliness is paramount at this stage to prevent glue from finding its way into a flat surface.
-Lay down some paper towel and put all the lid pieces in their correct positions, The Enigma logo needs to be facing up so that is readable.
-Apply a drop of glue to the inside of each finger joint of a side piece. Insert into the Enigma piece.
-Repeat until all 4 sides are installed.
-Careful of not touching the glue, push all 4 sides tightly.
-Flip the lid face down into a clean piece of paper and push down on it.
-Set aside to dry.

-Repeat the process for the bottom pieces of the case, mock the side pieces and arrange them around the base piece. 
-Apply glue the side pieces and install them one at a time.
-Apply pressure to each side piece to ensure there are no gaps around them.

-Install the hinges on the lid. 
-Drive the nails in by grabbing them with multi-tool pliers and pushing them into the wood.. Once they are embedded in the wood, use the tip of the pliers to push them in all the way. 
-Align the lid with the bottom case and install one nail. Verify the lid aligns with the case.
-Install the rest of the nails.
-Minor lid misalignments can be corrected by gently twisting the lid when closed.
-Connect a power plug on the back of the simulator and observe the lid angle that keeps the lid from touching the power plug. 
-Fold the twist tie around the screw in the lid so the lid stays open at that angle. Twist the tie around itself and back around the screw so it does not work itself loose.
-Align and glue a Merkblatt