NeoPixels on Fipsy FPGA

Recently I re-discovered that I have a Fipsy FPGA Breakout Board. Back in 2018 when I received this board, I made a version of blinky with five LEDs, lighting up red-green-yellow-blue-white, one at a time. Now, I want to play with something more colorful: NeoPixels!

What is a NeoPixel?

The WS2812 Integrated Light Source, also known as NeoPixel, is a simple, scalable, and affordable full-color LED. Neopixels are commonly found on Adafruit-branded development boards such as the MagTag. They are also available standalone in a zillion form factors. The unit I have is Keyes 18-LED ring WS2812 module that contains a string of 18 WS2812 pixels.

Keyes 18-LED ring WS2812 module

Each WS2812 is a surface-mount package that integrates RGB LEDs alongside a driver chip, forming a complete control of a pixel point. The WS2812 is controlled through a single wire, in which "0" and "1" bits are encoded in the timing of high and low voltage states. During a data refresh cycle, a WS2812 chip accepts 24 bits of data for its green, red, and blue color components, and then forwards any subsequent bits to the next WS2812 chip. This forwarding feature enables cascading: when a string of pixels receives a sequence of 24-bit words, the initial 24 bits go to the first pixel, the next 24 bits go to the second pixel, and so on. Theoritically, you could control a zillion pixels through a single wire.

Four-key Piano on Fipsy FPGA

The newest addition to yoursunny.com's toy vault is Fipsy FPGA Breakout Board, a tiny circuit board offering a piece of Lattice MachXO2-256 field-programmable gate array (FPGA). After porting an SPI programmer to ESP32, it's time to write some Verilog! Blinky is boring, but I did it anyway. Then, I'm moving on to better stuff: a piano.

The piano is an acoustic music instrument played using a keyboard. When a key is pressed, a hammer strikes a string, causing it to resonate and produce sound at a certain frequency. A normal piano has 88 keys, and each key has a well-defined sound frequency. My "piano", built on Fipsy, has four keys, and uses a passive buzzer to produce sound.

Fipsy FPGA connected to a buzzer and a keypad

Play Tone on Passive Buzzer with FPGA

A passive buzzer plays a tone controlled by an oscillating electronic signal at the desired frequency. In Arduino, the tone() function generates a square wave of a specified frequency, which can be used to control a passive buzzer.

Program Fipsy FPGA Breakout Board from ESP32

MocoMakers is creating Fipsy FPGA Breakout Board, a tiny circuit board offering a piece of Field-programmable gate array (FPGA). I worked with FPGA years ago in class projects, but didn't have access to a device after that. I backed the project, and received two Fipsy boards on Jul 20.

Fipsy is a very simple board: there is no power regulator or USB port. The official method to program the Fipsy is through the SPI port on a Raspberry Pi. It is easy to setup, and is a good use case for my Raspberry Pi Zero W (paid link), but there is one problem: It is good practice to power off the circuit when modifying hardware wiring. However, powering off a Raspberry Pi cleanly requires sending a shutdown command and waiting for a few seconds. If I just pull the power cord, I would risk corrupting the filesystem.

ESP32 microcontroller has SPI ports, and can be powered off and restarted very quickly. Can I program Fipsy from an ESP32?

Fipsy connected to Heltec WiFi\_Kit\_32

Hardware side is easy. ESP32 has two available SPI ports, HSPI and VSPI, and I connected Fipsy to the Heltec WiFi_Kit_32 (paid link)'s HSPI port. All that remains is deciphering the spaghetti code of the official programmer. After a day of hard work, I got it working:

EDA实验课程设计——电梯控制器

这是本人2007年4月的作品。根据上海交通大学闵行校区电信学院大楼内的电梯工作仿制。

  • AHDL语言编写,使用带有FLEX®EPF10K20TC144-4芯片的JDEE-10K实验箱
  • 4层楼的电梯控制
  • 轿箱按钮、层站召唤按钮,按钮带有指示灯
  • 用LED表示马达运转方向
  • 点阵显示当前楼层
  • 点阵开关门模拟动画
  • 支持背景音乐,乐曲为“欢乐颂”

下载源代码 实验报告

模拟的输入输出部件 输入输出部件