Introduction: HackerBox 0100: Centurion

Welcome to HackerBox 0100. Explore the use of digital logic analyzers to gain visibility into embedded microcontroller systems. Configure the PulseView graphical frontend to operate with the NanoDLA 24MHz, 8-Channel digital logic analyzer. Program the Raspberry Pi Pico development board and assemble the Centurion PCB around the Pico to serve as a bus analysis target. Leverage the NanoDLA to capture and analyze digital clock signals, I2C transactions, and video traffic on a SPI bus. Program the Pico to display graphics and human interface elements on a unique circular color display and also to sample motion and positioning data from a combined gyroscope, accelerometer, and magnetometer module.

HackerBox is the original monthly subscription box for electronics, computer technology, and hacker culture. Each HackerBox is a discovery box, which means all members await and enjoy a new surprise each month. Tech, toys, knowledge, and fun. It's like having a hacker convention, your birthday, and the first day of school - every month - right in your mailbox.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0100. The full box contents are listed on the product page for HackerBox 0100 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party. Subscription members save at least $15 every month and automatically receive each new HackerBox shipped immediately off the production line.

A soldering iron, solder, and basic assembly tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for tools and supplies along with a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.

Step 1: NanoDLA USB Logic Analyzer

The NanoDLA is a 24MHz, 8-Channel digital logic analyzer. The NanoDLA interfaces to a computer over USB for control and display of the logic analyzer features.

A logic analyzer is an electronic instrument that captures and displays multiple logic signals from a digital system or digital circuit. A logic analyzer may convert the captured data into timing diagrams, protocol decodes, state machine traces, opcodes, or may correlate opcodes with source-level software. Logic analyzers have advanced triggering capabilities, and are useful when a user needs to see the timing relationships between many signals in a digital system. (wikipedia)

Hello World

When the NanoDLA is first connected via USB-C, its blue LED will illuminate.

WinUSB Driver

When the NanoDLA is first connected to a Windows box, "fx2lafw" will usually appear in the Device Manager under "Other Devices" indicating that a driver is not present.

A driver can be installed using Zadig, which is a Windows application for installing generic USB drivers.

Upon running Zadig, choose the device named "fx2lafw", which will show a USB ID of 1D50:608C. Then select "WinUSB" in the driver option and click the "Install Driver" button.

Once the driver is installed, "fx2lafw" will have moved from "Other Devices" to "USB Devices" in the Device Manager.

Install PulseView

PulseView is a graphical frontend providing access to a wide range of devices and protocol decoders to record, analyze, process, and export signal data from test and measurement devices, including the NanoDLA.

PulseView can be downloaded here for use on Windows, MacOS, or Linux.

Step 2: Raspberry Pi Pico

The Raspberry Pi Pico is a tiny, fast, and versatile board built using RP2040, the flagship microcontroller chip designed by Raspberry Pi. The RP2040 features 133MHz dual-core ARM Cortex-M0+ processing, 264kB internal SRAM, support for up to 16MB of off-chip flash (2MB provided on the Pico), a DMA controller, 30 GPIO pins (4 of which can be used as analog inputs), and a wide range of flexible I/O options includes I2C, SPI, and exclusive Programmable I/O (PIO).

Raspberry Pi has provided a lot of great online documentation.

Before Soldering Anything

Plug the Pico into your computer using a microUSB cable. A new mass storage device (basically a flash drive) will appear. It will have the name RPI-RP2. If it does not appear, unplug the USB cable, hold down the BOOTSEL button and plug the USB cable back in before releasing the button. You can execute this BOOTSEL procedure anytime to force the Pico into a receptive state for (re)programming.

The RPI-RP2 mass storage can accept a UF2 file. Just copy/paste or drag the file onto the storage device. Once you drop it in, the Pico will automatically reset and run deposited program.

UF2 stands for USB Flashing Format. The associated bootloader allows embedded devices to be programmed using a simple USB mass storage class (removable drive) interface. The bootloader is also compatible with BOSSA (Basic Open Source SAM-BA Application), which is used by the Arduino IDE.

Arduino IDE

Install the Arduino IDE software and setup the Raspberry Pi Pico Arduino core as outlined here.

In the Arduino IDE, select: Tools > Board > Raspberry Pi RP2040 Boards > Raspberry Pi Pico

Open File > Examples > Basics > Blink

Execute the BOOTSEL procedure if necessary (unplug the USB cable, hold down the BOOTSEL button, and plug the USB cable back in before releasing the button)

Hit the arrow icon to compile the sketch and upload it to the Pico.

The Pico's green LED should start blinking once the code is uploaded and starts running.

Step 3: Centurion PCB

Once the Raspberry Pi Pico is tested and operation with the Arduino IDE tool chain has been verified, it is time to solder the module onto the Centurion PCB.

The Centurion PCB is designed to serve as a bus analysis target. The pins of the Raspberry Pi Pico are broken out to headers and the Pico is hardwired to peripherals using both I2C and SPI protocols.

Solder the Raspberry Pi Pico

It is recommended to solder the Pico using its castellated pads (tutorial) to maximize spacing around the breakout headers. Optionally: A strip of header pins is included if you prefer to solder the Pico using pins. Note that the header strip has 40 pins and would need to be snapped into two strips of 20 pins for use mounting the Pico module.

Solder the Breakout Headers

The Centurion PCB supports two rows of breakout headers around the Pico. These are indicated by the orange arrows in the image. Snap a single header strip (40 pins) into two strips of 20 pins and solder those into the designated holes. For easy access while using the logic analyzer, it is recommended to orient the breakout headers with the longer pins directed up from the top of the PCB and with the black plastic insulators sitting on the top of the PCB.

Step 4: Capturing Logic Traces

Download, compile, and upload the attached clock_divider.ino sketch.

Sketch output:

  • A square wave "clock" signal on pin 2
  • A clock signal on pin 3 with half the frequency of pin 2
  • A clock signal on pin 4 with half the frequency of pin 3
  • A clock signal on pin 5 with half the frequency of pin 4
  • Signal to LED_BUILTIN synced to the slowest clock (pin 5)

Connect the Pico's GPIO pins 2-5 (with the signals described above) to the CH0-CH3 pins of the NanoDLA

Connect one of the Pico's GND pins to a GND pin of the NanoDLA

Run PulseView

Click the device selector.

In the popup window, choose the driver "fx2lafw (generic)", set interface to USB, and hit "Scan for devices"

Select the device found: sigrok FX2 LA with 8 channels

Use Run/Stop to collect signal data, which should look like the square waveforms in the image

Modulo Operations

Aspiring mathemagicians, mathletes, and the binary curious will take interest in the sketch's use of the modulo operator (%) to elegantly generate the various "clock" signals. For example:

//pin 4 rises when count is divisible by 8
  if ((c % 8) == 0)
    digitalWrite(4, HIGH);
//pin 4 falls when count/8 leaves remainder of 4
  if ((c % 8) == 4)
    digitalWrite(4, LOW);

Step 5: Complete Assembly of the Centurion PCB

Six SMD Tactile Buttons Switches

Solder the surface mount buttons onto the red PCB. Each can be oriented in either direction.

Round TFT Display Module

The full-color TFT display has a resolution of 240x240 pixels and a diameter of 1.28 inches. The driver chip is a GC9A01 and supports an SPI interface.

  • Solder the header pins onto the module such that they extend from the rear of the module
  • Optional: Gently pry the black plastic insulator off of the header pins so the module can seat flat against the PCB
  • Solder the module onto the red PCB

Required Library: Search "Manage Libraries" in the Arduino IDE for "GFX Library for Arduino by Moon On Our Nation"

MPU-9250 Gyroscope, Accelerometer, and Magnetometer Module

The MPU-9250 IMU Breakout features the 9-axis MEMS sensor. Featuring nine degrees of freedom (DoF). The functionality combines an MPU-6500, which contains a 3-axis gyroscope as well as a 3-axis accelerometer, and an AK8963, which features a 3-axis magnetometer. Module Wiki Page

  • Solder the header pins onto the module such that they extend from the rear of the module
  • Optional: Gently pry the black plastic insulator off of the header pins so the module can seat flat against the PCB
  • Solder the module onto the red PCB

Required Library: Search "Manage Libraries" in the Arduino IDE for "MPU9250_WE by Wolfgang Ewald"

For Future Reference: Pin Connection within the PCB

// TFT Display Pins
TFTDIN GP11 
TFTCLK GP10 
TFTDC GP8
TFTCS GP9
TFTRST GP12

// MPU9250 Pins
MPU_SDA GP0
MPU_SCL GP1
MPU_AD0 GP22  //I2C ADR (not used in example sketches)
MPU_nCS GP26  //Chip Select (not used in example sketches)

// Switch Button Pins
SW_UP  GP16
SW_DN  GP18
SW_LF  GP19
SW_RT  GP17
SW_A   GP21
SW_B   GP20

// Unused GPIO pins (use these for your own connections)
2,3,4,5,6,7,13,14,15,27,28


Demonstration Sketch

Download, compile, and upload the attached HB0100_Demo.ino sketch to exercise the basic functionality of the six buttons, the display, and the MPU module.

While executing the sketch, addition information is pushed to the serial output. To see this, open the Arduino IDE Serial Monitor and set the baud rate to 9600.

Step 6: IMU Based HMI

Download, compile, and upload the attached Centurion_Ball.ino sketch.

The sketch demonstrates a simple human-machine interface based on inertial measurement. Motion of an on-screen ball is controlled by tilting the board. The left and right buttons can be used to change the ball color.

This basic functionality can be used for a game or displaying more complex visualizations.

Inspirational Resources

Volos used this same display for making round gauges using the TFT_eSPI library. His project leverages an ESP32, but the Arduino code shouldn't be too hard to get working on the Pico Pi. He made a really cool game project as well.

If you'd rather code this system in CircuitPython, get the setup from Adafruit, and check out these GC9A01 demos from todbot.

Step 7: Logic Analyzer I2C Decoder

The Pico Pi uses an I2C interface to communicate with the MPU-9250 motion sensor module. Let's use the NanoDLA Logic Analyzer to peek inside.

The Pico Pi has the I2C SDA on GP0, connect this to one of the CH0-CH7 pins of the NanoDLA

The Pico Pi has the I2C SCL on GP1, connect this to one of the CH0-CH7 pins of the NanoDLA

Connect one of the Pico Pi GND pins to a GND pin of the NanoDLA

Run PulseView and select the device: sigrok FX2 LA with 8 channels

Click the decoder icon and select I2C

This will add an I2C trace to the display as shown in the image

Click on the flag to the left of the trace and set the SDA and SCL pins to whichever NanoDLA pins that you connected the wires to. Note that these are not necessarily the same numbers as the GP0 and GP1 on the Pico. They might be, if that is how you connected the wires, but you might want to try using some different NanoDLA channels to see that it doesn't matter as long as you put the correct pin numbers into the I2C decode settings.

Set the slave address as SHIFTED.

Use Run/Stop to collect signal data.

The I2C decoder trace shows the Pico issuing Address Write 0x68 followed by Data Write 0x3B. As you can see in the code, the I2C address of the MPU-9250 is 0x68. If you look up the MPU-9250 datasheet, you can discover that the Accelerometer Register of the MPU-9250 is 0x3B. This register is what the Pico is asking for.

Next, an Address Read 0x68 (again the address of the MPU-9250) returns Data Reads of six bytes. The datasheet shows that the Accelerometer Register (0x3B) request returns three 16 bit values (six bytes) representing the X, Y, Z components of the accelerometer measurement.

FYI: If you change the I2C decoder setting for the slave address to UNSHIFTED, you will notice that the 0x68 value in the trace changes to 0xD0 for writes and 0xD1 for reads. This is a common source of confusion due to the fact that a read/write bit can be appended to the end of the address. This starts with the address itself getting shifted up one bit (multiplied by 2) which can be verified on a calculator by noting that 0x68 * 2 = 0xD0. Then the read/write indicator is placed into the lowest bit position. A 0 is added (just leaving 0xD0) for an I2C write or a 1 is added (resulting in 0xD1) for an I2C read.

These details may seem a bit complicated, which is why we abstract them away with libraries and such. It is nice to see that, at the bottom, it's all just bits (voltage levels) choreographed into a beautiful dance doing exactly what we tell them to do.

Step 8: Logic Analyzer SPI Decoder

The Pico Pi uses a SPI interface to communicate with the GC9A01 of the display module. Again, let's use the NanoDLA Logic Analyzer to see just what what's being said.

The Pico Pi has SPI Chip Select (CS) on GP9, connect this to one of the CH0-CH7 pins of the NanoDLA

The Pico Pi has SPI Clock on GP10, connect this to one of the CH0-CH7 pins of the NanoDLA

The Pico Pi has SPI MOSI on GP11, connect this to one of the CH0-CH7 pins of the NanoDLA

Connect one of the Pico Pi GND pins to a GND pin of the NanoDLA

Run PulseView and select the device: sigrok FX2 LA with 8 channels

Click the decoder icon and select SPI

This will add a SPI trace to the display as shown in the image

Click on the flag to the left of the trace and set the CS, CLK, and MOSI pins to whichever NanoDLA pins that you connected the wires to. Again these will not necessarily be the same numbers as the GP0 and GP1 on the Pico. The MISO pin can be left undefined since it is not used, and the CS should be left as active low (indicated as #CS or nCS).

Use Run/Stop to see a lot of data. As you'd expect, displaying graphics requires pumping out a lot of data. The quickest way to isolate some specific activity on the SPI bus, should you wish to do so, would be to halt the script at interesting places. For example, just before or after the gfx-> calls in setup(). The sketch can be halted by inserting the line: while(1); Then it will be less noisy and we can capture what the setup process looks like on the bus.

You may need to turn up the capture frequency of the logic analyzer and then it might also help to enlarge the capture buffer. These settings are right on the main screen in PulseView.

Step 9: Retro-Gaming in a Flash

The two 16GB USB flash modules were obtained as surplus from a commercial product manufacturer (most likely intended for a communications system or medical device). When the opportunity came up to grab these barely used (unused?) units for inclusion in a HackerBox, we jumped on it and doubled the order. We understand that they are good quality and should work excellently, but they are surplus, so maybe don't use one to store the only copy of your life's work. Also, if one of them seems weird in some way, just throw it out and use the other one.

These might be great for logging data, adding music files to your car's audio system, and a variety of other non-critical storage applications. You can also play around with booting into another operating system without impacting your main drive setup. One very cool option, especially if you are into retro games, is Batocera Linux. It's an open-source and completely free retro-gaming distribution that can be copied to a USB stick or an SD card with the aim of turning any computer into a gaming console. Batocera does not require any modification on your computer and supports most controllers out of the box. Download, flash, connect, and play!

Step 10: HackSpaceCon 2024

HackerBoxes is proud to sponsor the Hardware Hacking Village at HackSpaceCon in April 2024. 

Come join us to learn and play at the historic, and futuristic, NASA Kennedy Space Center.

We do these things not because they are easy, but because they are hard(ware).

video teaser

Step 11: Trust Your Technolust

We hope you really enjoy the exclusive HackerBox "C Note" PCB Ruler featured in this box. The unique design is full of hidden messages and is suitable for framing. If that's not your jam, just flip it over and use it as a ruler, because you rule!

Thank you for joining us in another monthly adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or on other social media. Email support@hackerboxes.com anytime with questions or whenever you need some help.

Want more? Surf over to HackerBoxes.com and sign up as a monthly HackerBox subscription member. You'll get a cool box of hackable gear delivered right to your mailbox every month and you'll enjoy a generous member discount.

Lastly, please share this free Instructable with others who might find it interesting. We really appreciate your support and "word of mouth advertising" is the greatest compliment that we can receive.