DMX Receiver

Most (all?) DMX receivers are based on a microcontroller platform. Two common controllers are the AVR (e.g. Arduino, or other design), and the PIC. These microcontrollers provide many I/O pins that can directly drive equipment, can support a UART and minimise the need for external components.

Example DMX Receiver Software Architecture.

A typical software design comprises 5 basic functions:

The algorithm below provides the input processing for reception of a DMX frame to create a set of DMX values, stored in the shared byte array DMXField[]. The algorithm is triggered as an Interrupt Service Routine (ISR), for each byte received from a UART.

gDMXState is a global variable used to retain the current receiver DMX state.
DMXcount is initially set to the base address used by the receiver.
DMXcount is later used to count the received number of bytes within DMXField.
DMXField represents 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 base address: A receiver skips a number of bytes 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 addres, the receiver extracts a set of contiguous bytes (slots) from the DMX frame.

Watchdog Timer

The watchdog is a special-purpose timer often found in microncontrollers. It is started in the initialisation code and periodically reset in the user interface routine. Once enabled, the watchdog can not be reset by the computer software.

If the timer ever counts to zero (too much time expires since the last reset), the program is assumed to have crashed. The microcontroller automatically reinitialises the hardware and call the initialisation routine.

Receiving multiple slots to represent values larger than one byte.

A receiver 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, to avoid issues when the sender changes the values between frames. Consider a 2 byte value, where the output function reads the first byte from the shared receive array (from an already recieved frame), and the receiver updates the value of the second slot (from the current frame). This would result in an inconsistent value when it is combined with the first slot from a previous frame. A solution is to use semaphore signals between the two functions to coordinate access to the shared array.


See also:


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