I don't know what it is about clocks and watches, but it seems that every second projects is one form of the two. This project follows along in the footsteps too. I have made smaller clocks before, but nothing of the scale of a typical wall clock. This is due mainly to the high price of fabricating one off large PCBs.
I wanted to create something large, not too big. I also wanted to keep the cost down. I managed to solve these problems by making various design choices, which will be covered in detail in the following steps.
I got some initial inspiration from adafruits 12 pixel neopixel ring, and now I notice that they sell a 60 pixel version which wasn't available back when I designed this, but comes as 4 segments to create a full ring. This would be an easy way to create a similar clock, without the need for making PCBs and soldering LEDs and small SMD parts.
I showed my design off over at the 43oh forums at the first prototype, the users there are great. They offered hints and design advice, aswell as helping source cheaper LEDs and PCBs, by buying in bulk via a group buy. If you have a projects that you are working on you should think about taking the time to display it somewhere online. Another great reason, since writing is a creative process, it can definitely help you process ideas and thoughts if you ever get stuck on a project.
Please note, I am writing this more as a project log rather than a tutorial, Basically because I will only make one of these following the steps outlined here exactly, and I know that if I make it again it will be different, and different again after that. Files for the PCBs and BOMs will be provided at the end, I would encourage you to get the PCBs fabricated and solder up a ring if you think you are up for it, I'd love to see your own artistic spin on it. :D
Step 1: PCBs
The design idea was to create a ring, since a few of the cheap PCB manufactures will send you 5 or 10 pieces of your single design, I figured it would be pointless to buy a 20cmx20cm PCB, and then waste 80% of it. Prototyping with boards that large is much more expensive than small 5cm squared boards. Not to mention that I would have paid for 5 pieces, and would only be using 1.
The solution was to create a small arched segment, that would be identical, and could be daisy-chained together. Initial designs involved a data/clock/latch/power data connection between boards. each board would then need a serial shift register and some driving electronics to drive the LEDs, this solution would work perfectly fine, except it would only provide a binary output to the LEDs. I wanted more than colours.
Moving on to another thought, LED drivers. This would have basically been a similar electronics setup to the equinox clock. Which I actually took some inspiration from. This would have used up alot of space on the PCBs and would have actually increased the total cost quite a lot.
Step 2: LEDs
The magic sauce of this project is the LEDs, they are part number WS2812b.
What's so special about them?
at first glance they may look similar to any 5050 sized RGB LED, except that they only have 4 pins.
Looking a little closer, you can notice a small controller inside the die itself.
This controller, drives the 3 colour channels via PWM, it is programmed via a single wire time based protocol.
These LEDs are now very popular in LED strips, 3 lines enable complete 24bit colour control of a theoretically unlimited number of LEDs. Because they only need power and a single data pin, the PCB design becomes very simple. Infact most of the PCB is a filled power plane, that is used to help dissipate any heat generated. The fact that the back of the PCB is bare is very useful for the next step.
One thing to note about these LEDs, they are very smart. 24 bit colour control, internal current limiting, buffering and reshaping of signal, daisy-chainable. But they are not smart enough to display a clock face, or even to light up the colour that you want them to be without some kind of controller that is speaking a language they understand.
A quick search for "WS2812 code" will probably turn up results for your favorite platform. Ideally I would use an AVR, then it could be made arduino compatible, and I could use the arduino buzz-word through out my arduino compatible project summary. Arduino's are great, and would infact work perfectly to drive 120 of these LEDs, but I did not use an AVR for this project.
Step 3: Controller
I mentioned in the last step I did not use an AVR, this means that this project is not arduino compatible. There are a few reasons because of this:
- I've been experimenting with TI's MSP430 line for awhile now.
- They have a "capTouch" feature which enables zero component capacitive sensors.
- I had already developed code to talk to the LEDs on the MSP430 hardware.
- I was looking at my TI89 when I was first thinking about this project.
- I already had all the development tools installed on my computer.
- I've done more research on the hardware architecture.
- The MSP430 G series is relatively new, and I like the bleeding edge.
Anyway, enough swable. These LEDs needed a master, someone to tell them what to do and when. I chose the MSP430G2553, for it's decent program memory/ram (8kb/512b), it's 28 pin count, and it's relatively small and easy to solder TSSOP form factor.
Almost all the pins are used, I wanted to make this controller a bit more special. So a 12 point touch slider has been fabricated into the edge of the board. It was envisioned that this would act somewhat like a 1d touchpad, as input into the device. like a computer mouse scroll wheel, before they added a middle button, and prev/next switches if you pushed the wheel.
3 other pins are used to interface to a I2C accelerometer, because why not? another pair of pins connects to a 32khz watch crystal for adequate time keeping, this is a clock after all. finally a single pin is used to interface to all 120 LED pixels.
The whole controller fits onto the back of one of the segment, with no disturbance of the LEDs above it, meaning from the front, the only difference between the two segments is a small amount extra traces between the LEDs, and a tiny programming connection, the mounting hole, and daisy connections are identical.
The videos show off the capacitive touch pads embedded in the controller, and a quick demo of the accelerometer.
Step 4: Case Options
At this point I have a very nice looking ring, it is covered in bright, colorful, pretty, RGB LEDS. but it still has wires running off to power it, and it's still very fragile.
I never like packing my projects into black plastic ABS boxes, I actually prefer to see the PCB, but that's not wise for something that you want to keep working for a long time. I had a crazy idea to encase the whole ring in clear resin. There were a few problems with this, I had NEVER touched casting resin before. So I went to my local hardware, bought a tin of clear resin, and experimented.
I can't remember where or when, but I recalled that Vaseline can be used to stop resin sticking to surfaces. I still don't know if this is true, but I used it anyway.
This is how the experiment played out (following along with the pictures)
- Cut out some wood segments, coat in a thin layer of vasoline
- Clamp up the wood to create a cube mold, my final ring would have a cross section about this size.
- Get resin supplies, read instructions, twice.
- Put on gloves, resin is nasty stuff so go outside.
- Mix up according to instructions.
- Pour into mold, for this test I suspended a single WS2812 led inside. (notice my mold leaked. u_u)
- after 24 hours of curing, I extracted my completed cube.
- After some light sanding and polishing.
I identified a few improvements I could do. One was buy more finer grit sand paper, for polishing. Another was make sure that your mold is leak proof. the leaked puddle actually created a chip in the main cubes corner, because it required a bit of force to remove.
Step 5: Making a Mold
Another issue with casting the entire project in resin is that I had no idea how to make a circular mold.
I know this would be achieved easily with a CNC mill ( maybe even a laser cutter ;) ). All I wanted was a circular channel in a piece of wood. I didn't want to spend too much money and I wanted to make use of tool I had already invested money into.
Searching router circle shows some simple guides that do exactly this. I decided to do mine just a little differently. I created my jig slightly different, in my setup the router stays in the one place, and my workpiece is rotated
Notice how everything is marked, I tried to be as symmetric as I could when cutting my mounting holes, but they aren't symmetric, so the mold needs to be put back the same orientation for a perfect circle. It is also a very good practice to label and date everything. If you ever need to use it again, you know you're using the right one, and not the one you found was too big, defective, etc.
Overall I spent less than $10 on screws and MDF to make this mold. Money well spent.
Step 6: Setting the Ring
So now that the mold is made, I need to do a few things to the PCB itself first. Since I can't just take it out of the resin once it's gone in, I need a method for talking to the micro controller. I was thinking a few different ideas, wireless, IR, inductive coils. Then one of my friends slapped me and told me KISS, "Keep It Simple Stupid"
Since I already have a small debug connector (4 pins), I decided to stay with that, I just needed to solder on a connector that will end up flush against the edge of the resin. This has to be sealed, so that resin won't fill the pins, this small one is already sealed from the rear, so all I needed to do was place a carefully cut label over the connector holes.
Secondly the ring needs power, so again I went for simplicity and used 2 threaded solder in standoffs in the board. these will carry the 5 volts and ground to power the ring.
These 3 extrusions from the board are evenly spaced as to provide a stable raised support. I wanted to have the LEDs facing upwards in the mold because I feared that more bubbles would be lodged under them than the bare rear PCB. Now its time to pour the resin.
Pouring a layer of resin just over half the height, then placing the ring in and slowly twisting it while pushing down will reduce the bubbles trapped underneath. Another layer is poured over the top of the LEDs slowly, ensuring no excess bubbles are formed, bubbles in the resin will float to the top and pop with time. Once the resin is poured a needle can be used to poke at the PCB and ensure it is centered in the mold.
One thing I noticed at this point was that the mold was closer to a perfect circle than the ring was :/
Leave this for 24 hours to set.
Step 7: Problems Arise
After 24 hours I went to check on the mold. It was still very much a liquid and had not hardened at all.
The trial run with the resin cube had been left outside all night just like this one, but that had been a few weeks before I'd made the mold and it was a much warmer night.
It had been a very cold night, and I had left the mold in the shed to cure. I promptly moved the entire mold out into the sun, I must have knocked it because I came to check on it after an hour and the resin had started to pour out the two corners I had left without bolts. Everything was going wrong, I promptly added the two bolts that I had left off thinking that 2 would be enough. I tilted the mold a bit too much adding the second bolt, resin pored up over the edge and down one side of my mold. I am grateful that I didn't discard the excess resin that I had mixed up. I hastily pored the excess resin into the mold, replacing what was now all over my work bench.
To speed up the curing process a halogen lamp was used to warm up the resin.
If you're repeating this you will need to experiment with you own brand of resin.
Step 8: Removing the Mold
Initially I had hoped that I could just kind of pop the ring out of the mold. but with the leaking and long setting time, I began to doubt it would be so easy. The resin had probably seeped into the wood grain by now, I'm using MDF sheets for the mold, so that's a likely outcome.
Using the jig I had designed for routing out circles. I marked where the edge of the ring was. Found appropriate distances to route at. Then I checked these back with the ring. Making a mistake here could result in LEDs being routed in half and a very non-functional timepiece.
I decided it would be a good idea to remove the bottom half of the mold. The tracing paper I used between layers worked very well to keep the resin from the wood. But wasn't exactly flush with the bottom wood layer, so the surface wasn't flat as I had hoped. Ohh and there was an air bubble.
I poked at the surface and noticed that it hadn't fully set yet. perfect. Using an exacto knife the resin was cut out above the bubble. I mixed up a small batch of resin, this time making sure to use plenty of the catalyst. I filled the hole, and traveled around the ring covering the whole back with an extra 2mm. My plan was to sand this down back to a perfectly flat surface.
I used the router to try to get the surface flat, this is called facing off a surface I believe. Unfortunately the jig I was using for the circles wasn't very good at keeping the working material a fixed distance from the router, so I resorted to my coarsest sand paper, P160. I'm using wet and dry sand paper, with water. this is recommended for resin ans the particles clog up the sand paper otherwise. Be prepared to use alot of elbow grease if you are repeating this.
My suspicions were correct when I started milling around the ring. The wood had a darker patch an extra 1-2mm around the circumference. So it is essential to mill out the ring from the wood. Milling was done is small increments, around 3mm of depth each pass.
Once free from the resin mold you'll be faced with hours of arm falling off sanding. If you have some kind of sanding machine this might be easier, but using your hands gives you complete control. I started with the 160 grade wet/dry sandpaper.
Once I had gotten rid of all the impurities I could. I moved down a grade, 240. I sanded away, this grade would be used to remove the scratches left by the 160, But it also leaves smaller scratches behind. Moving down in grades creates smaller and smaller scratches on the surface of your material. Once you're down at 1600, you should have a very smooth ring. but it wont be clear. It's your choice now whether to move on to polishing and buffing. Which will remove the last tiny scratches left by the sanding process. I decided to leave it unpolished.
When sanding I decided I would like rounded edges, so I sanded heavily around the edges with 160 grade paper. This actually gives the illusion that the board is wider than it really is, since the resin acts like a lens and it almost warps the LEDs around the edges a little.
Step 9: Let the Programming Begin
Before I had even thought about the casing I was programming the ring. But since I started working on the casing I had left the programming side to the end, that is why I had to include a programming socket. Can you imagine if there was a bug in my code and I had no way to fix it!!
Here is where another problem showed itself. A broken LED!! I had written a small test program that would show a pattern on the LEDs when power was applied, this pattern would cycle though colours to tell me that everything was working as intended. However I was only testing every second LED on the outer ring. Once I had programed to use the inner ring I discovered that only the first half worked, the second half wouldn't display anything. Strange enough, if the LEDs were powered from 3.6volts instead of 5, data would pass through this LED, but it still didn't display anything. However the colours given off by the LEDs are much better at 5v. so I decided to cut my losses and just use 60 LEDs of my ring.
This is actually a blessing in disguise, because I had only done a quick calculation in the back of my head while selection the brains of this clock. The chosen MCU the MSP430G2553 only has 512bytes of RAM. Yes, bytes. I had programmed a buffer to store all the LED values, they would then be transmitted in one quick burst to all the LEDs, this buffer takes up 360 bytes of our precious resource, that's a little over 70% of the RAM gone right there.
As it turns out, one of the coolest features of this clock is a capacitive touch sensor arrangement that I embedded into the edge of the PCB, Honestly I didn't even know if it would work, I've never made capacitive sensors that way before. But they did work, and work well. TI, the manufacture of the MSP430 microcontroller line, create an API for reading capacitive sensors, the capacitive touch software library. It is fantastic, however because of all the work it has to do, it uses alot of RAM. The 12 elements I needed to measure use 48 bytes, to store current measure values and a baseline value. then calling the function consumes space on the stack, I debugged some library calls, and found about 30-40 bytes was used.
If you are unfamiliar with computer memory layout, and you are interested in it, I suggest you look that up. Put bluntly when the STACK enters into the HEAP is known as a stack overflow. It was happening to me, I kept getting strange unpredictable results, because two parts of my code were accessing the same location in memory, overriding each others information. Without needing to buffer the middle ring I had freed up more than enough RAM for my code.
Step 10: Coding Creativity
Unfortunately I don't seem to be very creative when it comes to programming. I am when it comes to creating physical things, I mean I designed and created a beautiful ring covered in LEDs, however with coding I can only ever seem to be practical.
This is the code right now.
- The time is displayed by a single yellow pixel for seconds, a single green pixel for minutes and a block of 3 purple pixels for hours.
- Touch and holding the sensitive edge enters set mode,
- Sliding up and down increments or decrements the current item. (initially seconds)
- Tapping on the sensitive edge moves to the next item (seconds > minutes > hours)
- Once all the items have been set the clock returns to showing the time
This is basically the bare minimum of what a clock should be able to do. But with the setback of the inner ring not working, and all the issues I had with the resin I am more than overwhelmed to say that this project is finished.
Step 11: Mounting and Power
Obvious you'd want to show off your work at this point. But this is an electronic device, and it won't run without power. How will you power it? and how will it be mounted? on a wall? a small base?
I decided to mount it facing the wall, so the LEDs will be reflected off the wall. I hope this will give a softer glow from the ring. For power I am using very thin, 0.5mm magnet wire, or enamel wire. If the LED used too much power, wires this thin wouldn't be able to carry the required current. However with only a few segments lit the clock doesn't consume much power at all. The positive is that these wires are almost too thin to see.
Because the wires are enamel coated you will need to tin the ends of them with your soldering iron before use. I used a small proprietary 5 volt phone charger to power the clock, I removed the plug from the end and soldered on some wires. Be sure to heatshrink over exposed wires.
I used some textbooks to hold up the ring at the correct height when fixing the thin enamel power wires, finally textbooks have a use (I am kidding of course). The ring wasn't steady enough with just the wires holding it, and I was worried about potential breakage down the line, so I used some small double sided adhesive squares, These are made by scotch and won't rip of your paint when you remove them.
Step 12: Conclusion
I stated at the beginning that this would not be a step by step guide. That is because I don't want people to create what I created. Half of it isn't functioning, I'm pretty sure I'll never remove the resin smell from my shed, the back of the ring has a tonne of tiny cracks and imperfections in it, lastly the microcontroller board is wildly underpowered for creating smooth graphics on this beautiful LED ring.
But that being said, I would like people to create more LED clocks. But I don't think they should create something identical to this. I am glad there were things that failed, because you learn more when things go wrong.
Step 13: Downloads
This project is licensed under OSHW, I even put the little gear on my boards.
Here are design files for the PCB (gerbers and altium format)
Sorry I can not provide these in another format. That's just the software I used to make these boards, I used my university license. If you want to try it out, and you're a student. check if your school has it.
Please note, these files are as-is. They are exactly what I used to create this LED ring, and they may contain bugs.
The code is also provided as-is. It is written in C. There is lots of testing code. more than 50% of the code I've written isn't being used currently. But I have provided it here, if you wish to comb through it :)