MOD5441X DMX512 Receiver

Discussion to talk about software related topics only.
Post Reply
jfox21381
Posts: 7
Joined: Tue Feb 03, 2015 1:51 pm

MOD5441X DMX512 Receiver

Post by jfox21381 »

I have an application where I need to receive and process a DMX512 byte stream from a show controller. The DMX512 protocol is described here: http://en.wikipedia.org/wiki/DMX512 . I have a DS26LS32CN chip to convert the incoming DMX signal to 0-5V and pass it on to UART1 on my MOD5441X dev board. In the code I'm opening the serial port the standard way and create a task to read the data in the buffer.

Code: Select all

SerialClose( SYNCON_PORT_NUMBER ); //close the serial port

	syncon_serial_fd = OpenSerial( SYNCON_PORT_NUMBER, 250000, 2, 8, eParityNone ); //reopen the port in interrupt mode

	iprintf("->Serial: Syncon Handler Opened on Port %d Successfully!\n", SYNCON_PORT_NUMBER); //report progress

	if (OSTaskCreate(serial_in_handler_task, NULL, ( void * ) &serial_in_stack[USER_TASK_STK_SIZE], ( void * ) serial_in_stack, SERIAL_IN_PRIO ) != OS_NO_ERR )
	{
		iprintf("->**Error Creating Serial In Task**\n");
		return 1;
	}

Code: Select all

void serial_in_handler_task( void *pd )
{
	static unsigned char input_buffer[1024]; //input buffer

	if (syncon_serial_fd > 0) //make sure the port opened without any errors
	{
		while (1){ //continuous loop that blocks on UART read
			int bytes_read = ReadWithTimeout(syncon_serial_fd, (char*)input_buffer, 1024, TICKS_PER_SECOND); //read from port

			switch (bytes_read){ //switch on return value
				case 0: //TIMEOUT
					break;
				case -1: //ERROR
					iprintf("->Serial: Error ** \n");
					break;
				default: //NORMAL
					//iprintf("->Serial: Read %d bytes\n", bytes_read);
					process_incoming_bytes(input_buffer, bytes_read); //process incoming bytes
					break;
			}
		}

		iprintf("->**TERMINATING SYNCON TASK**\n");
	}
	else
	{
		//TODO: Handle the error
	}
}

Code: Select all

void process_incoming_bytes(unsigned char byte_buffer[], int bytes_read)
{
	for (int i=0; i<bytes_read; i++)
	{
		char current_byte = byte_buffer[i]; //get byte to be processed

		switch (syncon_packet_pointer)
		{
			default:        //receive the payload of the packet

				if (current_byte != 0)
				{
					iprintf("->Serial: Byte %d = %x\n", syncon_packet_pointer, current_byte);
				}

				if (syncon_packet_pointer != SYNCON_PACKET_LENGTH-1)
				{
					packet_buffer[syncon_packet_pointer++] = current_byte;
				}
				else
				{
					packet_buffer[syncon_packet_pointer] = current_byte;
					syncon_packet_count++;
					//iprintf("->Serial: Count - %d\n", syncon_packet_count);
					syncon_packet_pointer = 0;
				}
				break;
		} // end switch
	}
}
I'm seeing the data coming into the buffer, but the values that are reported are what they should be. All of the DMX channel data is set to 0, but the code is reporting 0xFC. I thought I would be able to read the correct data bytes no problem and would have to figure out how to detect the start of the DMX packet. There is a 100usec break in the stream to denote the start of the packet. Any suggestions on what I'm doing wrong and how I can detect that break at the start of the packet?
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: MOD5441X DMX512 Receiver

Post by ecasey »

I don't think the MOD5441X is 5 volt tolerant. The DS26LS32CN has a minimum Vcc of 4.5 Volts and it doesn't look like it is open collector. You may be experiencing a signal voltage problem if you are connecting directly to the MOD5441X. You could also be damaging the module.
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: MOD5441X DMX512 Receiver

Post by sblair »

Heya, I'm actually on the committee that maintains the DMX standard in PLASA, and I Chair the RDM group. I've also implemented DMX and RDM on a MOD5441x system.

A couple things, #1 you WILL have to use an external clock input to get the 250KBaud for DMX, you will see a lot of errors otherwise. We missed that on our first board spin with it, there's no getting around it.

#2, you are very unlikely to be able to use the normal Serial routines with DMX because of it's timings. I use the normal serial routines for a LOT of other stuff that we are doing, but for DMX we wrote our own code down to the UART level with a state machine to handle receiving and generating timings for BREAK, Mark After BREAK, etc. Once you get past the Start Code then you can make use of the DMA to handle receiving the rest of the slots so you don't have to catch each one with an interrupt as it comes in.

FYI, also keep in mind there is a WIDE window on some of the timings. BREAK can range from 88uS up to 1S. The recommended minimum now is 176uS to be friendly for RDM.

None of this is probably the news you wanted to hear I know, but hopefully it will save you from some wrong paths.

Scott
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: MOD5441X DMX512 Receiver

Post by dciliske »

Just the guy I was going to page... I knew you did DMX stuff Scott, but I didn't know you were on the committee!
Dan Ciliske
Project Engineer
Netburner, Inc
jfox21381
Posts: 7
Joined: Tue Feb 03, 2015 1:51 pm

Re: MOD5441X DMX512 Receiver

Post by jfox21381 »

Thanks for the help guys. I will look into those suggestions.

Jason
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: MOD5441X DMX512 Receiver

Post by sblair »

dciliske wrote:Just the guy I was going to page... I knew you did DMX stuff Scott, but I didn't know you were on the committee!
Yeah, it takes a being a true masochist to get involved in writing standards, especially for still doing it after 17 years now....
Post Reply