I wanted to set up a Midi Controlled Christmas Light Display using LED Lights. The LED Lights would require less power, allowing the use of a single 15 amp circuit.
The initial design was to control 32 strands of lights, but with the Christmas tree taking up 16 strands and the leaping lights taking up another 16 strands, I decided to increase the total number of relays to 64.
Simply using GPIO pins would not allow me to control that many relays, so I decided to use I2C with a 16 input/output port expander based on the MCP23017 chip from Microchip Technologies Inc.
You can attach multiple MCP23017 chips to the two i2c pins on the Tinker Board to obtain 16 general purpose pins per chip. Using four MCP23017 expansion chips, I could add 64 additional pins to the Tinker Board. The Tinker Board provided better performance than other SBC boards considered.
A search of the internet revealed the IO Pi Plus, manufactured by AB Electronics in the UK. It is a 32 channel digital expansion board designed for the Raspberry Pi, which would also work with the Tinker Board. A pair of MCP23017 chips are on the board allowing you to connect up to 32 digital inputs or outputs. Using two of the boards gave me the 64 pins required.
Having all the relays on at the same time raised the concern of how much power the relay circuit would require. Could the MCP23017 handle the total power demand when every relay is turned on?
The 16 channel relays I selected used opto-isolation and indicated that each relay would require 15-20mA Driver Current; therefore, I estimated the worst case was 320mA per board. The MCP23017 has a maximum output of 150mA; therefore, I reasoned there was a potential of drawing to much power from the board.
Finding the “ULN BOB” 16 Channel Darlington Driver IC Breakout Board was the solution to the potential power problem. It allowed me to have all 64 relays enabled at the same time. The Darlington can handle 500mA per output.
Putting it all together in a compact space required Plexiglas, aluminum angle bar, 32 outlets, wire, connectors, and assorted fasteners. The Tinker Light Controller (TLC) was assembled to fit into a storage container with a hinged cover.
To facilitate the possible need to change out a relay board, I elected to use spring lever push fit reusable cable (5 wire) connectors.
Two 16 relay boards were installed back to back on a sheet of Plexiglas, with each relay board connected to 8 outlets with tabs broken on each outlet, allowing each plug to be control individually by a relay. The Plexiglas was attached to aluminum angle iron using 4 screws.
- White wire is common for all the outlets.
- Black wire carried electricity from the NO connector of each relay to the plug.
- Red wire carried electricity to the COM connector of each relay.
- Copper wire was attached to ground on each outlet.
The one thing that was an oversight in the initial design was access to the SD card on the Tinker Board. I might recommend an SD extension cable to allow you to move the SD card to a location that can be accessed more easily. I had positioned the card for access to the usb, audio, and HDSI connections, which resulted in the SD card slot being difficult to access.
How does it work?
Using Linux, a MIDI File is submitted to the ALSA Sequencer, the service provides a timed events to both Timidity (midi synthesizer for audio output to low watt FM Transmitter) and relay controller software, for mapping to an i2c address, to switch the appropriate relay off or on. In addition, notes can be assigned to trigger a sequence of relays, such as leaping light.
To install the 2c-tools use the following command:
sudo apt-get install i2c-tools
Add the ‘linaro’ user to the I2C group:
sudo adduser linaro i2c
Reboot the board.
The software that controls the relays uses both the pitch and the octave of every note. The number of supported output channels is limited only by how dynamic the range of the midi file. Sixteen channels are used for leaping lights and 16 channels are used for a light tree, leaving 32 relays available for assignment to notes or other lighting features (such as the Bethlehem Star on the top of the house which uses 4 light segments).