feature article
Subscribe Now

$4 Logic Analyzer Based on Raspberry Pi Pico

Here’s a truly inspired project. Dr. Agustín Gimenez Bernad, a Senior Developer in ServiZurich S.A. in Spain, has created one of the most brilliant hacks I’ve seen yet. He’s built a 24-bit logic analyzer that samples at 100 Msamples/sec and stores 32K samples from nothing more than a $4 Raspberry Pi Pico board and some clever code. There’s a lot to learn from this project, which is posted with some very fine documentation on GitHub, but if you just need a $4 logic analyzer, there’s still a lot to be admired.

I go way, way, way back with logic analyzers. My Senior Lab project in college was a logic analyzer. I ordered a bunch of 2102 1Kbit SRAMs from Bill Godbout Electronics, which was located in a Quonset hut on the edge of the Oakland airport. Those SRAMs were a hot item back then. Put eight of them together and you had all of 1Kbyte of RAM for your 8080 microprocessor. I didn’t know it at the time, but Godbout supplied parts to all the early microcomputer pioneers at the Homebrew Computer Club in the San Francisco Bay area including Lee Felsenstein (Processor Technology Sol 20) and George Morrow (Thinkertoys and Morrow Microsystems). I mention those two people because I eventually bought 8-bit microcomputers designed by both of them. (Sadly, Bill Godbout perished in one of the 2018 California wildfires.)

My Senior Lab logic analyzer never worked. My portions of the project, the probe front end with variable logic levels and the memory subsystem, worked. However, my project partner did not complete their part of the project and I’m guilty of not coordinating well with my partner during the project development cycle. Nevertheless, I learned a lot about digital instrument design (and team-based design) from the project. That was back in 1975.

Just a few months later, I joined HP’s Calculator Products Division in Loveland, Colorado. When I arrived, I saw that the lab had one of HP’s earliest logic analyzers, the HP 1600A, which was basically an HP portable oscilloscope with a 16-bit digital logic analyzer’s front end. This analyzer was a visually beautiful instrument, but it was so primitive that I never had use for it.

Two years later, in 1977, I was assigned an emergency project to find the root cause of a logic glitch in the soon-to-be introduced HP 9845A desktop computer. It seemed that the machine’s I/O bus was losing data when reading from an HP 9885A external floppy disk drive. A scope was useless for this kind of debugging. The glitch was so infrequent, there was no way for me to catch the glitch with any kind of scope trigger I could imagine.

Fortunately, HP’s Colorado Springs Division – which was about 100 miles south of Loveland on I-25 – had just developed the HP 1615A logic analyzer, and it had a “trigger-on-glitch” function. We were able to borrow a production prototype, and that machine found the source of the glitch in 15 minutes. The problem was the HP 9845A’s I/O backplane. It supplied two amps at 5V to four I/O cards over a 2-layer board with small power supply traces. When a specific data pattern was transferred over the I/O card’s 16-bit parallel interface to the HP 9885A, the I/O card’s internal circuitry dragged the power supply rails down just enough to corrupt the transfer. Converting the backplane to a 6-layer board with ground and power planes and adding more bypass capacitance to the board’s 5V power plane eliminated the problem, and the HP 9845A was released to production on schedule. Without the HP 1615A logic analyzer, I would have been a goat. HP subsequently announced the HP 1615A logic analyzer in early 1978. It was a huge success, for a logic analyzer.

So, yes, I am very partial to logic analyzers, and I like Dr. Bernad’s design quite a bit. Now, if you are familiar with the Raspberry Pi Pico, you know that it’s completely different from the original Raspberry Pi, which is based on an SoC that was originally used in cell phones. The Raspberry Pi Pico is based on a custom microcontroller, the RP2040, which incorporates a dual-core Arm Cortex-M0+ processor running at a maximum clock rate of 133 MHz. Given those two Arm Cortex-M0+ processors and that clock rate, there’s no way to implement a 100Msamples/sec logic analyzer with trigger logic in software on that kind of system. Instead, Dr. Bernad harnessed the power of the two PIO (programmable I/O) engines designed into the device.

Each PIO engine contains four software-controlled state machines that share a 32-entry instruction memory. The PIOs recognize just nine different instructions,and each instruction executes in one cycle. The PIO state machines can run as fast as the Raspberry Pi Pico’s system clock. Even these PIO state machines are not capable of sampling at 100 Msamples/sec with trigger conditions, but gang all eight together with some imaginative hackery, and you have a logic analyzer.

The analyzer has three trigger types: edge, fast pattern, and complex pattern. The edge trigger program requires just two instructions and runs on just one of the Raspberry Pi Pico’s eight state machines, which allows eight such triggers to run in parallel at the full 100Msps sampling rate. The complex trigger requires the use of two state machines and runs more slowly. The fast trigger overcomes the limitations of the PIO units with a “clever hack” (documented on GitHub) and can run at 100Msamples/sec across as many as five channels. Dr. Bernad has already implemented an SPI protocol analyzer for the logic analyzer and plans to implement additional protocol analyzers for I2C and RS-232, and system bus analyzers for old computers with sixteen address bits and eight 8 data bits.

Based on what Dr. Bernad has managed to do with these PIO engines in the Raspberry Pi Pico, I suspect that there’s far more that can be done with these resources. Those exciting applications are just waiting to be discovered.

Of course, a $4 logic analyzer must have limitations. Dr. Bernad’s analyzer based on the Raspberry Pi Pico is limited to 3.3V logic levels, because that’s all the RP2040 microcontroller can handle. However, the resourceful Dr. Bernad has designed a pair of boards to shift the logic levels with on-board voltage translators. One board is a carrier for the Raspberry Pi Pico, and the other board carries the level translators and is designed to plug directly into the Raspberry Pi Pico’s I/O pins.

Like any self-respecting, cheapo logic analyzer these days, Dr. Bernad’s analyzer uses a PC for its user interface. Dr. Bernad developed his own GUI for the logic analyzer, explaining that it’s easier for him to develop his own Windows-based GUI than it is to use a 3rd-party GUI framework. I get this sense that Dr. Bernad is a real individualist. We need more people like him in the industry.


For more information about Dr. Bernad’s logic analyzer based on the Raspberry Pi Pico, click here.

One thought on “$4 Logic Analyzer Based on Raspberry Pi Pico”

Leave a Reply

featured blogs
Feb 1, 2023
See how Lightelligence used our Platform Architect SoC design tool to develop a multi-die system-in-package including digital, analog, and optical components. The post Customer Spotlight: Lightelligence Optimizes Optical SoC Design with Synopsys Platform Architect appeared f...
Feb 1, 2023
With climate challenges top of mind, the International Maritime Organization (IMO) is taking an ever more active role in establishing a more sustainable global fleet. The IMO2023 regulations have entered into force since November 2022. They are set for the shipping industry t...
Jan 30, 2023
By Hossam Sarhan Work smarter, not harder. Isn't that what everyone is always telling you? Of course, it's excellent advice,… ...
Jan 19, 2023
Are you having problems adjusting your watch strap or swapping out your watch battery? If so, I am the bearer of glad tidings....

featured video

Synopsys 224G & 112G Ethernet PHY IP OIF Interop at ECOC 2022

Sponsored by Synopsys

This Featured Video shows four demonstrations of the Synopsys 224G and 112G Ethernet PHY IP long and medium reach performance, interoperating with third-party channels and SerDes.

Learn More

featured chalk talk

TE APL: Flexibility for Any Use

Sponsored by Mouser Electronics and TE Connectivity

Connectors can make a big difference when it comes to reducing system complexity and ease of use but did you know they can also help with automation and sustainability as well? In this episode of Chalk Talk, Amelia Dalton and Anita Costamagna from TE discuss TE’s APL Connectivity solutions. They dig into the details of these connector solutions and how you can get started using these connector solutions in your next design.

Click here for more information about TE Connectivity Appliance Solutions