DMX isn't too bad if you spend a while in the datasheet. Depending on the chip you use, there are a few 'optimal' clock speeds which will allow you to send and receive zero error.
It's just asynchronous serial @ 250 kbaud.
I've used both '628s @ 20MHz and F88 chips @ 16Mhz, both transmitting and receiving.
Just receive through an appropriate level shifting chip (MAX485, SN75176 or similar).
The first thing I do is watch for the 'break' signal. PULSIN works remarkably well for this. I set a reasonable timeout duration and just keep watching for that 80 uS minimum break period.
Then, I use a WHILE RCIF = 0 : WEND loop to sit there and wait for something else to come through the USART.
Once I've found a valid break, the next byte is the start code. For dimmers, it should be zero.
Then I just increment a counter each time a byte comes through and when I've received what I want, I exit the loop.
I've not ever tried to implement a full interrupt based receiving system, as my other housekeeping code was fairly lightweight. However, it shouldn't be hard to do in theory.
Transmitting is almost the same: just generate a 'break' signal (I like 120 uS), send out a zero byte and then however many bytes of channel data you need. With tight code, I can output 512 channels @ almost 40 Hz...
John
Bookmarks