Skip to main content

PyDMX

Introduction

PyDMX is a package capable of sending DMX512 data via a driver. It was created to allow demonstrations on open days of DMX-based projects created at the University of York Department of Computer Science (UoY CS).

The project consists of a core package and a series of optional driver packages for particular hardware and devices.

DMX512 Protocol

 Idle |       Break       |MAB|  Slot 0  |  Slot 1  |
------\                   /---\        /-\ /--------\
      |                   |   |        | | |        |
      |                   |   |        | | |        |
      \-------------------/   \--------/ \-/        \--- - - -  -  -  -

Diagram of the start of a DMX packet.

DMX512 (or commonly just DMX) is a relatively simple protocol. The DMX bus is in an Idle high state between packets. A packet starts with a break of 100 μs, followed by a Mark After Break (MAB) of 12 μs, this signifies the start of the frame and the start of the "slots".

 S 0 1 2 3 4 5 6 7 E E
\ /-\   /---\      /--
| | |   |   |      |
| | |   |   |      |
\-/ \---/   \------/

Diagram of a slot with value 0b10011000 or 152.

Each slot consists of 1 low start bit, 8 data bits, and 2 high stop bits. Each bit of a slot is 4 μs long. This corresponds to a baudrate of 250000 or 250 kbit/s (though due to breaks this is not entirely accurate). There are 512 usable slots (channels) per frame and 513 slots overall. Slot 0 is special as it signifies the type of frame being sent. 0x00 is the normal frame type and corresponds to "standard" lighting data.

A frame can contain any number of slots (beyond the type slot) up to the limit of 513 slots (including type slot). Typically the 512 usable slots are referred to as channels.

The idle period between packets must be at least 92 μs and the MAB must be at least 12 μs. Further a packet must not be longer than 1 second. There are no other requirements on timing, even on inter-slot breaks.

A light will typically take an "address" which is the channel index (starting at 1) which it will listen on. Some lights will use this as a start address and listen on some number of channels above it also if they require more than 8 bits of data.

For example a light might be set to address eight, but listen on channels 8 9, and 10. It could then use each channel as a component of an RGB colour value.

Importantly for writing software relating to DMX, the standard does not specify how to encode different types of data in slots. Therefore, each light manufacturer, or even light, does it differently. There is nothing stopping a manufacturer allowing you to select noncontiguous addresses for each 8 bit value, or any number of more convoluted solutions.

Core

The core of PyDMX has the following classes:

  • DMXUniverse: represents a DMX universe
  • DMXInterface: allows simple control of a DMX driver
  • DMXLight: abstract base for lights
    • DMXLight3Slot: represents a 3 slot RGB light
    • DMXLight7Slot: represents a 7 slot RGB moving light
  • DMXDriver: represents a DMX output driver
    • Drivers are subclasses of this class
  • Colour: represents a 24-bit RGB colour value

Dependencies

The core modules do not depend on any other python modules or external dependencies.

Drivers

FTDI

This project is not affiliated with FTDI.

This driver package can be found at PyDMX-Drivers-FTDI.

Arduino

This project is not affiliated with Arduino.

This driver package can be found at PyDMX-Drivers-Arduino.

Built-in Drivers

Debug

The debug interface is designed to output to the terminal the data that would be sent to a interface hardware/drivers. It is also capable of estimating the refresh rate of signals being sent out, though this is effected by platform due to the massively slow terminal output of Windows compared to other platforms.

Dummy

The dummy interface does nothing. It's there simply as a placeholder for testing or any other use which does not require an actual interface.

Usage

Below is a basic example of sending an update to turn a light purple:

from dmx import Colour, DMXInterface, DMXLight3Slot, DMXUniverse

PURPLE = Colour(255, 0, 255)

# Open an interface
with DMXInterface("FT232R") as interface:
    # Create a universe
    universe = DMXUniverse()

    # Define a light
    light = DMXLight3Slot(address=8)

    # Add the light to a universe
    universe.add_light(light)

    # Update the interface's frame to be the universe's current state
    interface.set_frame(universe.serialise())

    # Send an update to the DMX network
    interface.send_update()

    # Set light to purple
    light.set_colour(PURPLE)

    # Update the interface's frame to be the universe's current state
    interface.set_frame(universe.serialise())

    # Send an update to the DMX network
    interface.send_update()

To run the above example you would need to install the core package PyDMX and the FTDI driver package PyDMX-Drivers-FTDI.

A further example program is available in the examples/simple.py file in the repository root.

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for more details.

Release files for PyDMX 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyDMX 0.1.0
File Size Uploaded
PyDMX-0.1.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyDMX 0.1.0
File Interpreter ABI Platform
PyDMX-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / PyDMX-0.1.0.tar.gz

Download URL PyDMX-0.1.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e8f2798fd033475a7e322f77799ddb75ffd65c473a833911a7a0d2f6cf3b48d1
BLAKE2b-256 checksum
How to use checksums
3191c4ba961dd21b69b0f691c1d48dc6c051b5718af6adc55bab9d4ebf313676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.9

Release files / PyDMX-0.1.0-py3-none-any.whl

Download URL PyDMX-0.1.0-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcdcf51766f0a8c821204b7528110052a013f80a641ba4b7c49d91759c5e2ba5
BLAKE2b-256 checksum
How to use checksums
e19acee964f1e7a5d3b41c08fd5a0c1c20e5a24fba1135caf0d3ea6ac2fe51ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page