All Projects → jostlowe → Pico-DMX

jostlowe / Pico-DMX

Licence: BSD-3-Clause license
A library for inputting and outputting the DMX512-A lighting control protocol from a Raspberry Pi Pico

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to Pico-DMX

buzzer music
RPI Pico / Micropython library to play music through one or more buzzers, can automatically replace chords with fast arpeggios to simulate polyphony with a single buzzer. Music can be easily taken from onlinesequencer.net
Stars: ✭ 23 (-61.02%)
Mutual labels:  raspberry-pi-pico, rpi-pico
rp2040js
A Raspberry Pi Pico Emulator in JavaScript
Stars: ✭ 178 (+201.69%)
Mutual labels:  raspberry-pi-pico
ArtNode
Art-Net library for Arduino, Teensy, etc.
Stars: ✭ 27 (-54.24%)
Mutual labels:  dmx
pico-emu
a little hobby raspberry pi pico emulator
Stars: ✭ 27 (-54.24%)
Mutual labels:  raspberry-pi-pico
sparklemotion
Sparkle Motion
Stars: ✭ 24 (-59.32%)
Mutual labels:  dmx
picoLCD
Example code for interfacing with a LCD with a Raspberry Pi Pico
Stars: ✭ 25 (-57.63%)
Mutual labels:  raspberry-pi-pico
BlenderDMX
Blender addon to design and render DMX lighting.
Stars: ✭ 67 (+13.56%)
Mutual labels:  dmx
OpenDeck
Software and hardware platform for simpler building of MIDI controllers with support for DMX.
Stars: ✭ 438 (+642.37%)
Mutual labels:  dmx
dmxnet
ArtNet-DMX-sender and receiver for nodejs
Stars: ✭ 43 (-27.12%)
Mutual labels:  dmx
ledcat
Control lots of LED's over lots of protocols
Stars: ✭ 89 (+50.85%)
Mutual labels:  dmx
WiFiNINA Generic
Enables WiFiNINA network connection (local and Internet) for SAM DUE, SAMD21, SAMD51, Teensy, AVR Mega, STM32, RP2040-based boards, etc. in addition to Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000, Arduino UNO WiFi Rev.2 , Nano 33 IoT, Nano_RP2040_Connect. Now with fix of severe limitation to permit sending much larger data than total 4K
Stars: ✭ 32 (-45.76%)
Mutual labels:  rpi-pico
ja-rule
Ja Rule is the code behind OLE, an Open Source DMX/RDM framework for PIC32 microcontrollers
Stars: ✭ 36 (-38.98%)
Mutual labels:  dmx
ESPAsyncE131
Asynchronous E1.31 (sACN) library for Arduino ESP8266 and ESP32
Stars: ✭ 97 (+64.41%)
Mutual labels:  dmx
DMXOPL
YMF262-enhanced FM patch set for Doom and source ports.
Stars: ✭ 42 (-28.81%)
Mutual labels:  dmx
zeptoforth
A not-so-small Forth for Cortex-M
Stars: ✭ 70 (+18.64%)
Mutual labels:  raspberry-pi-pico
dmx usb module
Linux kernel module for Enttec Open DMX dongle
Stars: ✭ 36 (-38.98%)
Mutual labels:  dmx
pico-ssd1306
Simple library for using ssd1306 displays with the Raspberry Pi Pico and the pico-sdk.
Stars: ✭ 57 (-3.39%)
Mutual labels:  raspberry-pi-pico
TeensyDMX
A full-featured DMX library for Teensy 3, Teensy LC, and Teensy 4. "Programmable DMX and arbitrary USB serial device emulation."
Stars: ✭ 82 (+38.98%)
Mutual labels:  dmx
MDNS Generic
mDNS Library for nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, AVR Mega, RP2040-based boards, etc. using Ethernet W5x00. Supports mDNS (Registering Services) and DNS-SD (Service Discovery). Ethernet_Generic library is used as default for W5x00
Stars: ✭ 22 (-62.71%)
Mutual labels:  rpi-pico
prk firmware
A keyboard firmware platform in PicoRuby
Stars: ✭ 337 (+471.19%)
Mutual labels:  raspberry-pi-pico

Pico-DMX

example branch parameter

A library for outputting and inputting the DMX512-A lighting control protocol from a RaspberryPi Pico

About

The RaspberryPi Pico provides an exciting new addition to the market on low-cost easy-to-use microcontroller board. The Pico has plenty of features making it particularly interesting for lighting control hackers:

  • Lighting control software can potentially become quite large. A large chunk of flash is required to run networked protocols such as Art-Net and sACN (ANSI e1.31). The Pico has a whopping 2MB of flash at disposal, which leaves plenty of room for your networked DMX software.
  • Storing DMX universes requires a lot of RAM (>512B for each full DMX frame). With other microcontrollers, RAM is a scarce resource and manipulating DMX universes can quickly consume the entire RAM of the microcontroller. The Pico has a solid 264kB of RAM, leaving plenty of room for dmx frame manipulation.
  • Libraries for sending DMX on other microcontrollers tend to rely on either bit-banging a GPIO or a hack on a hardware UART to allow the UART to assert a sufficiently long BREAK and MAB at the beginning of each transfer. Bit-banging consumes a processor core for the duration of a transfer and is extremely sensitive to interrupts. Using a hardware UART is less computationally intensive, but most low-cost microcontrollers only have 1 or 2 hardware UARTs, limiting the number of parallel universes one can transmit or receive. The Programmable IO (PIO) modules of the Pico gives the possibility to create what is basically hardware support for custom IO protocols (such as DMX). The Pico features 2 PIO modules with 4 State Machines each, making it possible to input or output up to 8 universes in parallel. Thats more universes than you can shake a proverbial stick at.
  • As if the PIO wasn't impressive enough, the Pico has a powerful 10 channel DMA controller. In conjunction with the PIO, the DMA makes it possible to input or output entire DMX universes with only a handful of instructions.
  • The Pico has a rather odd combination of 2 ARM Cortex M0+ cores running at speeds up to 133MHz. The dual core architecture could provide a huge benefit in processing DMX universes as computationally demanding data processing can be offloaded on the second core.

This library implements a DMX input and DMX output for the RPi Pico, leveraging its powerful DMA and PIO features.

Installation

The Pico-DMX library should be available in both the Arduino libraries and the PlatformIO libraries. Pico-DMX can also be used in pico-sdk-based projects.

The Pico-DMX library can also be manually added to any project in the same way as any other Arduino library. See the Arduino guide for more information.

Usage

The library is based around the DmxOutput and DmxInput classes, representing a single DMX output or input.

Outputting DMX

The DmxOutput class is simply instantiated, and requires no further arguments.

   DmxOutput myDmxOutput;

After instantiation, the DMX output must be assigned to a pin. The .begin(uint pin) method initializes the DMX output and binds it to a pin. To start a DMX output on GPIO1 on the Pico, call

   myDmxOutput.begin(1);

The library defaults to using pio0 as the underlying PIO instance. If you want to use pio1 as the underlying PIO, add the PIO you want to use as an argument

   myDmxOutput.begin(1, pio1);

Even though the DMX output is initialized and ready to party, the output is still idle, waiting for a universe to transmit. A universe is simply an array of uint8_t, with a maximum length of 513. The zero'th value in the array is the packet start code and should be set to 0 for ordinary DMX data packets. Let's make a universe with 3 channels (plus the start code), and set channel 1 to full.

   uint universe_length;
   uint8_t universe[universe_length + 1]; 
   universe[1] = 255;

To send the universe, call the .write(...) method to send the universe wooshing down your DMX line.

   myDmxOutput.write(universe, universe_length + 1);

The .write(...) method is not blocking, and executes immediately. To check the status of your DMX transmission, you can call .busy()to check if the DMX output is done transmitting your universe.

   while(myDmxOutput.busy()) {
        // Patiently wait, or do other computing stuff
   }

See the examples for complete examples on how to use the DMX output

Inputting DMX

The library also enables DMX inputs through the DmxInput class. The DMX input can either read an entire universe or just a couple specified channels. Let's say the Pico controls a simple RGB LED, and we want to read the first three channels on the DMX universe to control our RGB LED. First, instantiate your DMX input, specifying what pin you want to use (GPIO 0 in our case), what channel you want to read from (channel 1), and how many channels you want to read (3 channels in total)

   DmxInput myDmxInput;
   uint dmx_pin = 0;
   uint start_channel = 1;
   uint num_channels = 3;
   myDmxInput.begin(dmx_pin, start_channels, num_channels);

The DMX Input is now ready to receive your DMX data. Before we start receiving DMX data, we want to create a buffer where we can keep our received DMX channels:

   uint8_t buffer[num_channels]; 

Use the .read(...) method to read the 3 channels for our RGB fixture into our buffer.

   myDmxInput.read(buffer);

The .read(...) method blocks until it receives a valid DMX packet. Much like the DmxOutput, the zero'th channel in the DMX packet is the start code. You should always check that the start code is the one defined for DMX (zero) to ensure you have a valid DMX packet, unless you are messing around with other protocols such as RDM, in which case check it is their valid start codes.

As an alternative to the blocking .read(...) method, you can also start asynchronous buffer updates via the .read_async(...) method. This way, the buffer is automatically updated when DMX data comes in. Optionally, you can also pass a pointer to a callback-function that will be called everytime a new DMX frame has been received, processed and has been written to the buffer. This callback-function will be called with one parameter which is the instance that has received the new data. This way, you can use one callback-function to react on data from multiple universes. See this example below:

   void __isr dmxDataRecevied(DmxInput* instance) {
     // A DMX frame has been received :-)
     // Toggle some LED, depending on which pin the data arrived
     uint ledPin = instance->pin() + 8;
     digitalWrite(ledPin, !digitalRead(ledPin));
   }

   myDmxInput.read_async(buffer, dmxDataRecevied);

A note on DMX interfaces sending "partial universes" (= fewer channels)

There are multiple universes that can be configured to send less than 512 channels per frame. Some interfaces do this automatically without an option to configure this feature.

The reason why this is done is that if not all channels of a universe are in use, one can send a "shorter" frame but send this frame more often per second (= increase the refresh rate). The specification of DMX512 allows this.

The problem arises if start_channel + num_channels is larger than the number of channels sent by the interface since the code of DmxInput waits for this specific amount of channels until the callback is being triggered. So if the amount of channels arriving at the input, the callback will be triggered at a later point in time, not at the end of a DMX frame.

Voltage Transceivers

The Pico itself cannot be directly hooked up to your DMX line, as DMX operates on RS485 logic levels, which do not match the voltage levels of the GPIO pins on the Pico.

Fortunately TLL to RS485 transceivers are easily available. Simple transceiver modules can be bought through online retailers for only a couple of dollars. These tend to use the MAX485 series of voltage level transceivers, which work great for most purposes. If you're planning to implement DMX on an industrial level, your device should have some kind of EMC protection. Many RS485 transceivers are available that have galvanic isolation between the TLL side and the RS485 side. These should be the preferred option.

Modifying .pio files

Unfortunately, the mbed-based Arduino core has no native support for compiling .pio files yet. However, we can compile them manually using pioasm. The result is a header file that can be included into the arduino sources.

Manual compilation requires cloning the pico sdk, compiling the pioasm tool, and running it like so: pioasm src/DmxInput.pio src/DmxInput.pio.h

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].