Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

Rgco's Ultra-Cheap Arbitrary Waveform Generator Packs a Raspberry Pi Pico to Outperform Lab Gear

Based on an older Arduino project, this waveform generator shows just how powerful the $4 Raspberry Pi Pico can be.

Pseudonymous maker "rgco" has released a guide for turning a $4 Raspberry Pi Pico microcontroller into an arbitrary waveform generator β€” building on an earlier Arduino-powered project and upping the performance by a massive three-hundredfold.

"As a test I wanted to see if any of my previous projects based on the Arduino Uno/Nano could benefit from a remake with this much more powerful board," rgco writes of his experiments with the Raspberry Pi Pico, launched earlier this year as the first device built around the RP2040 microcontroller. "After all, it has 4x the bus width, 8x the clock frequency, 130x the RAM, and is more than a decade more modern."

A port of an old Arduino project reveals how powerful the Raspberry Pi Pico can be for certain workloads. (πŸ“Ή: rgco)

"My choice fell on the Arbitrary waveform generator (AWG). With the Arduino, I managed to squeeze out 381ksps, since every sample update took 42 instruction cycles, mostly because updating a 32-bit phase counter takes a quadruple loop with an 8-bit CPU. My expectation was that it should be possible to improve this by a factor 8 just from clock speed and maybe another factor 2 because the new board is 32-bit."

"However, after reading selected parts of the 637-page datasheet of the new RP2040 chip, I realised it might be possible to update every single clock cycle! Just by initialising 2 peripherals, the DMA (Direct Memory Access) and the PIO (programmable Input/Output), an array can be cyclically streamed to the output pins."

The resulting Raspberry Pi Pico version of the project is considerably faster than the Arduino original - 300 times faster, in fact, boosting performance from 381 kilosamples per second (ksps) to 125 megasamples per second (Msps), or up to 250Msps with overclocking. "That is similar to serious lab-AWGs," rgco notes, "which cost ~100EUR [around $119] for budget models."

The project is written in MicroPython running on the Raspberry Pi Pico, but should be portable to any other RP2040-based board. To get around the lack of an analog output on the RP2040, rgco built a resistor ladder to act as a digital to analog converter (DAC) β€” the only additional piece of hardware required to get the project up and running."

A full guide, including the source code, is available on Instructables.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles