NOTE This has been update on January 29th, 2019.
This is going to be a multi-part series on my build of an DMX 512 controller based around the Mbed LPC1768 microcontroller with MBed OS 5. At it's heart lives the ARM Cortex M3 CPU. While it offers many I/O options, I plan on using a small set of the features to complete this goal.
A DMX 512 packet is fairly simple. Each bit is 4 microseconds long, which equates to a data rate of 250 KHz. Between packets, the signal is kept high. The packet is built as follows:
1) Break signal of 88 microseconds or longer. I am keeping this at 88 microseconds. However, I have heard this could be an issue for some devices. If so, I will bump this value up incrementally as a test.
2) Mark After Break signal of 8 microseconds or longer. The signal can be up to one second in length. Again, I am keeping this at the minimum time of 8 microseconds and can adjust it if required.
3) Start Code signal. This is where timing becomes critical. Unlike the first two signals, the start code has to be 44 microseconds long. The signal is broken down into the following 11 bits:
* First bit is always low, signialing the start bit.
* The next 8 bits signify the binary representation of the data between 0 and 255.
* The remaining 2 bits are high, signifying the end of the information.
This frame is often seen as the data for address 0, which is the controller itself.
4) Mark Time between Frames which is loosely timed as a little more than 0 seconds to less than one second. Each frame gets one of these high signals.
5) Channel data signals follow the setup of the Start Code frame and the data is followed in a sequencial manner. The upside to this is you don't need to send an address and value, just the value. The downside is that if you want to update the value at address 128, you have to send the values for all 128 addresses instead of just one address.
6) After the last frame is sent, the output stays high and the next packet can be sent along.
I started with a simple program here that uses a 512 by 8 array of boolean values that I can bitbang out. Every eight 1/0 bits represents the binary value of a number between 0 and 255. In this case, the array is counting up from 0 to 255, then back down to 0 again. The code then enters an infinate loop that sends out the packet based on the array created earlier. The output from the LPC1768 is sent into a Texas Insturments SN75176, which is a differential bus transceiver. This creates the positive and negative 2.5 volt signals that is required for the DMX 512 protocol. The pin I used coming from the MBed LPC1768 is a PWM pin and was chosen as it was close to the input pin of the differential bus transceiver input pin.
My next step will be to create a simple user interface to send data given by the user, but that is for a future blog post.