I use DMX512 quite a bit. One of my controllers has no master fader facility. I would like to add this capability and wonder if an Arduino could do this.
As you probably know DMX512 can control up to 512 different addresses each having from 0 to 255 states per channel. Each frame is re-transmitted about 44 times per second. this means that the effective clock rate is 250Khz. Each pulse is thus about 4 micro-seconds.
The balanced RS485 signal I need to adapt leaves the existing controller and would enter the device I wish to build. Each of the 512 addresses need to be examined at every frame and depending on the percentage output selected, ideally this would also have 256 states, and each frame would have its HEX number changed downward as needed.
Do you think that such a stand-alone device could be made to work using an Arduino? In essence this device has an RS485 input and output, a potentiometer as a dimmer and that's it. Of course any of the 512 channels can and will change in any subsequent frame so an implicit delay of at least one frame is unavoidable.
Yes this should work with an Arduino Mega (multiple hardware serial ports).
I have a simple test rig I built using a Mega with a DMX library that supports multiple universes. I use it to check Swisson DMX distribution boxes by sending 512 channels of data, reading them back through the distribution box and comparing to the sent signals.
You want to read from a desk, apply master mixing and then re-transmit.
DMX library used can be found here and I have attached the schematic for the shield I built though you can probably find several different design's on the net.
Thank you. I like your hardware design. 120 ohm terminators and opto-couplers. Way to go. I will build one this weekend.
Do you please have a sketch that I can test with? I have the feeling that the code will be a struggle for me. I just need something to get me started and to make sure the hardware is working. I'll take it forward from there.
I have tweaked the schematic as it did not show resistors on the RGB LED's, just download from #1 again to get latest. Also the DC-DC converter part number is IL0505S (sheet attached).
The library comes with several examples that should get you going but I will hopefully get a chance to knock the basics of what you need up tomorrow.
I have used IL0505S before. For a tiny amount of "floating" power they are great.
Once I get this thing working with just a single pot I would later add a Blackout button and LED, Fade-Out and Fade-In buttons and a pot to adjust the Fade-In / Fade-Out time from about 0.5 seconds up to 30 seconds.
Many older consoles lack a master fader and this little project may come in handy for others. I am really only talking about fading PAR cans across all DMX channels but there is no reason why a group of channels (say 200 - 300) could not be excepted from the fade so as to allow scanners and moving heads to keep running provided they inhabit that address range. Heck I could even put a 2 x 16 LCD screen on and make it somewhat selectable.
The code to support a master fader seems pretty straightforward, maybe I have missed something crucial as the code is untested.
There are several potential problems/improvements that can be addressed.
I only had a trimming pot to hand instead of a slider to simulate the master fader so it tends to sit at a pretty stable resistance compared to normal pots/slider. The slider value might need averaging/smoothing to give stable results.
The code just runs forever reading the RX universe and applying the master fader to the TX universe. It might be better to use the dmx library callback so you only apply the fader changes after a full set of channels have arrived/sent.
Another thing you could do is make a crashbox. We sometimes used them on shows to store lighting sets so if the desk died the crashbox could be used to do basic lighting until the desk reboots.
#include <lib_dmx.h> // include DMX library
#define DMX512 (0) // (250 kbaud - 2 to 512 channels) Standard USITT DMX-512
#define dmxCount 512 // Number of RX/TX channels
#define faderPin A0 // Fader input
void setup() {
pinMode(13,OUTPUT); // Turn off the internal LED
digitalWrite(13,LOW);
// Configure DMX Universes
ArduinoDmx1.set_tx_address(1); // set tx1 start address
ArduinoDmx1.set_tx_channels(dmxCount);
ArduinoDmx1.init_tx(DMX512); // starts universe 1 as tx, standard DMX 512
ArduinoDmx2.set_rx_address(1); // set rx2 start address
ArduinoDmx2.set_rx_channels(dmxCount);
ArduinoDmx2.init_rx(DMX512); // starts universe 2 as rx, standard DMX 512
}
void loop() {
float fader = constrain(analogRead(faderPin),0,1000); // Read fader and constrain the range to simplify maths
fader = fader / 1000; // Divide by 1000 so result is between 0 & 1
// Read from DMX RX buffer, apply master fader % and send to TX buffer
for (int x = 0; x < dmxCount; x++){
ArduinoDmx1.TxBuffer[x] = ArduinoDmx2.RxBuffer[x] * fader;
}
digitalWrite(13, !digitalRead(13)); // Flip LED state (*to fast to see without some sort of delay)
}
Wow. That code does look straightforward. Even I am able to make sense of most of it. I will not be able to build the device this weekend. Da wife has made other plans so, that's that. No matter it will nonetheless involve beer so all is not lost.
Thank you very much for helping me out and taking the trouble to do this. It is much appreciated.
The intended use for this is on an old hardware theatre board that (I think) has 32 fixtures, mostly PAR64s.
I did think of a crash function to just give me some light. A good idea. The trouble is, these things tend to run away with you and before you know it, you are building a a new surface.
I will build a mega to your design very soon and will get back to you. Thank you again.
I am sorry for the delay in replying. Stuff keeps happening in my life that get in the way of this little project.
I have built the hardware and it works. I tested it by running the Blink programme that comes on all Arduinos and blinks the D13 output. I connected this to the input of the opto-coupler and put a couple of back to back leds across the RS485 output of the MAX485 chip. That way I can see the DMS flickering. I did the same on the DMX input. Then I connected RS485 out to RS485 in and connected an led to the output of the receive opto-couplet. All leds flash in sync. I guess the hardware part works. I have built this as a shield so it plugs into the Arduino Mega 2560.
My problem comes with the software. It won't compile. I get these errors
Arduino: 1.6.6 (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Users\Pete\Desktop\DMX_MasterFader\DMX_MasterFader.ino:1:0:
C:\Program Files (x86)\Arduino\libraries\lib_dmx/lib_dmx.h:29:20: warning: ISO C99 requires whitespace after the macro name [enabled by default]
#define __INC_DMX_H#include <avr/io.h>
^
C:\Users\Pete\Desktop\DMX_MasterFader\DMX_MasterFader.ino: In function 'void setup()':
DMX_MasterFader:12: error: 'ArduinoDmx1' was not declared in this scope
ArduinoDmx1.set_tx_address(DMX1); // set tx1 start address
^
DMX_MasterFader:12: error: 'DMX1' was not declared in this scope
ArduinoDmx1.set_tx_address(DMX1); // set tx1 start address
^
DMX_MasterFader:16: error: 'ArduinoDmx2' was not declared in this scope
ArduinoDmx2.set_rx_address(1); // set rx2 start address
^
C:\Users\Pete\Desktop\DMX_MasterFader\DMX_MasterFader.ino: In function 'void loop()':
DMX_MasterFader:27: error: 'ArduinoDmx1' was not declared in this scope
ArduinoDmx1.TxBuffer[x] = (uint8_t)(((long)ArduinoDmx2.RxBuffer[x] * fader) / fader_max);
^
DMX_MasterFader:27: error: 'ArduinoDmx2' was not declared in this scope
ArduinoDmx1.TxBuffer[x] = (uint8_t)(((long)ArduinoDmx2.RxBuffer[x] * fader) / fader_max);
^
exit status 1
'ArduinoDmx1' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
I also see this error in the code at compile time
I believe the problem is in the version of lib_dmx.h that I have. Perhaps you can post your version which may work better.
Thanks for that. I have now corrected it. However I am still seeing the following errors on 1.6.6 of the IDE.
I will download and install IDE v1.0.6 and see if that helps.
Thanks again.
Arduino: 1.6.6 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Pete\Desktop\DMX_MasterFader\DMX_MasterFader.ino: In function 'void setup()':
DMX_MasterFader:12: error: 'ArduinoDmx1' was not declared in this scope
ArduinoDmx1.set_tx_address(DMX1); // set tx1 start address
^
DMX_MasterFader:12: error: 'DMX1' was not declared in this scope
ArduinoDmx1.set_tx_address(DMX1); // set tx1 start address
^
DMX_MasterFader:16: error: 'ArduinoDmx2' was not declared in this scope
ArduinoDmx2.set_rx_address(1); // set rx2 start address
^
C:\Users\Pete\Desktop\DMX_MasterFader\DMX_MasterFader.ino: In function 'void loop()':
DMX_MasterFader:27: error: 'ArduinoDmx1' was not declared in this scope
ArduinoDmx1.TxBuffer[x] = (uint8_t)(((long)ArduinoDmx2.RxBuffer[x] * fader) / fader_max);
^
DMX_MasterFader:27: error: 'ArduinoDmx2' was not declared in this scope
ArduinoDmx1.TxBuffer[x] = (uint8_t)(((long)ArduinoDmx2.RxBuffer[x] * fader) / fader_max);
^
exit status 1
'ArduinoDmx1' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
I installed IDE 1.0.6 and I now get less error lines. Now it looks like this.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
DMX_MasterFader.ino: In function 'void setup()':
DMX_MasterFader:12: error: 'ArduinoDmx1' was not declared in this scope
DMX_MasterFader:12: error: 'DMX1' was not declared in this scope
DMX_MasterFader:16: error: 'ArduinoDmx2' was not declared in this scope
DMX_MasterFader.ino: In function 'void loop()':
DMX_MasterFader:27: error: 'ArduinoDmx1' was not declared in this scope
DMX_MasterFader:27: error: 'ArduinoDmx2' was not declared in this scope
I am stumped. ArduinoDMX1 and 2 are defined and are in lib_dmx.h
rederikus:
after the defines fixed that. I will now try and upload it to my Mega 2560.
Thanks for your help.
You seem to have found/fixed the errors before I even go t a chance to log in again.
If your still having problems then attach/post your code and I can try compiling it this end.
I was a bit lucky and I followed your suggestions and I am pretty tenacious. Finally, I really want this to work.
Now I shall move forward to what I want to do with this in the first place. Trouble is, I reckon Christmas being upon us will slow the whole thing down.
Thank you very much for your invaluable help. It is much appreciated.