So... since I did have to wait for my parts longer than expected this time (and I still wonder how that postal code got messed up on the parcel) and I couldn't really prepare anything ahead for this, it took me a little longer to finish.
After I finally got all the parts I needed and verified their board footprints (yes, those optocouplers are really that large, they seem like DIP-8 with cut leads) I etched and drilled the prototype board and started populating it. I started off with the microcontroller section so I could try to flash the firmware, but I was unlucky: I simply couldn't get the bare controller to show up in the USB device list. Thus, I was unable to flash any firmware over USB. Well, I'm happy I included the ISP header as a backup, because at least that one worked without a hitch.
While testing the DC-DC bridge I measured that the secondary power on my board was not really working as expected, and noticed that the IC was getting really hot. After some debugging I found out that I had accidentally reversed the polarity on the converter outputs. D'oh! The best I could think of was to unsolder the output pads and cross them over with some wires to properly power the circuit, which turned out to be an acceptable fix (at least for a prototype).
After populating the rest of the components, I hooked it up to my Raspberry Pi et voilá - it worked right away, at least the output (I'm still not done programming the input side).
So, with all that done, here's a little update on the Todo List of part 1:
Testing: Well, that is pretty much an ongoing task. My two LED PARs work perfectly, but that hardly counts as extensive testing.
PiLight Integration: Works perfectly as an output, but no work has been done on the input side.
DMX Input: no progress so far, except for the fact that the hardware has been included in the build.
Configuration: I can receive the configuration in the firmware by now, and I have started interpreting it with the AVR timer. Parameter storage to EPROM still needs to be done.
Galvanic isolation: Included and seems to work (at least I got rid of that nasty ground hum the first prototype had). I still need to evaluate if it really is effective against a few hundred to thousand volts.
Packaging: Well, I still need an enclosure :)
To round things up, here's a few pictures of the result:
Alright! It's been quite some time since my last post here (almost a year!), and I must admit that there has not been much going on, so at least you haven't been missing out. That is - until a few days ago, of course, and that's why I'm writing this new post to bring my latest experiences to you!
I've already mentioned the DMX protocol on here before, but since I had the opportunity to work with some actual DMX equipment these days, I thought this would be a good time to dive in deeper. Some words about the DMX protocol:
It's the de facto standard for professional lighting equipment. Pretty much any kind of modern lighting equipment that is used on stage comes with a DMX interface (well, apart from simple lamps obviously, since those will usually be hooked up to a DMX dimmer).
It is a serial protocol, transferred over an RS485 bus; It's initiated via a so-called "break" signal followed by a "start" byte and up to 512 channel value bytes in sequential order. After that follows the next break, and the cycle starts over. All bytes are sent as 8N2, meaning 8 bits followed by two stop bits.
The first thing I did was to attach a MAX485 chip to one of my Arduinos to have some sort of "reference device" that I could perform further tests with. I adapted some code taken from Hennes Sites and verified that it was working by attaching the circuit to a DMX controller. The good news from this experiment is: I did not need to alter the RS485 receiving circuit, which means that both the PiLight controller board as well as the PiLight LED dimmer are basically capable of receiving DMX signals; They only lack the right firmware, which I might eventually come up with.
Reference device with 6 DMX channels
The one thing I am really after is to have an interface that would allow the integration of actual DMX devices into the PiLight system. It should be pretty simple to come up with a simple SPI-driven extension board for the Raspberry PI that would output DMX (fueled for instance by a ATMega328p), and I might eventually return to that idea.
But instead, I have a different idea.
From the past I already know a few DMX-Interfaces for computers, and most of them will work more or less reliably. But there is one Interface that is not only know for its reliability, but also its performance and the fact that you can actually build one yourself (and yes, I have). I'm talking about the Digital Enlightenment USB-DMX Interface.
Now, if I'd just follow the scheme and built another instance of this well-known interface, that would be kind of boring. Instead, I've had a few thoughts on the design (that dates back a few years now):
It uses a separate USBN chip to communicate with the computer. While this works perfectly, it also seems a little redundant these days, since we now have microcontrollers available that come with an integrated USB interface (e.g. ATMega16u2, ATMega32u4).
It uses an 8kb external memory chip (and an additional latch chip for communication) in order to store the current DMX state. This is due to the limited amount of memory available (512 bytes on an ATMega8515) in the original microcontroller. Now, 8kb is still a lot of data for a microcontroller today (an ATMega32u4 holds 2,5kb), but with some optimization I might actually find a solution that does not require any external memory.
So... with a little bit of work, I could reduce the necessary components, and combined with the switch to SMT components that would mean a much smaller and cheaper DMX interface!
After some work on the Arduino core I was able to come up with some modified USB code that contained the device descriptors of the original interface, and after some more hacking I held in my hand an Arduino Leonardo that was recognized by the original driver and was successfully receiving data from the software. I attached some LEDs to the PWM ports and was able to control their level from the computer. Success!
Now all I had to do was to come up with some code that would output the correct DMX-signals on the internal UART, add a MAX484 converter chip, and my newly created homebrew DMX interface would be finished. I connected it to my reference device, and it worked right away! Awesome!
Complete DMX testing setup: Arduino Leonardo as DMX interface on the left, Arduino UNO as DMX reference device on the right, both connected via a DMX-like connection.
Another shot of the testing setup
What's next? Here's the (unordered) list of next steps:
Testing. First of all I will need to test my new interface with some real-world DMX devices, to make sure that the generated output is sufficient for real-world applications.
PiLight Integration: So far I've spent a lot of time coming up with a DMX interface, but I haven't spent any time to make it work with the PiLight software. The good news is, that there's already some python code available. Also, this would introduce compatibility with the original interface design.
DMX Input: The original interface supported a DMX input, too, as well as a handful of different modes that would combine the signals in different ways which I'd like to implement as well for full compatibility.
Configuration: The original design had a set of parameters that could be used to fine-tune the DMX output. The DMX standard allows for some variations in the protocol timing, and some devices might fail to interpret the data under certain circumstances. The parameters could be used to fix this. Would be nice to have that option, too.
Galvanic isolation: The original design features a complete isolation of the DMX part from the microprocessor, that would protect the attached computer in case of a DMX device on the bus erratically outputting excess voltage onto the bus. Easily adopted from the original design.
Packaging: Once the circuit and software is confirmed to work, I will try to come up with a PCB reduced to the minimum, and some sort of case. When leaving out the galvanic isolation, this might even be small enough to enclose into some sort of USB key.
You know the day is going to be good when the mailman rings at the door during breakfast time. Well, apart from the breakfast obviously. In my case, I was about to receive a box of fresh new and exciting components to build awesome stuff with:
Bunch of components
Among them was the ATMEGA328P microcontrollers I was eagerly waiting for to be able to build the controller module from my previous post. I already prepared the PCB (my first double-sided one, with lots of vias), meaning that I could start with all the SMD components right away:
Pilight controller board, partially assembled
After making sure that there were no shorts or dead solder joints on the board I was ready to add the headers and program the microcontroller:
Finished controller board
Port illustration
Size comparison: Full-size Arduino, Pilight controller, Arduino Mini
Programming with ArduinoISP
The programming step was a little troublesome, because I wired the cable to connect the controller to the Arduino incorrectly, meaning that my controller was missing ground and in constant reset state. Of course the cable was the last part I checked... However, after fixing it programming went fine.
After that, I hooked the board to the WS2801 LED pixel strand only to find out that i switched data & clock on the SPI port. Oh well. Luckily, I could make it work with a corresponding cable:
Controller in place
I previously named this the "Pilight universal controller" because I designed it to be able to drive all the various pilight devices - and so I needed to try the I2C port, too:
Pilight controller driving a PCA9685 PWM board
I'm very glad it all worked out so nicely. This first controller prototype will now resume its work on the pixel strand, and I am back to the drawing board to integrate the same microcontroller circuit into the LED dimmer board.
Update: Here's another short video of the controller in action. Enjoy :)