DMX Receiver

Most (if not all) DMX receivers are based on a microcontroller design. The most common controller is the AVR (as used in the Arduino, and other designs), although other microcontroller (e.g., the PIC). These microcontrollers provide a set of I/O pins many can directly drive equipment> It si common for the microcontroller to support a UART on the chip, which minimises the need for external components.

Example DMX Receiver Software Architecture.

A typical basic software design for a DMX receiver contains 5 basic functions:

The state machine described above can be implemented in an algorithm below provides a flow chart for the Input Function. It receive a DMX break, and the the slots in a DMX Frame to create a set of DMX values (stored in the shared byte array DMXField[]). Execution is triggered as an Interrupt Service Routine (ISR), for each byte (or status change) received from the UART.

The following states are noted:

gDMXState is a global variable used by the Input Function. This is used to store the current receiver DMX state.
DMXcount is a variable that is set by the User Interface Function to the base address used by the receiver.
DMXcount is also later re-used to count the received number of bytes within the DMXField.
DMXField indicates the number of bytes that the device needs to collect from the DMX Frame.

This algorithm cycles through 6 internal states to process each DMX Frame:

State Machine for an example DMX Receiver.

Waiting of the DMX Frame to receive the 1sts slot at the configured base address: A receiver skips the number of slots after the Start Code, corresponding to the configured base address. (e.g. for a base address of 8 the receiver skips the first 7 slots). After finding the base address, the receiver extracts a set of contiguous slots (bytes) from the DMX Frame.

Receiving multiple slots to represent values larger than one byte.

The Output Function can be designed to use a number of consecutive slots to realise a 16-bit, 24-bit, 32-bit or other size of value that can be used by the output function. However, care needs to be taken that this data is read consistently by the Output Function, to avoid issues when the values change in later DMX Frames and are updated by the Input Function. Consider a 2 byte value, where the Output Function reads the first byte from the shared receive array (part of an already recieved DMX Frame), and the Input Function then updates the value of the second value (from the current DMX Frame). This would result in an inconsistent value when the two bytes are combined (becaiuse it combines one value from one DMX Frame with a value from a later DMX Frame). A solution is to use semaphore signals between the Input Function and the Output Function to coordinate access to the shared array.


See also:


Prof. Gorry Fairhurst, School of Engineering, University of Aberdeen, Scotland. 2023