After searching the web for Arduino DMX libraries, and test, we find no library allowing the use of multiple DMX universes and that did not use the timers of the arduino, so finally decided to create it.
*** UPDATED 07/07/2012 ***
Download current version: Arduino four universes dmx library version 0.3
The wiring diagram you can find it at:
Version 0.3 CHANGES
– Not needed anymore to disable and enable interrupts during configuration.
– Not needed anymore to modify the Arduino IDE file HarwareSerial.cpp.
– Experimental support for non-standard DMX modes, faster and with more channels per universe:
- DMX512 (250 kbaud – 2 to 512 channels) Standard USITT DMX-512 1990
- DMX1024 (500 kbaud – 2 to 1024 channels) Completely non standard – TESTED ok
- DMX2048 (1000 kbaud – 2 to 2048 channels) called by Manufacturers DMX1000K ?
– Removed leds tx – rx for speedup, if required shall be implemented in the program
– Interrupts on frame transmitted and frame received by each universe, user callback functions.
When we compile get the error: ‘ArduinoDmxN’ was not Declared In This scope:
Check if you have configured the correct type of board in the Arduino IDE, menu tools > board
(with Arduino nano can only use one USART = ArduinoDmx0 = USART0)
Errors while programing Arduino:
Will be necessary to remove the DMX shield, and put it back once programmed.
Flicker when controlling LEDs:
If we are dealing with LED lights, flicker may appear due to a refresh rate too low, we use fewer channels per universe (eg 200 instead of 512, to increase the frequency) and / or use less universes. This is a well known problem that affects all consoles and controllers that send all 512 channels, even when the maximum DMX refresh rate (around 44 Hz) is used.
Note about the refresh time:
The Arduino Mega and Arduino Nano use a microcontroller Atmel AVR 8-bit at 16 Mhz, which imposes a limitation of resources.
For example, 4 buffers in DMX1000K mode at 2048 channels each, will consume ALL the memory on an Arduino Mega 2560, so it must be clear what we are doing.
We should note that in practice we will probably not use all universes with all channels if we keep up the refresh rate of the DMX inputs and outputs.
Instructions for library setup – version 0.3:
Copy deskontrol library folder “Dmx” to arduino-XX.XX/libraries/
Instructions for library use:
There are four objects already created called “ArduinoDmx0”, “ArduinoDmx1”, “ArduinoDmx2”, “ArduinoDmx3”, each of these objects using a USART of the Arduino Mega, with Arduino nano can only use “ArduinoDmx0” because there is only one USART.
When compiling your programs, in order to economy Arduino resources, should comment in the “lib_dmx.h” lines with “# define USE_UARTN” of USARTs not going to use (only Arduino Mega).
The library usage is very easy, the functions that you have to use are:
ArduinoDmxN.set_control_pin (PIN_NUMBER); // if not used -1
A call to this function we assign the pin number to be used to control the MAX485 driver, if it works as a universe of input or output. (Arduino pin that connects to pins 2 and 3 of the MAX485), can be any Arduino digital output pin.
Calling this function assign the DMX INPUT start address for this universe, can be any value between 1 and 510 (2046)*.
Calling this function assign the DMX OUT start address for this universe, can be any value between 1 and 510 (2046)*.
A call to this function we assign the number of channels of DMX INPUT for this universe, can be any value between 2 and 512 (2048)*.
A call to this function we assign the number of DMX OUT channels for this universe, can be any value between 2 and 512 (2048)*.
If you want to use sincronous mode:
A call to this function we assign the name of the user callback function that is activated each time that finish sending a DMX frame in a DMX universe. (avoid loss of time in the main program loop)
A call to this function we assign the name of the user callback function that is activated each time that finish receiving a DMX frame in a DMX universe. (avoid loss of time in the main program loop)
To begin transmitting or receiving a DMX universe (currently not possible simultaneously in the same universe), use one of the following functions:
ArduinoDmxN.init_rx (DMX_MODE); // *** new parameter DMX_MODE ***
A call to this function (once called the above functions) starts this universe to DMX RECEIVE.
ArduinoDmxN.init_tx (DMX_MODE); // *** new parameter DMX_MODE ***
A call to this function (once called the above functions) starts this universe to DMX TRANSMIT.
To write DMX output values: ArduinoDmxN.TxBuffer [CHANNEL – 1] = Data;
To read DMX input values: Data = ArduinoDmxN.RxBuffer [CHANNEL – 1]; // channel is 0 indexed
* This library does not use any Arduino timer, remaining free for other uses.
Thus we can use up to four universes simultaneously, each functioning as an input or output DMX.
In the examples of the library have as:
– Receive one DMX universe.
– Mix 2 DMX inputs (2 universes) in one, with patched channels. 200 + 200 input channels, output 400 channels.
– Mix 2 DMX inputs (2 universes) in one, with higher value priority (HTP)
– Use interrupts to send or receive in synchronous mode.
– Use non-standard fast DMX modes.
* 2048 channels with DMX1000K – 512 with DMX512
Download OLD version: Arduino four DMX 512 universes library version 0.1
Application example: Dimmerino – Inexpensive modular dimmer for Arduino.
Any suggestions or improvements are welcome.