First Gyro’clock board assembled!

Since I have finished building my home made reflow oven, now I can use it to assemble parts in the Gyro’clock boards.

The first step is to ensure that I have all the parts for the board. Since ideally you would only want to reflow the board once. I organized this in my project book as shown below. This makes it easier to find all the parts when it is time to place them on the board. Also the parts will not get mixed up! (The 0.1 uF, 22 pF and 4.7 uF caps all look the same!)


Making sure all the surface mount parts I need for the board are there before starting

Then I realized that I am missing a key component: 3.3 V Zener diode. Ordering just a single part from Digikey is quite expensive and I will have to postpone the board assembly yet again. Luckily I had a through hole 3.3 V Zener in my parts inventory. So I made a choice to do the reflow without the Zener, and then afterwards solder in the through hole Zener to the surface mount pads.

The next step is to put solder paste on the pads. I am using Chip Quick no clean lead free solder paste (SMD291SNL-ND). The solder paste came with a syringe and a nozzle. Ideally to put solder paste on a board you have to make a stencil first. Getting a professionally made stencil for a board can be quite expensive. So I decided to do it the hard way by putting solder paste manually on the pads using the syringe.

I had no idea how difficult it is to put solder paste onto a pad with a syringe. The paste didn’t really stick at all. You have to make sure not to put too much solder paste on a pad. If you do then you run the risk of making solder bridges. Too little solder paste and it won’t make a good connection. Having never done this before, I had a high risk of making one of or both of those two errors. Solder bridges on pins can easily be corrected later so I wasn’t too worried except for two components: The ADXL345 accelerometer and the HSMF-C165 bi-color LED. All the pads of these chips are located underneath the component. I only had one chance to get it right with these two.

With care and patience I put solder paste on all of the surface mount pads.


Solder paste applied to surface mount pads on the board

Once solder paste is applied to the pads it is time to place the components on the board. I must say this part is quite fun. Specially putting the resistors and capacitors. Once placed on the pads the solder paste holds the component in its place. The ATmega328p took a little aligning and the ADXL needed quite a bit of nudging to get it in place. Once all the components are placed on the correct pads (also in their correct orientations; watch out for those polarized caps!)


Once all the components are placed on the pads the board is ready for the reflow oven

Once all the components are placed in the pads I put the board carefully in the reflow oven and ran a previously prepared custom reflow profile. After about 10 minutes the board was ready to be taken out of the oven.


Gyro’clock board out of the reflow oven

Initial inspection showed that there were no solder bridges! All the resistors and capacitors showed solid connections with their pads. The only issue was the 3PDT switch, and this could have been totally avoided. The heat caused the plastic parts of the switch to melt. The switch was unusable.

So I removed the switch and manually soldered in another one in its place. After that I soldered in the Zener diode, the seven square LEDs that go on the edge, and the 150 mAh liPo battery. And then the moment of truth; Did the accelerometer and the bi-color LED make it? Did all the parts survived the heat inside the reflow oven?

They did! I was able to upload the bootloader to the ATmega328p and program it. The bi-color LED was working, which also meant that the LiPo battery charge circuit was also working.


A fully assembled Gyro’clock board (left) next to a bear Gyro’clock board (right)

I am very happy that the first try on my home made reflow oven was a success. The next step for the Gyro’clock project is to make a case for it. That is another completely new avenue for me to explore. Until next time!

Reflow Oven Build – Part 2

In Reflow oven build – part 1 I showed how I modified a simple toaster oven to function as a reflow oven. In this part I will explain the reflow oven controller. The purpose of the reflow oven controller is to control the temperature inside the oven to follow a standard reflow temperature profile. The controller must have the ability to do the following tasks:

  1. Be able to turn on and off the heating elements of the oven
  2. Measure the temperature inside the oven
  3. Ability to modify the existing profile or upload a new reflow temperature profile
  4. Report current status and temperature data from the reflow oven to a user interface (the user interface will be covered in part 3)

This job is made for a microcontroller. For my reflow oven I am using an Arduino Micro. The diagram below shows the schematic of the controller:

Schematic of the reflow oven controller

Schematic of the reflow oven controller

I assembled the circuit inside a small first aid case, and made two openings on the side to connect a USB cable to the Micro and a +12 V adapter to power the CPU fan of the reflow oven. On the opposite side I made another hole to run the wires that connect to the reflow oven (thermocouple, GND, +12 V for fan, and signal to solid state relay).

The controller circuit assembled in a small box

The controller circuit assembled inside a small box

The reflow oven and the controller

The reflow oven and the controller

The next thing to do is to write code for the controller. Inside the controller a reflow profile is stored as time-temperature value pairs. These are target temperature values that need to be achieved at the specified times after starting a profile. The controller has only a single reflow profile at a time. A new profile can be uploaded to the controller using a separate program on a computer (reflow oven manager), which will be discussed in part 3. The controller also sends profile status and temperature data to the reflow oven manager so that it can be monitored in real time. The following flow chart shows the basic structure of the program that controls the reflow oven:

Basic flow chart of the reflow oven controller program

Basic flow chart of the reflow oven controller program

A complete program listing for the controller can be found here. On the next post I will discuss the reflow oven manager program that talks to the controller.

Playing with Music and Lights

Yesterday I was experimenting with my Music and Lights system and trying out different algorithms to sync lights to Music. For this purpose I had integrated a ATmega328p microcontroller (MCU) when I designed the Music and Lights PCB.

Three of the MCU analog input pins are connected to the outputs of the bass, mid and treble filters. This allows the MCU to read the bass, mid and treble levels of the audio signal at any instance of time. The MCU can then process the inputs and drive the RGB strip according to a pre-programmed algorithm.

To program the MCU in-system, I have included a 5-pin header on the PCB, which connects to the respective programming pins of the MCU.  If you want to know the details this is a good tutorial that explains how to upload a program to a stand-alone ATmega328p.

The ATmega328p on board the Music and Lights PCB can be programmed via the 5-pin programming header, which connects to an Arduino board

The ATmega328p on board the Music and Lights PCB can be programmed via the 5-pin programming header, which connects to an Arduino board

Calibrating the bass, mid and treble filter outputs

Before experimenting with algorithms, I calibrated the bass, mid and treble filters to the same level. There are three pots on the PCB that can be used to adjust the input audio level to the three filters. The filters are of type multiple feedback active bandpass filter, which has a very narrow pass band. The center frequencies are 224 Hz, 1057 Hz and 3202 Hz for bass, mid and treble respectively. Please read my previous post if you want to know how these types of filters are constructed.

I used this handy online tone generator tool to generate an audio signal with the center frequency for each of the filters. Then with the pots turned to maximum input signal, I read the output value of each of the filters using the RGB strip with the number of lit LEDs proportional to the signal level. The number of lit LEDs was 15, 13 and 11 for bass, mid and treble filters respectively. Since the treble filter had the smallest output signal level I adjusted the pots for the bass and mid filters to the level of the treble filter.

Now with all the filters calibrated, I set out to experiment! So far I came up with three algorithms that I liked. Let’s see them in action first and then I’ll explain the algorithms.

Algorithm 1

This algorithm is very similar to the one I had originally, but with only three colours instead of the full RGB spectrum. The audio levels are sampled every 50 ms. It then compares the bass, mid and treble levels and selects the LED colour depending on the largest value; Red if bass, green if mid or blue if treble. The number of LEDs lit is proportional to the signal level.

I like this better than having the full RGB spectrum since it is easy to see whether the bass, mid or the treble is the largest.

Algorithm 2

Very similar to Algorithm 1 except the zeroth LED is at the center of the strip. The bass level is indicated on the right side (red) while the treble level is indicated on the left side (blue). The mid level is indicated on the center (green). Again the sample rate is set to 50 ms, and for each sample only the largest level is displayed.

Algorithm 3

This one is my favourite so far. It is more smoother and eye pleasing than the previous two. To make this happen I created two virtual shift registers of size 16 bits (or an int) each; one for the LEDs on the right side of the strip and the other for the LEDs on the left side of the strip. The bits in the shift registers determine whether a particular LED is supposed to be on or off in each cycle.

How this works is better explained with the actual code, and here it is


These are a few examples that showcase the capabilities of the Music and Lights system. My idea with this project is to develop a system that can sync lights to music in real time, but one that performs better than a simple light organ.  I will continue to experiment  and improve it with new and more complex algorithms until I run out of memory of the MCU, and an upgrade becomes necessary.

Thanks for reading!

Music and Lights – the PCB!

After that fun-but-this-is-too-much-work making of the PCB, and over 200 solder joints later, I am finally done with the construction phase of the Music and Lights system.

Music and Lights PCB assembled.

Music and Lights PCB assembled.

One difficulty I had with soldering components on to this board is that certain components like the screw terminals and the audio connector could not be made flush with the PCB surface. This is because in order to solder the pins I had to reach in between the component and the board surface with the soldering iron. So when you look at the board from certain angles you can see the gaps, and it doesn’t look that neat. Next time I will make sure to put the traces for these components on the bottom side so they can be easily soldered.

I put all of the components on the top side of the PCB except for the LM1875 audio amplifiers, which were placed on the bottom side, so that I can heat sink them directly to the ground plane and avoid those bulky heat sinks.

The LM1875 audio amplifiers were placed on the bottom side of the PCB so that they can be heat sunk directly to the ground plane.

The LM1875 audio amplifiers were placed on the bottom side of the PCB so that they can be heat sunk directly to the ground plane.

The next step is to test it and see if all that hard work in designing and making the PCB has payed off. First I decided to try just the Speakers with no lights. The first time you power up a circuit board is always both exciting and dreadful. So it turned out that one of the speakers worked, and one of them didn’t.

Now it’s time to troubleshoot. First thing I did is to check if the amplifier for the speaker that didn’t work has power. Turned out that it didn’t, and this is good news. Close inspection of the solder joints of the amplifier found that I had forgotten to solder the power pin. Thankfully it is an easy fix. After soldering the power pin, both speakers are now happily working.

So far so good. What about the lights? After connecting the RGB strip to the PCB I turned on the lights switch and there was…. no flashing lights. Time to troubleshoot again. As before, I checked to make sure that power is available to all the components of the RGB driver portion of the circuit. This includes the RGB strip, the ATmega328p and the active filters. All the components had power. This means I have to dig a bit deeper to find the problem.

I decided to re-program the ATmega328p first. Surprise surprise! After re-programming the MCU the lights started flashing. Most likely what happened was that sometime in between removing the MCU from the breadboard and putting it on the PCB and soldering it, the program on the chip got corrupted. This could be due to ESD since I didn’t take any protective measures for ESD.

The best part however, is that now there is none of the interference that I observed before when the setup was on the breadboard. The audio is crystal clear even when the RGB strip is running. This means that the interference observed before is due to imperfections of the breadboard. Good layout technique and having a ground plane eliminated the interference problem.

Finally, let’s enjoy a show to celebrate this

So what’s next? This project is not done yet. One of the reasons I build this is to have a platform where I can test and implement different ways of syncing lights to music. So I will be trying out different algorithms and doing a bit of programming for the next little while to get the maximum use out of the Music and Lights system. And I will keep you up to date on that as well. Stay tuned and Thanks for reading!

Music and Lights – RGB strip driver

First of all, I made some changes to my project objectives. The music and lights system I am building will not be attached to my bicycle. This is because I don’t think it will be used that often if it is just on my bicycle. So instead I am gonna set it up on my room, so that I can make the most out of it.

So far I have build an amplifier for the speakers and a triple channel audio filter for the lights (see previous posts). The next step is to read the output values of the triple channel audio filter and drive the TM1809 RGB strip to represent those values. For this I am using an Arduino. I have several Arduino boards hanging around and they are great for when you need to write a simple program to read sensor data and do something with it. Also there is a fantastic library for Arduino called FastLED that makes driving LED strips a breeze.

So I wrote a simple program to read the output values of the triple channel filter and drive the RGB strip with the red, green and blue values representing bass, mid and treble levels.

   Purpose: Read three analog values and drive a TM1809 RGB strip with the red,
   green and blue levels representing the analog values. 

   @author Kasun Somaratne
   @version 1 06/07/14

#include <stdio.h>
#include <FastLED.h>

#define NUM_LEDS      30
#define DATA_PIN       7
#define BASS_PIN      A0
#define MID_PIN       A1
#define TREBLE_PIN    A2

//create an array of RGB values for the number of leds on the strip.

void setup()
  //Specify the led strip type and the data pin used to send data to the led strip
  FastLED.addLeds<TM1809, DATA_PIN>(leds, NUM_LEDS);

  //Initially turn all leds off
  for(int i = 0; i < sizeof(CRGB); i++)
     leds[i] = CRGB(0,0,0);

void loop()
  // read the bass, mid and treble values. These values will be between 0-1023.
  int bass = analogRead(BASS_PIN);
  int mid = analogRead(MID_PIN);
  int treble = analogRead(TREBLE_PIN);

  //calculate the number of LEDs to be lit using the bass value
  int litLEDCount = map(bass, 0, 1023, 0, NUM_LEDS);

  //map the bass, mid and treble values to red, green and blue values. The rgb values can only be from 0-255
  int rVal = map(bass, 0, 1023, 0, 255);
  int gVal = map(mid, 0, 1023, 0, 255);
  int bVal = map(treble, 0, 1023, 0, 255);

  //turn off all the LEDs on the array
  //update the LED strip with calculated red, green and blue values
  for(int i = 0; i < litLEDCount; i++)
    leds[i] = CRGB(bVal,rVal,gVal);
  //display the LEDs;


Finally, It is time to test the entire setup. Here’s a short video showing how it looks at the moment:

Not bad for the first try, right? However, it has several issues:

  1. There is a high frequency noise that seems to be proportional to how many LEDs are lit on the strip.
  2. There is a low frequency noise (~25Hz) whenever the Arduino board is connected to the system.

Next step is to identify the sources of these noises and eliminate them. But so far I am satisfied with the progress.