Bitluni's Magnetic LED Matrix Build Showcases Clever RISC-V Programming

This project snaps together 12-bit color depth from 8x8 LED matrices at 98 frames per second, with time to spare.

James Lewis
1 month agoDisplays

YouTuber bitluni's latest incredible build video uses a RISC-V microcontroller with an uncommon driving technique to create a modular magnetic LED matrix.

The LED matrix is an off-the-shelf 8x8 module. Bitluni designed a custom PCB to connect to the matrix. It contains a WCH-IC CH32V208 RISC-V microcontroller and multiple eight-channel drivers for the LED matrix. A 3D-printed enclosure creates a complete module. Bitluni glued magnets into the edges of the enclosure so they could snap together. Pogo-pin connectors (pins on one module, pads on the other) pass power and communication.

Bitluni is no stranger to the WCH-IC CH32V RISC-V microcontroller series. In a past project, he created a 256-core RISC-V supercluster. While the WCH CH32V208 in this project does have wireless capability, bitluni chose this one because of the high number of GPIO pins available. Driving the matrix on a single module directly would require 32 IO pins since there are eight rows and eight columns with three pins for RGB colors. (So, eight rows by 32 columns.) However, bitluni is not driving the matrix directly.

The matrix rows use an integrated high-side driver with eight channels, and the columns use three eight-channel low-side drivers to cover the 24 I/O required for eight RGB LEDs. With this setup, the display could achieve up to 400,000 frames per second (FPS) with one-bit or 133K FPS with two-bit color depth using a traditional pulse-width modulation (PWM) technique. However, this approach means the CPU drives the GPIOs 100% of the time, leaving no spare cycles for anything fun.

Bitluni's final implementation is what he calls "divide and conquer" but is also known as binary code modulation (BCM). BCM is similar to PWM. However, BCM relies on interrupts to provide the delays between bit changes. The weight of the binary values determines the time between interrupts, and the number of interrupts is related to the bit-width. For example, to achieve an eight-bit color depth, there would be eight interrupts. During each interrupt, an interrupt service routine (ISR) pulls the current bit's position from a rotating buffer to update the LED. (Nigel Batten has an excellent tutorial on BCM.)

This combination results in a high-fidelity display (12 bits of color depth) with a frame rate (98 FPS) that appears very smooth to the human eye. Once bitluni had the LEDs working, he created the 3D-printed frame that allowed them to align magnetically and the pogo pins/pads to mate.

Unfortunately, some issues could prevent bitluni from producing the LED Matrix Magnet as a product or kit. First, the pogo-pin connections sometimes fail to make good contact. Also, a design issue with the high-side drivers requires some dead-bug rework. But, it turns out, those drivers have a less-than-ideal response rate, resulting in some display quirks. So, a new version of the custom PCB is more than just fixing the pin mapping issue.

Developing a high fidelity LED Magnet Matrix (📷: bitluni)

Check out the video above for an explanation of the circuit and a demo. Of course, being bitluni, the demo involves a Rickroll — similar to when he integrated an animated GIF into an ASIC. You can download the CH32 code from the MagnetMatrix GitHub repository.

James Lewis
Electronics enthusiast, Bald Engineer, and freelance content creator. AddOhms on YouTube. KN6FGY.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles