DIY Pixel Lab
I'm going to assume that we already have some media that we want to play on our little LED Matrix.
Let's begin by setting up Resolume by creating a custom Advanced Output setup for our pixel map. The first thing we need to do is create a custom fixture for our LED Matrix Screen. Resolume let's you create any variation of layouts using its Fixture Editor.
Inside Resolume, click on Application, and select Fixture Editor:
The Fixture editor is split into 3 panes:
A list of all your Fixtures, you can add and remove them at will, rename them etc
This pane allows you to set parameters for the fixture you are editing. Things like what kind of channels it will have, the width and height of your fixture, its direction, colour space etc
A visual and numerical representation of the fixture we create
Our 14 x 14 pixel matrix has a total 196 pixels. If you remember from earlier how many channels a single DMX Universe has, you will note that we can not fit this matrix into 1 DMX universe. We can only fit 170 pixels worth of RGB data into 512 bytes!
So we have to create 2 fixtures that split the panel into 2 sections. For simplicity, we are going to create 2 fixture that are the left and right parts of the matrix. We will then use these fixture in 2 universes. The driver device will be tasked with compiling the DMX data from both universes and appropriately rendering it to the LEDs. Don't worry, we will cover this later.
Above is the physical layout of all the pixels on our 14x14 matrix.
We will create 2 fixtures called "14x14_LEFT" and "14x14 _Right". Note they will differ only in the "distribution" attribute.
Clicking on the "+" button in the Fixtures panel, creates a new fixture for us. Scroll down to it on the left pane and double click on it to rename it. I have named it "14x14_LEFT"
Lets go over the Fixture Parameters for this fixture.
Width & Height
This allows us to set the width and height of the fixture. We will set this one to 7 pixels wide by 14 pixels tall.
The color space attribute tells Resolume how to organise each pixel's color data and in what order the colors appear. Our pixels have RGB leds inside BUT, and this is a big BUT, the actual order the LEDs translate the data sent to them can vary from pixel models.
For simplicity I will be using RGB and filtering the actual layout of data in the Driver Device later on. Note that you could also drive pixels that are RBGW (white) or just White. There are a tons of different configurations to choose from.
We can leave this as is at 2.5
Probably the most important attribute, this tells Resolume the physical placement of each pixel. Our panel is oriented so that the 1st pixel is at the bottom left corner, data then flows up, turns RIGHT to the next row, DOWN, then RIGHT then UP etc as indicated by the icon we have selected.
Now create a second fixture, you can do it quickly by RIGHT CLICKING on the current fixture "14x14_LEFT" and selecting DUPLICATE. Then rename it to "14x14_RIGHT"
This fixture's parameters are the same, BUT we need to change the Distribution as this part of the panel starts at the top!
Now that we have our custom Fixtures set up, click Close to save them!
The next step is to insert them into the Advanced Output system of Resolume, adjust the virtual mapping and position over your actual media.
Back in the main window of Resolume, click on the Output Menu and select Advanced
Click on the PRESETS menu at the top LEFT and click on NEW to get the same blank layout. Note the colour gradient I have in the screenshot is the media I have selected. Its a simple shader called "Gradient" that is included within Resolume.
Next we need to Add a new "DMX Lumiverse". Resolume treats a Lumiverse as 1 DMX Universe with a unique DMX Universe ID and Subnet ID. Each Lumiverse can have a maximum of 512 channels, just like a regular DMX Universe. Click on the big "+" icon on the top left and select "DMX Lumiverse"
Next we need to remove the "Screen 1" section from the layout. We are setting up a DMX output only system and don't need anything other outputs for this demo. Click on "Screen 1" and click on the "X" to remove it from the layout. You will be left with "Lumiverse 1".
Duplicate this Lumiverse by Right Clicking on it and selecting Duplicate. Now we must make sure we have the correct fixtures in each Lumiverse. By Default, when you create a new Lumiverse it adds whatever fixture you were last working with. So if it's not the correct one, click on it on the left panel and select the correct one form the drop down on the bottom right.
Our advanced output layout will have 2 lumiverses. Lumiverse 1 will have "14x14_LEFT" and Lumiverse 2 will have "14x14_RIGHT"
In the Center panel you can click on any fixture and move it around to position it onto the screen in any way you like. The screencap above has the 2 fixtures split so you can see what I'm doing. We need to do 2 things. Push them together and resize them to scale.
Let's talk about scale. As you can see above, the fixtures are inserted as equal squares. But these specific fixtures are more rectangular as they are 7px wide and 14px tall. Lets click on the Left Fixture and adjust it using the Width and Height attributes on the right panel.
For ease and visibility we will say that 1 LED pixels is equal to 50PX on the screen of your computer. So that the left fixture will have a width of 7x50=350px and a height of 14x50=700px
We set the same atributes for the right fixture and then push them together.
We have created a virtual Pixel Map for our panel. Now save your layout. Click on the PRESETS drop down at the top left and select SAVE AS. Name it "14 x 14 Panel".
Back to universe IDS, we now need to assign each fixture to their appropriate universe so that the driver device can work out what universe is meant to be rendered into what part of the panel.
Click on "Lumiverse 1" and on the left hand side you will see Subnet and Universe. We will leave these at 0:0. Now Click on "Lumiverse 2" and set it to be at Subnet 0: Universe 1.
Resolume will send out 2 blocks of data each time a single frame is rendered from its output. Block 1 will have all the data for Lumiverse 1 and block 2 will have all the data for Lumiverse 2. Your driver device will then receive these 2 blocks and will be able to identify what block of data needs to be copied into what side of the matrix.
The DIY Pixel Driver
In this section we will be build a device that will allow you to received Art-Net data via WiFi and push it to our 14x14 LED Matrix.
I have prepared a simple bit of code that has all the elements necessary to do this. If you are heading down the path of doing this work from scratch, its imperative you understand most of this code as its designed to be modular and expandable to very large installations.
We will be working with the following pieces of hardware and software. Ill try and provide links to the exact devices I'm using if you want to follow along at home. The guide is written for a Windows PC. The assumption here is that your pc is connected to a wireless or wired network and that you have a WIFI network to connect the ESP32 (read on later for network layout). You will need the Wifi SSD and Key. Your PC needs to be able to speak to the wifi network freely.
- ESP-32S Dev Board using the ESP32 Micro Controller
- USB to MicroUSB cable for programming
- A small breadboard
- A Voltage Level Shifter to raise the ESP32s logic level from 3.3v to the SK9822 5V. I Use the SN74HCT245
- 14px x 14px SK9822 Addressable LED Matrix. This will come with a 4 pin data cable and a 2 pin power cable
- 240V Mains 5V 300W Switching Power Supply. You will need an GPO male plug cable to connect mains power and a short cable to connect 5V rails
- Small Jumper cables
- Arduino IDE from Arduino.cc
- ESP32 Arduino Development Libraries from the Espressif GitHub
- Source code for this project from my GitHub
Installing the Arduino IDE and setting up the ESP32 API
Download the Arduino IDE from arduino.cc install it as per usual then do the following in this exact order:
- Go to the Espressif GitHub for the ESP32 Arduino API
- Top right, click on "Clone or Download" and select Download ZIP save this to your desktop
- Go to your local computers Documents folder and locate the Arduino folder "C:\Users\USERNAME\Documents\Arduino"
- Create a folder called "Hardware" if its not already there
- Inside the "Hardware" create a folder called "espressif"
- Inside this folder Extract the contents of the ZIP file from step 2 then rename the extracted folder to "esp32"
- Go into the "esp32\tools" folder and locate the executable "get.exe" double click on it and wait for the command prompt to disappear. This will download the latest API from Espressif servers and may take 5-10 minutes depending on your internet connection. Once the command prompt disappears you can proceed to the next step
- Open the Arduino IDE. Click on the Tools menu, select Board and scroll down. If you installed everything correctly above, you will see a whole bunch of ESP32 boards like this
Next download the project source code from my GitHub, save the folder to your desktop, and open the project file "ESP32ArtNetDriver.ino". Click on the Tools Menu and select Boards. Then find the "Node32S" board and select that.
Connect the ESP32 to your PC via the USB cable, wait for the drivers to install. Then in the Arduino IDE, slick on tools, PORT and select the port the EPS32 is connected to. You are now ready to compile and upload the code to the micro controller, but do read on as there are things we need to change.
On lines 22 and 23:
const char * ssid = "ArtNet";
const char * password = "megapixels";
Change the SSID and Password to whatever your wifi network name is (the SSID) and the password to whatever your wifi password is. Once done click on the UPLOAD button, wait a few seconds for the code to compile and then upload to the ESP32. At this point your DevBoard is ready to rock! Let's hook up all the hardware!
Notes on Networking for this lab
To get the best performance for this hardware set up, its best to hook up the computer running Resolume to your network via a wired network port. You can definitely stream Art-Net via WIFI from Resolume but you WILL notice a lag and a lot of packet loss due to the nature of the UDP protocol. Here is an example of our preferred network set up for this lab:
I will be using a relatively cheap consumer grade WIFI Enabled Router made by TP-LINK. But you can use any router you like, as long as you have DHCP enabled
Grab all your hardware and set it up as above.
We are using the SN74HCT245 for level shifting. The DATA and CLOCK lines on the SK9822 pixels assume a logic level of 5V, where 0v = 0 and 5v = 1. The ESP32 has logic levels of 3.3V, where 0v = 0 and 3.3v = 1!
Once hooked up, power on your power supply and get ready to see... Nothing!
Enabling Output in Resolume
At this stage, even if you had Resolume open you wont see anything on the panel because we are not outputting any data from Resolume yet!
Open Resolume and go to the Advanced Output. For this demo we are going to be using the "Broadcast" method to send data to the ESP32. Broadcasting UDP packets comes with a lot of challenges, especially over WiFi, so for anything you work on in the future, try not to use this method unless you have a small controlled lab set up.
Click on "Lumiverse 1" and on the "TargetIP" attribute on the right select "Broadcast", do the same for "Lumiverse 2" you should will see your output appear on your matrix display!