Home Arduino projects Arduino four universes DMX 512 library
formats

Arduino four universes DMX 512 library

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:

Schematic Arduino shield four DMX 512 universes.

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.

Known issues:
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.

ArduinoDmxN.set_rx_address (DMX_RX_ADDRESS);

Calling this function assign the DMX INPUT start address for this universe, can be any value between 1 and 510 (2046)*.

ArduinoDmxN.set_tx_address (DMX_TX_ADDRESS);

Calling this function assign the DMX OUT start address for this universe, can be any value between 1 and 510 (2046)*.

ArduinoDmxN.set_rx_channels (NUMBER_OF_CHANNELS);

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)*.

ArduinoDmxN.set_tx_channels (NUMBER_OF_CHANNELS);

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:

ArduinoDmxN.attachTXInterrupt (my_TX_ISR_name);

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)

ArduinoDmxN.attachRXInterrupt (my_RX_ISR_name);

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.

Toni Merino

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
32 Comments  comments 

32 Responses

  1. Arnaud

    Hello,

    Firstly I want to thank you for this very simple and very complete library.

    However, I encounter a little problem, I injected “Dmx_Receive” sample program in my duemilanove arduino 328 and tested as such.

    I notice that channel 1 is all or nothing, 0-127: State 0 and 128-255: 1 state.
    It is the same for channel 3. But Channel 2 and 4 PWM function perfectly.

    Do you have any idea about my problem?

    Thank you in advance, sincerely yours,

    Arnaud

    • Toni Merino

      Hi.
      I have no idea what resources or libraries make unusable some Arduino analog outputs, you can use Arduino mega for a few outputs, or consider to use a TLC5940 (16 PWM outputs each IC)
      If you need help to get working TLC5940, please let me know.
      Regards.

  2. Petar Chan

    Hi, Toni
    I have a problem with code I was downloading source code “Small Arduino DMX controller” and error: (‘ArduinoDmx0′ was not declared in this scope)what type I must declared it?

  3. Bernd

    Hallo,

    at 1st: Thank you very much for your library – it working very fine!

    I only have a problem, when i add “Serial.begin(9600);” for debugging into my source. When i add this function i get this Error-Message:

    Compiling ‘dmx_test’ for ‘Arduino Mega 2560 or Mega ADK’
    core.a(HardwareSerial.cpp.o)* : : In function `__vector_36′:
    HardwareSerial.cpp : multiple definition of `__vector_36′
    lib_dmx.cpp.o : :C:\Arduino\arduino-1.0.4\libraries\Dmx\lib_dmx.cpp:205: first defined here
    ld.exe : : Disabling relaxation: it will not work with multiple definitions
    Error creating .elf

    Can i use your library in combination with Serial.xy ?

    Thank you very much and greatings from Germany

    • Toni Merino

      Hi.
      I am not sure if modifying the file harwdareserial.cpp can work, if not, you can use software serial.
      Regards.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">