This new version DHD PCB can function all on its own without the need for the extra keyboard PCB. It connects to the raspberry pi with a regular micro-USB cable. The DHD PCB is recognized by the raspberry pi as an ItsyBitsy 32u4 – 5V 16MHz and can be programmed like an Arduino. If you are looking for the first version, you can still see the information on this page.
Jonathan Moyes lent me his expertise with PCB design. All the PCB, schematics, hardware, firmware etc. came from his brilliance. I have tried to make this page as step-by-step guide for others to make their own DHD PCBs from Jonathan’s designs.
You can see the schematic for the PCB here.
What hardware do we need?
First one needs to order the PCB and a stencil from a PCB manufacturer. I used JLCPCB.com. Upload the DHD_v2_RC1_GERBERS.zip file in the ordering page at JLCPCB and order with the following settings:
- Layers: 2
- Dimensions: 100x100mm
- Different Design: 1
- Delivery Format: Panel by JLCPCB
- Panel Format: 1×1
- Edge Rails: On 4 sides
- PCB Thickness: 1.6mm
- PCB Color: Green
- Surface Finish: Lead-free HASL-RoHS
- Copper Weight: 1oz
- Gold Fingers: No
- Confirm Production file: Yes
- Flying Probe Test: Fully test
- Castellated Holes: No
- Remove Order Number: Yes
- Framework: No
- Dimensions: 380x280mm
- Customized size: No
- Stencil Side: Top
- Stencil qty: 1
- Electropolishing: yes
- Fiducials: None
There are a lot of tiny, (very tiny!) SMD components that needs to be soldered to the PCB using a reflow method. (I used an electric skillet). The microchip also has a lot of very small solder pads. To apply the solder-paste to those pads we need a good stencil.
In addition to the bare PCB and stencil we also need a lot of resistors, an atmega32u4 microchip, the LEDs, and a few other parts. I ordered all the SMD parts on digikey.com except the LEDs which I ordered from Sparkfun.com. Jonathan created this handy CSV file which serves as a bill of materials showing all the parts to be soldered on the DHD PCB. The BOM file is also included in the archive together with a .xlsx version. Take special notice to the Reference Designators column and be sure to solder the correct part to the correct place on the PCB. You need to solder the Microchip and LEDs with the correct orientation. There are small white dots on the PCB that indicates the orientation of the parts. We will also need some solder paste. I used SMD291AX50T3, and I think Jonathan prefers Kester Solder 70-4021-1410.
The microchip comes with some default settings we need to change. We can set up the chip using an Arduino. I used the ItsyBitsy 32u4 5V 16MHZ. It makes sense since that’s the board we are mimicking.
That should be it for the needed hardware components. Now let us look into the soldering of the PCB.
First things first: make sure there is not a power-ground short on each PCB before assembling them. Just take your multimeter, set it to resistance/Ohm mode, and touch the probes together to ensure you get a reading very close to 0 Ohms, to prove that the meter is working. Then touch the probes to the GND and VCC pads on the back of the board. You are hoping to see OL/Open Line (infinite resistance). You will repeat this test after assembly and before powering it up, but after assembly we expect to see something in the high K to low M-ohm resistance. If we see very small resistance, there’s a chance there is a power-ground short on the board and plugging it in would let out the magic blue smoke that makes electronics work.
Let us go over the materials/tools you will need:
- The bare PCB and the parts from the BOM file.
- The stencil to help with solder paste application.
- Packing tape, to hold the stencil in place.
- Isopropyl Alcohol, to clean the solder paste from the stencil and tools.
- A flat surface that you can tape PCBs down to. It should be a bit larger than your stencil, and at a comfortable working height.
- Some other PCBs of the same thickness as the board you are assembling. We will use these to make a frame to align the board and stencil.
- Solder Paste. The best is Lead-Free/RoHS, No Clean paste.
- Electric skillet, to use as a reflow oven. To melt the solder paste and do the actual soldering.
- Nice tweezers for placing components.
- 6″ Steel putty knife – we will use this as a squeegee to screen the solder paste on the board. You really want to do the whole width in one pass, hence the 6″.
- Plastic putty knife to work the material out of the jar, get it lined up on the 6″ knife, and to help knead the paste before application.
- Pliers to break the board out of the frame.
This is the soldering process that worked well for me:
- Build your stenciling frame.
- Line up and tape down the stencil.
- Prepare the putty knife w/ paste.
- Screen the paste.
- Post-print inspection.
- Place the parts on the PCB. (Except the buttons and the USB connector. The USB connector will be soldered to the back of the board with a regular soldering iron). To make placing the parts easier I recommend sorting them beforehand and keeping track on what components to place where. I lined them up on a piece of paper where I wrote down what components to put where. I taped the paper to the table to avoid shuffling it around and accidentally mixing the parts.
- Reflow. Carefully place the board in the electric skillet and crank the heat. Keep watching to see when the solder melts and the magic happen. (see video below). Make sure the parts are soldered on the entire board before powering it off and letting it cool down again. There is a nice article about reflow soldering using an electric skillet at SparkFun here.
- Post-solder inspection. Check that all soldering points looks shiny and appropriate. Check for bridging or soldering errors around the microchip.
- Pre-smoke test using the multimeter as mentioned above.
- Solder the USB connector to the back of the board using a soldering iron. The USB cable should connect to the board from the underside. To make the board fit nicely in the DHD model you need to make sure it is not soldered at an angle. It needs to be lined up correctly.
- Solder on 6 wires to the pads on the back of the board. These are just temporary and will be removed again later. They are used to connect the DHD PCB to the ItsyBitsy to set up the microchip.
This video shows the soldering and assembly process
That is it for the soldering. Now it is time to configure the microchip and upload the Arduino program to our newly created DHD PCB board.
Programming the DHD PCB
First, we need to configure the atmega32u4 microchip on the DHD PCB so that whatever computer we connect it to will recognize it. We will do this using an ItsyBitsy 16MHz, 5v. (You can use most arduino variations or a real programmer to to this also).
- Take out the ItsyBitsy 16MHz, 5v and solder on the header pins if you have not done it already.
- Install the Arduino IDE on your computer. Here is a guide that shows how this is done in Windows.
- Configure the Arduino IDE to work with the ItsyBitsy as seen in this guide.
We need to upload a specific sketch, the ArduinoISP, to the ItsyBitsy to use it to change the settings on our own microchip:
- Connect the ItsyBitsy to your computer and fire up the Arduino IDE
- Make sure you have selected the right board and port in the tools menu. (Your port may differ from mine of course)
- Open the ArduinoISP sketch.
- Upload the sketch to the ItsyBitsy.
Our microchip programmer device is now ready, and we can use it to program the DHD firmware on the DHD PCB. I prefer doing this on a raspberry pi. I had issues using avrdude on my windows computer, but It worked brilliantly on the pi.
Boot up the raspberry pi and install avrdude.
sudo apt-get install avrdude
Copy the DHD_Keyboard.ino.with_bootloader.promicro.hex to your raspberry pi. This file contains the firmware for the DHD. You will find the file in the downloadable archive in this folder: Hardware\DHDv2\ (Note: If the file is not there, download the archive again for an update. The file was added to the archive the 25th of July 2022)
Connect the 6 wires soldered to the back of the DHD PCB to the ItsyBitsy on the following pins:
Arduino -> DHD Board 5V -> 5V GND -> GND 10 -> RST MOSI -> SDO MISO -> SDI SCK -> SCL
Connect the ItsyBitsy with a micro-USB cable to the raspberry pi.
Run the following commands in order on the raspberry pi. You might need to check what port is used to reach the ItsyBitsy. Most likely it’s /dev/ttyACM0 or /dev/tty/ACM1. If not, you can try /dev/serial/by-id/usb-Adafruit_ItsyBitsy_32u4_5V_16MHz-if00
The first command erases the chip and is necessary in order to run the three next commands.
avrdude -P /dev/ttyACM0 -b2400 -cavrisp -pm32u4 -B 2 -e avrdude -P /dev/ttyACM0 -b9600 -cavrisp -pm32u4 -U lfuse:w:0xff:m -B 25 avrdude -P /dev/ttyACM0 -b9600 -cavrisp -pm32u4 -U hfuse:w:0xd8:m -B 25 avrdude -P /dev/ttyACM0 -b9600 -cavrisp -pm32u4 -U efuse:w:0xcb:m -B 25 avrdude -P /dev/ttyACM0 -b9600 -cavrisp -pm32u4 -U flash:w:DHD_Keyboard.ino.with_bootloader.promicro.hex
After running the lfuse, hfuse and efuse commands you should get output in avrdude similar to this: Make sure the line marked with red has the correct Fuses OK (E:CB, H:D8, L:FF)
pi@stargate:/dev/serial/by-id $ avrdude -P /dev/ttyACM0 -b9600 -cavrisp -pm32u4 -U efuse:w:0xcb:m -B 25 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9587 (probably m32u4) avrdude: reading input file "0xcb" avrdude: writing efuse (1 bytes): Writing | ################################################## | 100% 0.01s avrdude: 1 bytes of efuse written avrdude: verifying efuse memory against 0xcb: avrdude: load data efuse data from input file 0xcb: avrdude: input file 0xcb contains 1 bytes avrdude: reading on-chip efuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of efuse verified avrdude: safemode: Fuses OK (E:CB, H:D8, L:FF) avrdude done. Thank you.
To verify we can disconnect the ItsyBitsy from the pi and the DHD PCB. Connect the DHD PCB with the USB cable to the raspberry pi. Check the /dev/serial/by-id folder. There should now be a file named usb-SparkFun_SparkFun_Pro_Micro_HIDPC-if00.
Let us test the keyboard functionality. Disconnect the board and add a button or two. (or all of them). Open notepad or any similar program. Connect the DHD PCB with the micro-USB cable and hit the button(s). Letters should appear in notepad.
We can fully test the DHD PCB by running the included dhd_test.py script. If you have not done so already you first need to set up the python virtual environment and install the required modules. You can see step by step instructions on how to do this here. Make sure that the dhd_test.py script is the only custom active script in the .bashrc file and restart the raspberry pi. When it boots up it should first run through all the LEDs before you can toggle the LEDs with the keys. This video below shows the result of running dhd_test.py
If everything worked, it is time to remove the temporary wires (solder them off) and break it out of the frame if you have not done it already. It should fit nicely into the printed 3D model:
The DHD buttons
In the TV Show the DHD buttons light up when pressed. This means using “transparent” plastic for the main part of the button. And a “cover” on top that does not let the light through. When held up against the light coming from the window, it looks like this.
Below are a few pictures of the fully assembled DHD and a video of the dialing process.
The Stargate will not do much without a valid address to dial, so I made this tablet with a few Stargate addresses. I based the design on a goa’uld tablet from the TV show.
Hopefully you liked how I made the DHD using a custom PCB. If you haven’t checked it out already, I encourage you to also take a look at how I made the Stargate itself.
If you have any comments or questions, feel free to use the comments section here. Or, you can send me an email at firstname.lastname@example.org