ENTTEC Open DMX USB - Got it working in Max

Matthew McCabe's icon

Hi everyone,

I bought an ENTTEC Open DMX USB device, and as many have posted, it doesn't work with the Max "serial" object -- if I'm correct (and please correct me if I'm wrong) - it's because the Open DMX device isn't buffered, it relies on the host computer to follow the DMX packet timing standards, etc. and the "serial" object in Max doesn't have the capability of doing this. It also errors out when you try to open the baud rate at the correct DMX setting of 250,000bps - so maybe that has something to do with it too.

Anyway, there is a spiffy npm package written by moritzruth on github - https://github.com/moritzruth/node-enttec-open-dmx-usb

This will work in Max in node.script though it's a little weird - I'm not the best programmer in the world but if you make a file with this code I came up with, it appears to work fine.
There is one little bug in the enttec-open-dmx-usb npm package - the timing is set to "0" on line 126. This would cause my test light to flash whatever color I was sending it and then go black. Changing the timing to 33ms (figuring for 30fps?) it works.

// enttec-wrap.js for use in the node.script object in Max
const Max = require('max-api');
const Enttec = require('enttec-open-dmx-usb');
const myUniverse = new Array(512);
myUniverse.fill(0);

let device;

// set up everything and zero out the DMX universe
(async () => {
  device = new Enttec.EnttecOpenDMXUSBDevice(await Enttec.EnttecOpenDMXUSBDevice.getFirstAvailableDevice())
  device.setChannels(myUniverse);
})();  // not sure if this is the right way to do this, with ES modules?  async JS hurts my brain
  
Max.addHandler("list", (arg1, arg2) => {
  myUniverse[arg1 - 1] = arg2; // the enttec npm module is off by one (DMX ch 1 is position 0 in the buffer)
  device.setChannels(myUniverse);
});
  
Max.addHandler("dump", () => {
  myUniverse.unshift('universe');  // temporarily add the word "universe" to the front of the array so it can be routed back in max
  Max.outlet(...myUniverse);
  myUniverse.shift();
});
  
Max.addHandler("blackout", () => {
  myUniverse.fill(0);
  device.setChannels(myUniverse);
});
    

    
change this line in enttec-open-dmx-usb/dist/index.js if it doesn't work out of the box

Matthew McCabe's icon

Just a quick follow-up - the timing of the underlying node.js code is definitely incorrect. I came out tonight to real stage with 15 lighting instruments and it was very buggy. I'll continue to work on it and post here when I find out more.

QLC works perfectly though, so it's possible. Just more hackery to do on it :)

GustavoRhomas's icon

Hi Matthew,

I'm having the same issue - really interested to hear if you've had any progress with this. Thanks for posting initially!

Matthew McCabe's icon

Hey Gustavo - glad you found it -- I actually haven't worked on it for a few months. It looks like the author of the underlying node.js package made an update in May that might address the timing issues -

I think the better solution would be to use a buffered USB to DMX dongle - I have one that works fine with the Max "serial" object... the price of the open DMX is attractive though.

Alexander Candid's icon

Hi Matthew,

I'm super new to Max and any type of coding is way out of my league. Could you share a basic patch and instruction on what files go where to get me started? I'm trying to decide if investing in DMX is even worth it, but solutions that would reliably work with Max are too expensive, so I'm stuck with an Enttec ripoff for now.