ofxDmx

i just posted a new addon to github

https://github.com/kylemcdonald/ofxDmx

it’s a cross-platform interface to the enttec dmx usb pro.

it builds on previous work from erik sjodin and mark bereza.

i refactored and cleaned the code so it matches some other patterns better and uses less c-style allocation.

it only does output atm, but because DMX is a fairly simple protocol it should be straightforward to adapt to input as well.

i also extracted the packet construction into the update() method so other kinds of packets can be constructed for different devices.

Hi,

That looks a right and clear ofx.
I will try and tell you, but do you think there’s hope with EnttecOpenDmx (under win7 of course :slight_smile: ) ?

Sebastien

your OS shouldn’t matter, because it’s just using OF directly.

it might work with EnttecOpenDmx. do you have the data sheet describing the message/packet format?

I’ve a first solution working wich uses the classic packet format :
one byte = one channel + the first byte set to 0 (512 channels gives 513 bytes)

wow, nice – if that packet works, then you can just swap out a chunk of code. update() should become:

  
  
void ofxDmx::update() {  
	unsigned int n = levels.size();  
	unsigned int packetSize = 1 + n;  
	vector<unsigned char> packet(packetSize);  
	  
	// header  
	packet[0] = 0;  
	  
	// levels  
	copy(levels.begin(), levels.end(), packet.begin() + 1);  
	  
	serial.writeBytes(&packet[0], packetSize);  
}  
  

want to try swapping that out and see if it works?

of course, I will try.
I would enjoy to work with so simple ofx, more than with my hackish way using ftd2xx.dll.

Hi,

It’s not a succeed on my side :confused:
Serial iniated correctly, but DMX open usb does not drive the lights…

no crashes, no messages indicating something wrong, no messages indicating something right…
the packet looks good in the watches windows…

Maybe that packet is not so available but that kind of packet works in my version with ftd2xx.dll
Maybe the parameters of the serial port…

the serial baud might be slower – try switching the number 57600 in both ofxDmx::setup() methods to 25600

Hi, I´m trying to use ofxDmx with Visual Studio 2010 and i get the following error.
Please, anybody knows why it´s happened?

Creating library bin\moviePlayerExample_debug.lib and object bin\moviePlayerExample_debug.exp
1>LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of other libs; use /NODEFAULTLIB:library
1>main.obj : error LNK2019: unresolved external symbol “public: __thiscall ofxDmx::ofxDmx(void)” (??0ofxDmx@@QAE@XZ) referenced in function “public: __thiscall testApp::testApp(void)” (??0testApp@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol “public: __thiscall ofxDmx::~ofxDmx(void)” (??1ofxDmx@@QAE@XZ) referenced in function “public: virtual __thiscall testApp::~testApp(void)” (??1testApp@@UAE@XZ)
1>testApp.obj : error LNK2019: unresolved external symbol “public: bool __thiscall ofxDmx::connect(class std::basic_string<char,struct std::char_traits,class std::allocator >,unsigned int)” (?connect@ofxDmx@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z) referenced in function “public: virtual void __thiscall testApp::setup(void)” (?setup@testApp@@UAEXXZ)
1>testApp.obj : error LNK2019: unresolved external symbol “public: void __thiscall ofxDmx::update(bool)” (?update@ofxDmx@@QAEX_N@Z) referenced in function “public: virtual void __thiscall testApp::draw(void)” (?draw@testApp@@UAEXXZ)
1>testApp.obj : error LNK2019: unresolved external symbol “public: void __thiscall ofxDmx::setLevel(unsigned int,unsigned char)” (?setLevel@ofxDmx@@QAEXIE@Z) referenced in function “public: virtual void __thiscall testApp::draw(void)” (?draw@testApp@@UAEXXZ)
1>bin\moviePlayerExample_debug.exe : fatal error LNK1120: 5 unresolved externals

tioWashie, those are errors from the linker, which complains it can’t find any of the things the example refers to. that makes me think you forgot to add ofxDmx to your project. can you post a screenshot of your project’s file structure?

Hi,
You are right! I forgot to include the cpp and h in my project.
Now it’s working. Thank you for that information.

I get a new problem: the name of my device to initialize it dmx.connect(“xxxx”).
I tried to use the number 0. My app answered with this error:
OF_LOG_ERROR: ofSerial: could not find device 0 - only 0 devices found

And when I Tried send a byte (dmx.setLevel / dmx.update() ) get another error:
OF_LOG_ERROR: ofSerial: Can’t write to com port

I have no experience with of in windows, any idea how I can initialize this device?

Thanks in advanced.

Hi, again,
Solved that another bug.

Used dmx.connect(“COM3”);
And all the errors in preview msg gone away.

Now I’m in the same problem of Dudley.

The DMX device not answer to of commands.

I’m using this code:

  
  
#include "testApp.h"  
  
//--------------------------------------------------------------  
void testApp::setup(){  
  
        ...  
  
	printf("Connecting COM3\n");  
	dmx.connect("COM3");  
        ...  
}  
  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
...  
  
	if (fingerMovie.getCurrentFrame()== 500 ) {  
		printf("Changing gobo at frame 500\n");  
		dmx.setLevel(1, 43);  
		dmx.setLevel(2, 174);  
		dmx.setLevel(3, 0);  
		dmx.setLevel(4, 255);  
		dmx.setLevel(5, 255);  
		dmx.setLevel(6, 0);  
		dmx.setLevel(7, 0);  
		dmx.setLevel(8, 77);  
		dmx.update();  
	}  
  
	if (fingerMovie.getCurrentFrame()== 2000 ) {  
		printf("Changing gobo at frame 2000\n");  
		dmx.setLevel(1, 43);  
		dmx.setLevel(2, 174);  
		dmx.setLevel(3, 0);  
		dmx.setLevel(4, 255);  
		dmx.setLevel(5, 255);  
		dmx.setLevel(6, 0);  
		dmx.setLevel(7, 0);  
		dmx.setLevel(8, 35);  
		dmx.update();  
	}  
  
  
  ...  
  
}  
  
  

Any idea what’s happening, please?

Thanks again

because the addon is so simple, i can only suggest changing the baud rate.

or, try unplugging and re-plugging the dmx controller. this was a problem for me once.

are you using the enttec dmx usb pro or another device?

Hi,

Indeed the Open DMX is more boring than others and can not use all ofAddons previously posted.

I finally derivate the exemple from enttec website
http://www.enttec.com/index.php?main-menu=Products&pn=70303&show=downloads
, and can post my solution.

The code will be rough, and commented in french :slight_smile:

Cheers
seb

Hi Seb,

You might want to also have a look at some code I wrapped a while ago:
http://forum.openframeworks.cc/t/ofxusbdmx512-addon-for-dmx/3938/0

I think it should support the open DMX

And Kyle, this time around I’ve got hold of the Enttec device…got your addon up and running on Linux in no time. Thanks!!

Thanks for the great addon, Kyle! I’ve got this working with the Enttec USB Pro hooked up to a 3-channel RGB controller hooked up to an LED strip.

I don’t know much about DMX, but I’m curious to know if I can use this setup to control the LEDs in the strip independently. Are 3-channels enough to do this? I did a bit of Googling, and it looks like PWM might be the way to go to achieve this, is this something I can do with ofxDmx and my hardware setup?

Thanks,
-Elie

Depends on what controller you’re using.

Typically if you interface an RGB LED strip directly using say, an Arduino, then you will need to drive them using PWM and something like an N-channel Mosfet.

I imagine there might be some kind of DMX manipulated RBG controller out there for LED strips, but I’m not sure.

Hey Pierre,
Thanks for your reply. I’ll look into our controller and see what the specs are. From what I’ve read so far online, it seems like the Arduino is one of the most used controllers out there… at least for the scale I’m working at.

Here’s a link to N-channel Mosfet usage with Arduino:
http://www.freetronics.com/products/n-mosfet-driver-output-module
http://bildr.org/2012/03/rfp30n06le-arduino/

Basically you would connect one mosfet to each of the R, G, and B lines. Then drive them from the Arduino PWM outputs - see the default LED fading example, that’s basically PWM already done for you.

Or, you could order LED strips from this guy - he’s written his own Arduino library to interface with them:
www.bliptronics.com