# Using an RS 232 to 485 converter box for DMX program



## domls (Sep 22, 2008)

Hello to all, first post here!

I am writing a DMX software program to control lighting gear from my laptop at live sound gigs. I'm a very experienced RS 232 programmer (VB.NET VS 2005), so I bought an RS 232 to RS 485 Converter box from B&B electronics. I've wired up my own DMX connector from the box...

I also have the entire ESTA National Standard USITT DMX 512-A book with all the DMX specs. I know that (from pages 19 & 20 of the book), the timing is critical. I know I can set up the serial comm (232 side) so that the port is opened with, say 9600 baud, 8 data bits, 2 stop bits, no parity and RTS handshaking. This should do the trick, since I'm using the 485 converter box.

What I am not sure about is sending the right characters. Let's say I want to send the "SPACE FOR BREAK" followed by the "MARK AFTER BREAK" and then the NULL (START CODE) followed by the Channels 1->4 data only.

If I want Channel 1 data to be 3C (hex), Channels 2->3 to be 00 (hex), and Channel 4 to be FF (hex), I would normally think that I just have to send the following bytes for the complete loop: 00 FF 00 3C 00 00 FF. But this doesn't seem to be working right. When the specs talk about setting the line high or low, how does that relate to the characters that I'm sending? What is the converter box doing in terms of the incoming data, and do I need to shift the data I'm sending with regards to the least significant bit/most significant bit (LSB/MSB).

Thanks to all!

domls


----------



## icewolf08 (Sep 22, 2008)

DMX controlled devices are looking for all 512 values for the universe. Each device counts the bits that go by and act on the ones that apply to them. So, if you are only sending out data for channels 1-4 you will confuse the gear. You need to transmit 1-512 all the time, even if the values are 00.


----------



## rmarston (Sep 22, 2008)

Try this link: DMX512 PAGE FROM Ujjal...details of DMX512 !!


----------



## domls (Sep 22, 2008)

OK, no problem creating the sending of all 513 bytes of data (START + 512).

rmarston: Thanks for the link. I checked it out briefly and, like many (or most) other web sites with DMX info, it really gives very detailed information about hardware, timing, etc... But it seems that nobody ever talks about the actual sending of of the bytes of data? In other words, when they say HI and LO, what characters are being sent? How does it relate between RS 232 and RS 485???

I've got the serial port write on a timer. I've set the timer to send data every 250ms (I can set to any value, if needed). Here's my write code. Does anybody have any write code that they KNOW actually works?

Private Sub tmrWrite_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrWrite.Tick
Dim b() As Byte
Dim s(0) As Byte
Dim m(0) As Byte
Dim timeout As New System.TimeSpan(100000) '100 microseconds = 100,000 ns
Dim timeout2 As New System.TimeSpan(12000) '12 microseconds = 12,000 ns

Erase b
ReDim b(512)
s(0) = 158 '9E

SP1.Write(s, 0, 1)
System.Threading.Thread.Sleep(timeout)

m(0) = 223 'DF
SP1.Write(m, 0, 1)
System.Threading.Thread.Sleep(timeout2)

b(0) = 0
b(1) = 60
b(2) = 0
b(3) = 0
b(4) = 255

With SP1
.Write(b, 0, 513)
End With
End Sub

Note that I had captured data from my Behringer controller into Hyperterminal and the "9E" and "DF" hex values are from the capture...just guessing that these might be the LO and HI values.

Thanks!!!

domls


----------



## fredthe (Sep 22, 2008)

The LO and HI refer to the signal level for each bit of data... so sending 0x00 will be all low for 8 bits, 0xFF will be all high for 8 bits, and 0x55 will alternalte high and low. (I may have the high/low backwards, I don't have the specs in front of me...)

RS-232 vs. RS-485... They are two different electrical specs for serial data. Converting from one to the other will give you different signal levels (RS-232 is referenced to ground, RS-485 is a differential signal). Note in terms of data rate, bytes, etc, what you put in is the same as what you get out, only the levels have changed.

Are you running at the correct bit rate? You mentioned 9600... I believe that DMX requires 250,000 BPS.


----------



## domls (Sep 22, 2008)

Thanks, fredthe,

I'm not sure that the B&B 232 to 485 converter box handles 250,000 bps, or that there is a 1 to 1 correlation between bps in 232 and 485. I'll have to look at the specs of the box, and see what it says. It might have a limit of 115200 on the 232 side. Baud rate in RS 232 is x number of bits per second, so that if you send a character such as FF, you usually have 10 bits per byte (but in this case, you have 2 stop bits, making for 11 bits per byte).

I guess my biggest question concerns the conversion of data in the box between 232 and 485. In other words, if a byte of FF into the 232 end of the box is converted, what is it converted to, or is the box smart enough to know HOW to convert the FF into an 8 bit high signal automatically (where all 8 bits are set to HI)?

Any ideas?

Thanks!

domls


----------



## domls (Sep 22, 2008)

Allow me to give a real-world example. I have a "COLORpalette" from Chauvet which can be set up to be a 6, 9, 15, or 27 channel DMX LED light. The first channel determines the function. If I set the first channel with a value of between 060 and 079 (decimal), then it is set to 6 Channel mode. The second and third channels are Auto mode speed and Strobe (which I usually don't use, so these are 0).

The 4th channel is Red 1, 5th Channel is Green 1, and 6th is Blue 1 (assuming that I've set Channel 1 to 6 Channel mode, as above). So, by sending a value of 255 for Channel 4, 255 for 5, and 255 for 6, I get all LED's on at full blast, thus giving a White light overall. If Channel 4 is 255, 5 is 0, and 6 is 0, then, obviously I will get a Red light overall.

What is unnerving for me is that the Behringer (and many other) hardware mixing-style dimmer boxes give values on the sliders from 0 to 100 instead of 0 to 255, when all the specs for modern LED devices give detailed channel values ranging from 0 to 255! This makes it incredibly difficult to set Channel 1 to a range of 60 to 79 (which is the range for 6 channel mode), and thus my want for a software program to control the lighting instead. What else is crazy is that there are only 12 main faders (with two banks=24), so heck, in theory, the Behringer controller can only handle the ONE LIGHT (if set to 27 channel mode).

Thanks!

domls


----------



## soundman (Sep 22, 2008)

This sounds like an interesting project but if you are looking for something that is done for you try this ENTTEC - Lighting Control,RDM,DMX USB PRO it will run with chamsys magic Q so you can use the color mixer and effect engine.


----------



## fredthe (Sep 22, 2008)

For the (any) 232 to 485 converter, it's only a signal level conversion.... in terms of bit rate, etc, what you put in is what you get out. Since DMX is 250,000 bps, your RS-232 port would need to be set to the same, which it probably can't. 

Looking at your code snippet, your reference to HI and LOW seem to be in relation to sending the BREAK and MAB parts of the DMX signal. Unfortunatly, these are Constant levels, not something that can be programmed as a byte to be sent out by a UART, since the byte will always be sent with start and stop bits, but the requirement is to keep the output at a single level, with no transitions, for a specified period of time. Unless you have a port that can be directly programmed to output a Constant low or high level, you're out of luck using a serial port. (This functionality may exist, but may or may not be easily accessable.... I haven't looked at low-level UART programming in 15+ years )

Oh, and don't get me started on "Baud" rate... unless you're dealing with a modulated signal, you really mean bit rate. (Yes, I know the documentation probably says baud, but it's still not correct usage.)


----------



## fredthe (Sep 22, 2008)

To convert from an attribute value (scaled by 255,) to the board value (scaled by 100) just multiply by 0.392


----------



## domls (Sep 23, 2008)

OK, thanks.

Perhaps I should start at the beginning, then. There certainly are software controllers on the market today (like MyDMX from American DJ). It appears that it comes with a "box" to convert the signal (I would imagine) from RS 232 to DMX. So, first question, what is the box actually doing, and second, if they (and others) can do it, then how is it being done with respect to writing the software for Windows PC's?

On another note, I know I could multiply the value by 0.392 (100/255) to get the "percentage" to use on the controller's fader, but really, this is unreasonable at a live sound gig (low light...good luck moving the fader to between 23.52 and 30.968 _exactly_)! This represents 060 to 079 per the Chauvet documentation, and the fader only has numbers at 0, 50, and 100!!! That's just one of the reasons why I want to write this program!

IMHO, hardware controllers were probably great back in the day of just having a bunch of par cans with color gels, but now with the LED lights and all the available controllable channels, it seems that the hardware is far inferior to the overall capabilities of running a light show???

domls


----------



## zuixro (Sep 23, 2008)

The box from American DJ is probably USB, and it most certainly is buffered. The computer just says what channels need to be at what intensity, and a microcontroller in the box takes care of the rest. Your computer is multitasking, so it has to take care of sending the DMX signal, and checking your email, and displaying stuff on the monitor, etc. The microcontroller in the DMX box only focuses on getting data from the computer, and spitting back out on the DMX line.


----------



## domls (Sep 23, 2008)

Hi Soundman,

Thanks for the input. I checked out the ENTEC site. It looks like they have a USB to serial converter. B&B Electronics (Industrial Serial Communications - B&B Electronics) also has several USB to serial converters that support RS 232 & RS 485 serial comm. In addition, they sell an Ethernet to serial converter box. I think that I would rather have a commerically available box rather than one tied down with a GPL license. I doubt there's any difference between the two. However, I really do like their documentation on the ENTEC site. Perhaps it should be able to help!

But really, I want to be able to write my program because then I have FULL control over how the program operates and can tailor it to my specific needs (such as a text box under each fader that lets me actually _enter_ the value! Seems that I just need to write the correct driver to do this, and/or perhaps use a USB to serial box instead of a 232 to 485 box?

Thanks!

domls


----------



## domls (Sep 23, 2008)

On the B&B site, I found this converter box:
Isolated Inline USB to RS-232, RS_422, RS-485, isolated, in-line, high retention, high-retention

It offers baud rates up to 921Kbps, but on the downside, it's $120.00 (non-isolated version).

OK, so that should take care of the hardware...from there, I could (if necessary) write the underlying driver code in C++, or perhaps write everything in VB...we'll see. Either way, it looks like I need to go with USB, not 232 serial comm.

domls


----------



## waynehoskins (Sep 23, 2008)

I'm not sure if we've solved the frame-break problem or not, but it's interesting nonetheless. 

Hardware boards aren't really outdated; they're just not suited to driving movers (except for the ones that have things like fixture libraries and encoder wheels).

But I like the idea you've got. I like finding low-level solutions to things .. one I want to do sometime is an AMX192 -> DMX512 translator. That's an "eventually" project. Before that, I'm tinkering with a camera-tally-multiplex circuit that creates (and a receiver that decodes) a serial digital stream on one wire with multiplexed clock .. all using 7400 logic.


----------



## domls (Sep 23, 2008)

Here's what I've learned today:
It appears that the only real solution to writing my own program for controlling DMX lighting fixtures is to either A) Build my own converter box that does 2 things: 1) converts the signal from say, USB, to RS 485, and (most importantly) 2) ALSO ESTABLISHES A PROTOCOL FOR MY DMX SOFTWARE TO USE. In other words, I need to actually create my own protocol and implement it _in hardware_. Then, I will be able to create a VB.NET program to run the lighting.

It would seem to me, and yes, I know I'm a newbie/novice at the whole DMX thing, that the architecture of DMX really places a serious limitation on those who have the ability and would like to write their own controller software. Perhaps the designers of DMX were a little short-sighted and didn't take into account the future of lighting fixtures and the fact that a computer-based program would be MUCH more productive in presentation of a show? I know that there seem to be a lot of pluses to using EIA 485, but now, I wonder, perhaps there's a better solution out there (How about every fixture being wireless and receiving signals from the computer via wireless ethernet)?

*I offer my very humble opinion* on this matter, but as a programmer for 25+ years, and having written commercial data collection software for GPS and Robotic total stations for surveying-grade applications, I have found the difficulties here quite hard to swallow.

That said, I may go with the ENTEC solution, or I may build my own box and EPROM program for the protocol. Thanks to all who have contributed to this discussion, and I still welcome any and all comments!!!

domls


----------



## derekleffew (Sep 23, 2008)

domls said:


> ...Perhaps the designers of DMX were a little short-sighted and didn't take into account the future of lighting fixtures and the fact that a computer-based program would be MUCH more productive in presentation of a show? ...


Yes and no. First, it was "specification by committee." CB Member STEVETERRY was one of the major proponents. Its primary purpose was to specify a common language to allow any manufacturer's console to control any other manufacturer's dimmers. USITT DMX-512 (1986) was never intended to control anything other than dimmers, and was based on proprietary industrial hardware and dedicated controllers. Second, most lighting professionals agree that a personal computer, with keyboard and mouse, is no substitute for a dedicated control surface. We've argued this issue here many times. One of many threads: http://www.controlbooth.com/forums/lighting/6262-running-lights-pc.html?highlight=personal+computer. 

If you wish to be forward thinking, research ACN. Unfortunately, no fixtures currently implement it. An interim step, not recommended, might be for you to generate Art-Net from your PC, and purchase an Art-Net to DMX converter (beyond your budget).

I applaud your desire to write your own software, but the fact is there already exist many solutions ranging from sixty dollars to over $50,000 to control lighting. Why re-invent the wheel? While the wheel you invent may be perfectly suited to you, it won't fit any other vehicle, no one but you will be able to use it, and will cost more time and money than an existing solution. And chances are good that it won't be as elegant. Want to program lighting via timeline, just like editing video? How about a touchscreen, or FIVE (+3 external monitors!)? That being said, many professional lighting control systems today run under Embedded XP, Linux, or Mac OSX, so it can be done, just a matter of time, money, and perseverance. It took High End Systems, a major manufacturer, at least five years to deliver a show-capable HogIII, and I have no idea how many programmers and developers they had working on it. See here for the story of the founding of the predominant stage lighting manufacturer in the world. I believe it wasn't until seven years later, in 1982 when EPCOT opened, that the company showed a profit.


----------



## TimMiller (Sep 23, 2008)

I would say try to get a hold of Chris Litz over at high end (High End Systems) . He is on the DMX committee along with doug fleenor (Doug Fleenor Design - Ph. and Fax (805) 481-9599). They have both developed products in this industry, and I bet they would help answer some of your questions, esp, since you are doing this as a hobby and not trying to knock off some product).


----------



## n1ist (Sep 23, 2008)

As others have mentioned, there are quite a few parts to DMX

- The electrical spec is RS485 (5V differential)
- The baud rate is 250000 (this is not a standard RS232 baud rate and can't be accurately generated by many standard baud rate generators.
- You don't need to transmit all 512 data bytes, but there's a minimum number that is needed.
- You need to be able to both send bytes, usually with a UART, and be able to pull the line low. This may be faked by changing the baud rate to a very low value (75 baud comes to mind) and sending a BREAK.
- Some receivers are very sensitive to non-standard timing and spacing between bytes. This often shows up as flicker or jittering in a mover. Driving a 232-485 converter from a Windows PC is what gives the Enttec Open DMX a bad name...

The correct way to do this is to use an external micro to take commands (set channel 3 to 42, set all channels to 0) and runs the DMX loop itself. There are many examples of this out there, some with schematics and source available. It's really quite easy.


----------



## domls (Sep 23, 2008)

Hi N1ist,

That sounds like a good idea. I actually want to build my own "box" as it were that is dedicated to sending the data via DMX protocol. Sounds like I need to buffer the incoming data in the box and just have the program worry about sending data via a protocol that I create for talking to the box.

I really don't mind re-inventing the wheel, as it were, so that I can create an interface that suits me and add to it's capabilities as I go (i.e. as I purchase more stuff). In browsing the American DJ site the other day, I saw a new toy that they have out called the LED Messenger. I downloaded the manual, specs, etc. This device is of course DMX controllable, and it allows you to pre-program words using a standard PS2 keyboard. Now, I don't own it yet, but I'll bet that you can't program the words via DMX. The 3 channels are only for controlling which pre-programmed words to display, sensitivity, and strobe.

The reason I bring this up is that it's an example (to me) where, perhaps, DMX doesn't have the capability of doing something that, in this day and age, should be very easy to do. In other words, let's say you have the fixture set up on stage. Now let's say that you have a controller (be it PC or hardware) set up at the back of the room. IMHO, you should be able to edit the words (for display) from your remote location and then activate them when desired. However, it appears that someone would have to take a PS2 keyboard onto the stage (or the included infrared remote controller) to first edit the text, and then go back to your DMX controller to display the text.

This is what I mean, I suppose, when I say that the lighting fixtures are getting well ahead (technically speaking) of the DMX protocol capability...or, am I wrong?

Anyhow, do you have any links for the schematics etc, for building a box?

Thanks also to TimMiller and derekleffew.

domls


----------



## SHARYNF (Sep 23, 2008)

If you look back at the various approaches for DMX pc based systems it will suggest that
1 you could make your own card, Martin started with ISA card, moved to PCI
2 There were some attempts re using parallel port but eventually all of these on the lower end were abandoned for USB
3 Make your own usb-dmx box this certainly seems to be the way forward, as you can see some of these boxes are down to about 60 dollars, with not a lot of parts

you could do it via firewire 1394 but USB would probably be better

OR you could do it via Ethernet which seems to be the way going forward
It would be interesting to see if you could to an art-net to dmx box your self

I would think that you could bread board up a usb or ethernet version without too much difficulty 

.
Sharyn


----------



## waynehoskins (Sep 23, 2008)

Some important observations, that have been observed before:

- DMX512 wasn't developed to control moving lights and toys; it was invented to control dimmers, to be a standard base. Before DMX512, if you had a Strand rack and an ETC board, fat chance of getting them to talk together: you'd have to build your own LMI-to-CD80 translator, or if you were lucky the board could also talk AMX192. At the time of its invention, we were working with 8080s and 8051s, so this is a protocol that could be implemented with existing hardware of 20 years ago (see Colortran Protocol). 512 addresses was a sufficiently large number that you wouldn't often have to run multiple universes of conventionals like you would with AMX.

- The future of lighting control protocols is in the Ethernet-based systems that are at the bleeding edge now, like ACN. Not that fixtures have so much moved beyond DMX, but people are trying to do things with fixtures now that DMX was never really intended to handle. Side note: when Colortran Protocol was being developed, the PS/2 (and its keyboard) I don't think had been invented yet.


----------



## domls (Sep 23, 2008)

Hi waynehoskins,

I totally understand where you're coming from. Heck, I used to program Apple II computers in assembly language in 1983 to create video games! I don't even own any "regular" par cans, and when I do buy some in the future, I'm sure they'll be the LED type with many DMX channels available!

I envision the day when all lighting fixtures will be wireless and capable of self-addressing like ports on a computer (sort of like using a Bluetooth device that can then discover all the fixtures). No more cables to run, and virtually unlimited numbers of fixtures and channels. Each one having it's own little antenna. Then the controller (or PC) would simply send out data containing the "ip" address of the fixture and channel data.

What do you think?

domls


----------



## TimMiller (Sep 23, 2008)

Thats what RDM is. The fixtures talk back to the console, every fixture has its own unique ID (like a MAC address), The console looks at all of these unique ID's and addresses them based on your parameters such as all of the mac 250's are channels 1-12, all of the mac 300's are channels 13-20. Then it sends a signal back to the fixture to assign the address. Highend has come up with their own protocols for remote addressing and they have been around for about 10 years now (anyone remember the handshake? also the hog II and i believe III can also has fixture talk back). There is wireless DMX with RDM. Also a big player comming out is ArtNET. ArtNet is like DMX over eithernet. It uses Ip adressing to talk to all of the fixtures in the network, just like a set of computers. There are fixtures out there that have eithernet on board (Robe, and highend came out with it on the x-spot but it was unfortuately never implemented into the software).


----------



## derekleffew (Sep 23, 2008)

domls said:


> I envision the day when all lighting fixtures will be wireless and capable of self-addressing like ports on a computer (sort of like using a Bluetooth device that can then discover all the fixtures). No more cables to run, and virtually unlimited numbers of fixtures and channels. Each one having its own little antenna. Then the controller (or PC) would simply send out data containing the "ip" address of the fixture and channel data.


HOW the control sends information to the fixtures, or display devise is much less important than WHAT information is sent. 
The HES ShowPix™, in max mode, requires 451 DMX channels. Directly assigning an RGB color value to each of its 127 LEDs, for each cue, would take forever, so some alternative for control had to be found. The buzzword for the past few years has been "convergence"--the merging of lighting and video. The line separating the two becomes more blurry every day. Video screens (projection or LED video walls) are no longer only for IMAG, but serve also as eye candy. Any/all LED and CMY fixtures may be pixel-mapped, in that a video image (still or moving) is "displayed" across all, or a portion of the fixtures. There are currently three ways to accomplish these goals. 1) Use a "media server," such as Catalyst, Axon, Hippotizer, MBox, or about ten other popular ones. 2) Some lighting consoles: GMA, HogIII, Maxxyz, others, have rudimentary support built in, a bit-mapped image can be displayed across an array of fixtures, for example. 3) Stand-alone interfaces send their own DMX to the fixtures, and the lighting console triggers them with its DMX: PixelDrive, pixelMAD, arKaos.


----------



## n1ist (Sep 24, 2008)

Here are a few sites that have useful information:

usbdmx.com : The bus powered usb dmx interface : Home Page
DMX dimmer pack (he has an apps note for tx as well)
[ a n y m a ] - uDMX - tiny bus powered USB-DMX interface (USB and DMX all on an ATMEGA8)
http://www.enttec.com/docs/dmx_usb_pro_api_spec.pdf (an example of the commands that are sent from a PC to one of these converters)
Projects - Netgear WGT634U - About (an ARTNET node built from a router and simple usb-rs485 converter
Arduino playground - DMX

/mike


----------

