A model building with fancy lights

Image of the SSE Hydro which is a multi-purpose indoor arena located within the Scottish Event Campus in Glasgow, Scotland.
The Glasgow SSE Hydro Arena

The company I work for has been asked to take part with a local Science Centre to contribute ideas for their refurbishment of one of their floors. As part of the Internet of Things interest group at my work I helped to contribute the idea of having a diorama or scale model of the area around the science centre and parts of the city centre or even areas round the city which could be controlled by external stimulus such as QR codes or voice control. At the moment voice control has not been implemented and I will probable use Amazon Alexa for that (as I already have an account) so that will be the subject of a later entry.

This diorama was planned to be housed in a glass/perspex case to avoid damage from inquisitive fingers and would be used to highlight that you can effect the world (or in this case a model) by external manipulation. The QR code would be triggered by using the camera application on either an Android or Apple phone and a button on a website would appear with some expected results in text and would then action the activity (be that switching on a building’s lights or causing some movement to happen such as trains/buses or cranes to move). This action could be guarded by a logic puzzle to provide a prior learning experience before allowing them to change the diorama. There would be multiple activities to action, one per QR code and these could all be running simultaneously on the diorama.

As a demonstration of this idea I built a model of a well known building in the centre of the city and built a software application which would allow you to go to a website, trigger a button and cause LEDs to flash in the model, much like the external features that the building exhibits anyway. I thought it would be fun to tell people how I did this so they could try it out with building models in their own city.

The Hydro Arena is a Greek style amphitheatre  with the outside wall of it following the amphitheatre seating in the inside. It is in the back of this seating where the colour lights are that allow the building to be lit in different colours. These building walls posed me some problems when I came to build the models transparent walls to let the LEDs shine through, but I will go into detail of that later.

My first step was to identify the best way to control RBG LEDs from a Raspberry Pi. I chose the Raspberry Pi so that I could have an entirely self contained demonstration at the Science Centre as I planned to have a WiFi Hotspot in the Pi to allow multiple users to access the controls on their phones to change the LEDs within the model. I knew of the TLC5940 PWM LED Driver IC which can control Multiple LEDs but I also knew that when using the bare chip the wiring would be complex and unlikely to be completed in the time I had before the demo. I looked around at more “pre-build” versions of this chip and came upon the PCA9685 16 Channel 12-Bit PWM Servo Motor Driver which, although made to control servos would also allow me to control RGB LEDs. So after some soldering I ended up with this:

I realised that these circuits were far too bulky and the model building would be pretty big. So I decided to look for another solution. I’m not actually sure where I came across single addressable surface mounted LEDs, I think they were mentioned to me by one of the in-house IoT group and I had a look around the internet and and found the WS2812B chipset. Single addressable RBG LEDs in a handy, cutable strip which could be bought easily and quickly.

So I bought a strip and looked for a Raspberry Pi library to drive them.  There was only a Python library which is a language which I don’t really like and so I decided to add in an extra hardware step, i.e. use an Arduino Nano to drive the lights. This was partially driven by finding a Arduino library called FASTLed which appeared to offer all the facilities and much, much more that I wanted in controlling these lights and partially because I had a communications library which allowed me to easily link an Arduino Nano and a Rasp Pi together without resorting to voltage level changers as Rasp pi uses 3.3 volts and Arduino Nano uses 5 volts which can cause some pretty nasty issues between the two.

So I put together a test rig with the first 16 LEDs on the strip and keeping the pre-connected wires at the end tried them out:

This went remarkably well! You just need to identify the chips being used, and if there are 3 or 5 address connectors and away you go. The chips seem to auto sense the start of the chain so the first LED after the cut is always zero and so on. I had the strip doing all sorts of tricks in just a short period of time.

Short video testing sending messages and using the FASTLed Library to switch the LEDs. The music was lucky happenstance and was just playing at the time from my computer.

So now I had to work out how to put all the electronics inside a relatively small model of the SEE Hydro. This started by me making an attempt to get the right “lean” for the front side and the back of the Hydro. As you can see this is a bit complex.

I hunted around the internet for some architectural plans of the Hydro but these were generally focused on the seating layout or single cross sections to the middle of the building so not much help for me to build the entire outside wall. I came to the conclusion that someone somewhere must have made a paper model of this building at some point so changed my search terms to that. I immediately got at hit! With a copy of this paper model I had a go at what it may look like:

It didn’t looks like much to work with so I tried it in a couple of new configurations:

Although this was lots of fun for me, this didn’t seem to help much other than provide a sense of scale for the paper model. It was cut from a single A4 sheet of paper, and I probably should have used card.

However I decided that the part which provided the wall could possible be blown up to A3 size (using my wife’s A3 printer that she has for music) and cut from translucent plastic which would provide what I wanted.

As you can see from the above picture I had measured out the angles for 18 partitions on foam board but only wanted to have 16 lights. This gave me space for the wires to power the whole thing to come out the back and maybe some wiggle room for the wires and mechanics for the internals. The section cut from the child’s ball was a bit of a disaster. When it was spray painted with white paint to cover the coloured surface it just curled up and died!

Next thing was that I noticed that if the ring of lights is glued directly onto the foam board then it would be very low on the translucent plastic and probably pressed against it. So not a very good light effect. I reckoned that needed to raise them up a bit. I also needed to take the rather chunky cable off of the end of the light strip as it took up too much room inside the model.

I built some cardboard stands which raised the LEDs to approximately half way up the translucent wall and started to stick the LEDs to them using the sticky glue on the back of the printed circuit board. This worked pretty well at first. You will note that I also used a new strip of 16 LEDs which had no pre-soldered connector as I planned to add my own lighter gauge wires as shown below.

At this point I put together a bit of perf board with some female pin headers for the Arduino Nano to sit in so that I wasn’t soldering wires directly to pins on the nano itself.

Half made seat for Arduino Nano

Next step was to put it all together. I started to glue the stands onto the foamboard but this caused the less than sticky LED strip to start to come off of the stands. I then used superglue and some mini clamps to reinforce the base as I went along. This gallery also has some shots of the Arduino Nano in situ with the perf board and pin headers. The arrow on the foam board indicates where the highest point of the translucent wall should be so that the double thickness with the hole for the power cable will sit opposite. The finished structure will slide into the translucent wall when ready.

After a bit more thought I realised that I wanted to divide the LEDs into “cells” where the colour of each LED did not bleed into the next. This was similar to the effect shown in the banner picture of the real building at the top of this blog entry and also meant that I could show some dividing vertical “walls” in the model building which would make it a bit more realistic. I couldn’t do much about the horizontal lines round the building, so decided to leave those well alone. These pictures also show the final seating of the Arduino Nano in the centre of the model.

Below is the final assembly of the model with Raspberry Pi and Ardunio Nano and the polystyrene roof in the background which was quite effective and had a similar curvature as the real building. It sits on an A4 cardboard base which has been covered with some green felt which I had left over from another project to give the appearance of grass. Communications between the Rasp Pi and the Nano was by USB serial cable and is shown in the picture. The cables powering the two devices were pretty thick with pretty chunky connectors, but it is difficult to get anything with thin cable with the right connections for a project like this without building your own and I did not have the time to do that.

Final build with all components except the roof of the model building in place
Final build with Raspberry Pi lifted out to show position of Arduino Nano and cabling for LEDs

After all the physical build of the model and the electronics, now I needed to work out the software for the Nano and the Raspberry Pi. I had a simple RS232 protocol mechanism which I had used in a few projects and would work between the Arduino and the Pi just by plugging in a USB cable between them, so communications was sorted. I planned to use Spring Boot to handle the processing of the REST messages from the front end, which I planned to use Angular for and access that by url‘s selected by the QR codes and I had example files from another project which had been provided by my friend Brian Hackett to produce the WiFi hotspot code. Well, putting all that together should be fairly simple!

For those interested in the programming, both for the Arduino and the Raspberry Pi, all code can be found on Github in a public project which you can fork at https://github.com/ksimes/SSEHydroModel. The example WiFi files are also there, under an appropriately named folder with instructions in a file called hotspot.txt. Some tweeking may be required, especially as later versions of Rasperian appear to change the WiFi configuration regularly. But at the moment it does work for Raspberian Stretch, October 2018.

Below is a short video demo of the final model in action. The hideous grinding noise is me using the manual focus trying to get the phone screen and then the model in focus during filming.

Thank you for watching and reading.

Leave a Reply

Your email address will not be published. Required fields are marked *