|
| 1 | +/************************************************************************************************************* |
| 2 | +* |
| 3 | +* Title : Example DMX mode conversion and reception with 3 Universes chained |
| 4 | +* Version : v 0.3 |
| 5 | +* Last updated : 07.07.2012 |
| 6 | +* Target : Arduino mega 2560, Arduino mega 1280 |
| 7 | +* Author : Toni Merino - merino.toni at gmail.com |
| 8 | +* Web : www.deskontrol.net/blog |
| 9 | +* |
| 10 | +**************************************************************************************************************/ |
| 11 | +#include <lib_dmx.h> // comment/uncomment #define USE_UARTx in lib_dmx.h as needed |
| 12 | + |
| 13 | +// This example test 3 universes at one time with diferent DMX modes: RX-3 DMX-512 - TX-2 DMX1000K - RX-1 DMX1000K |
| 14 | +// and handle 512 input channels + 2048 output channels + 2048 input channels, asincronous data updates in main loop. |
| 15 | +// GoooOOO Arduino |
| 16 | + |
| 17 | +// *** Place a wire loop between output pin of universe 2 (Arduino pin 16 - TX2) and universe 1 input pin (Arduino pin 19 - RX1) *** |
| 18 | + |
| 19 | +// Signal from external controller, inputs at universe 3 RX, copies universe 3 input buffer to universe 2 output buffer and loops |
| 20 | +// with a wire to universe 1 input, then received data on universe 1 is write to analog output pins... |
| 21 | + |
| 22 | +// Remember: |
| 23 | +// Standard DMX-512 signal from external controller is applied to MAX 485 in universe 3 input pin (Arduino pin 15 - RX3), data received in |
| 24 | +// universe 3 INPUT buffer are copied in main loop to universe 2 OUTPUT buffer (4 times to fill 2048 channels), and transmitted |
| 25 | +// by universe 2 in DMX-1000K (2048 channels) mode, then received by universe 1 in DMX-1000K (2048 channels) mode (via the loop wire), |
| 26 | +// and received value from original input channel 512 written to PWM pins 2 to 5. |
| 27 | + |
| 28 | +// And voila, our original value from input channel 512 is now at DMX-1000K channels 512-1024-1536-2048, Enjoy ;) |
| 29 | + |
| 30 | +// Is this useful??? |
| 31 | +// Advantages are clear, DMX-1000K is 4 times faster than USITT DMX512, 4 times faster is 168 Hz refresh rate with 512 channels, |
| 32 | +// or 4 times faster is 4 times more channels in one universe at DMX standard refresh rate of 42 Hz. |
| 33 | +// Many manufacturers are producing led matrix and other led systems and controllers with unknow (for me) specification |
| 34 | +// called DMX-1000K: unoficial?, but standard de facto... |
| 35 | + |
| 36 | +// If you have any information about strange DMX modes used by led lighting, (DMX derivates like 1536 channels mode, modes |
| 37 | +// with/without break and other funny modes, not SPI) please contact me. |
| 38 | + |
| 39 | +//********************************************************************************************************* |
| 40 | +// New DMX modes *** EXPERIMENTAL *** |
| 41 | +//********************************************************************************************************* |
| 42 | +#define DMX512 (0) // (250 kbaud - 2 to 512 channels) Standard USITT DMX-512 |
| 43 | +#define DMX1024 (1) // (500 kbaud - 2 to 1024 channels) Completely non standard - TESTED ok |
| 44 | +#define DMX2048 (2) // (1000 kbaud - 2 to 2048 channels) called by manufacturers DMX1000K, DMX 4x or DMX 1M ??? |
| 45 | + |
| 46 | +#define CHANNELS (512) |
| 47 | + |
| 48 | +void setup() |
| 49 | +{ |
| 50 | + ArduinoDmx3.set_rx_address(1); // set RX 3 DMX start address |
| 51 | + ArduinoDmx3.set_rx_channels(CHANNELS); // number of RX channels universe 3 |
| 52 | + ArduinoDmx3.init_rx( DMX512 ); // starts universe 3 as RX (DMX input from external controller), DMX mode: standard USITT DMX-512 |
| 53 | + |
| 54 | + ArduinoDmx2.set_tx_address(1); // set TX 2 DMX start address |
| 55 | + ArduinoDmx2.set_tx_channels(CHANNELS * 4); // number of TX channels |
| 56 | + ArduinoDmx2.init_tx( DMX2048 ); // starts universe 2 as TX (wire loop to universe 1), DMX mode: DMX2048 (DMX1000K) |
| 57 | + |
| 58 | + ArduinoDmx1.set_rx_address(1); // set RX 1 DMX start address |
| 59 | + ArduinoDmx1.set_rx_channels(CHANNELS * 4); // number of RX channels |
| 60 | + ArduinoDmx1.init_rx( DMX2048 ); // starts universe 1 as RX (wire loop from universe 2), DMX mode: DMX2048 (DMX1000K) |
| 61 | + |
| 62 | +} //end setup() |
| 63 | + |
| 64 | +void loop() |
| 65 | +{ |
| 66 | + // copy data from RX 3 buffer to TX 2 buffer 4 times (repeat values 4 times in order to fill 2048 output channels of DMX1000K) |
| 67 | + |
| 68 | + // To channels 1-512 |
| 69 | + memcpy((void *)ArduinoDmx2.TxBuffer, (void *)ArduinoDmx3.RxBuffer, CHANNELS); |
| 70 | + // To channels 513-1024 |
| 71 | + memcpy((void *)&ArduinoDmx2.TxBuffer[512], (void *)ArduinoDmx3.RxBuffer, CHANNELS); |
| 72 | + // To channels 1025-1536 |
| 73 | + memcpy((void *)&ArduinoDmx2.TxBuffer[1024], (void *)ArduinoDmx3.RxBuffer, CHANNELS); |
| 74 | + // To channels 1537-2048 |
| 75 | + memcpy((void *)&ArduinoDmx2.TxBuffer[1536], (void *)ArduinoDmx3.RxBuffer, CHANNELS); |
| 76 | + |
| 77 | + // write values from RX 1 buffer, (dmx channel 512 only, to arduino pwm pins 2-5) |
| 78 | + analogWrite(2, ArduinoDmx1.RxBuffer[2047]); // DMX input channel 512 -> DMX1000K channel 2048 |
| 79 | + analogWrite(3, ArduinoDmx1.RxBuffer[1535]); // DMX input channel 512 -> DMX1000K channel 1536 |
| 80 | + analogWrite(4, ArduinoDmx1.RxBuffer[1023]); // DMX input channel 512 -> DMX1000K channel 1024 |
| 81 | + analogWrite(5, ArduinoDmx1.RxBuffer[511]); // DMX input channel 512 -> DMX1000K channel 512 |
| 82 | +} //end loop() |
| 83 | + |
0 commit comments