The Next Project – PropClock Reboot!

Last two weeks I have been thinking about what my next project should be, and then this got me thinking about why I keep working on these projects in the first place?

Thinking back, I started most of my electronic projects because I could easily apply the things I learn and see the results firsthand. One day I get an idea, and then I really want to try and see if it would actually work. Most of my projects build up on the work I have done and the things I have learned in past projects.

Some projects like the MSYNC and the Music and Lights system surprised me by working better than I expected. Then there are a few that worked but not quite as well as I expected them to. One of those projects is the Keychain propeller clock (the PropClock). If it’s not obvious by the name what it does then this photo will explain it pretty well.

The PropClock V1 displays the time when it is spun

The PropClock V1 displays the time when it is spinning

And the actual device looks like this,

The PropClock has 7 LEDs  arranged in a row. The case is made from an excel mint can.

The PropClock has 7 LEDs arranged in a row. The case is made from an excel mint can.

Even though from the photo it looks like it is working perfectly, it has many issues. The time doesn’t always show up in the same location. Also the case tumbles when spinning so the LEDs are not guaranteed to face the same direction in every rotation. It is also bulky and heavy to carry around in a pocket. Fixing these problems requires major design changes and so it kind of fell into the bottom of the stack.

This is my original design, but not my original idea. When I was making my desktop propeller clock (pictured in the background of this webpage) I stumbled upon the website of Jussi Angesleva & Stephen Hughes, who used a PIC microcontroller in their original keychain propeller clock (called “Spin”). I used an Arduino Micro for my design without much thinking and this turned out to be a major mistake.

The Micro needs +5 V to operate fully and this means I had to include a voltage booster to increase the voltage of the rechargeable Li-Poly battery from 3.7 V to 5 V. Although smaller than a regular Arduino board, the Micro board was the major constraint for the overall size of the device. Also when not displaying time, the Micro board still consumes a significant amount of power, making this device very inefficient.

Another source of problem was the accelerometer (MMA8452Q) I used to detect the rotation speed of the device and to orient the clock display. The accelerometer output was fairly good when detecting static orientation, but when the device is spinning I had no way to see the exact output from the accelerometer. Hence I was not able to figure out how to accurately detect a rotation using the accelerometer.

By this point you may have guessed what my next project is going to be! Yes, the next project is completing the PropClock and designing it to fix all the problems I ran into last time. To make sure I don’t make the same mistake twice I will set up a proper project plan, project scope, goals requirements, tests and validation procedures and a timeline before I begin. Before getting too deep into this project I am going to write a project proposal and do a feasibility study to come up with an initial design solution.

In related news, I have successfully assembled the Attiny85 programmer board I got from ASIMOWALK5, and will be using it to do a series of tests to see if the Attiny85 would be a suitable MCU for the PropClock project.

Thanks for reading, and stay tuned for more!

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

 Algorithm3

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!

A prize from ASIMOWALK5!

In the mail today I received a prize from a giveaway contest! It is an Attiny85 Programmer and Breakout Board from ASIMOWALK5.

Attiny85 Programmer/Breakout board by ASIMOWALK5

Attiny85 Programmer & Breakout Board by ASIMOWALK5

This is a neat little board that brings out the pins of the Attiny85 with clearly identified labels. With this board an Attiny85 can be programmed easily and quickly since you don’t have to keep looking up which pins to connect to. I haven’t used Attiny’s before so I am very excited to get one and try it out. The board also has room for a power input terminal and a power indicator LED, which is very handy. More information about this board and how to use it can be found here: http://gdriv.es/attiny85board

I already have a project idea in mind for this and the tiny Attiny85 would be an ideal choice! More on that coming soon in a future post, stay tuned!

Fixing Keypad door entry – The solution

In my last post I talked about a problem I am having with an electronic keypad door entry unit. I have narrowed down the problem to the keypad interface, which is either worn out or in some other way not doing its job. The conductive traces in the keypad interface is laminated, making it very difficult to fix any broken traces.

So I decided to create my own keypad for this unit with a solid PCB and real push buttons. In making this PCB, the biggest challenge I am facing is reducing the overall height of the keypad so that it will neatly fit inside the original housing. To achieve a thickness close to the thickness of the original keypad I have made two design choices,

  1. Use surface mount push buttons instead of through hole push buttons.
  2. Remove the spacers from the original keypad membrane, which will go on top of the new PCB.

Instead of buying surface mount push buttons I decided to modify a bunch of through hole push buttons I already had. Converting the push buttons from through hole to surface mount was easy with a needle nose plier and a wire cutter. Afterwards, I took measurements of a transformed push button and made a footprint for it in KiCad.

Push buttons transformed from through hole to surface mount

Push buttons transformed from through hole to surface mount

The surface mount push buttons have a thickness of 3 mm, which is 1 mm shorter than the thickness of the buttons on the original keypad membrane. This means the push buttons should be able to fit inside the membrane buttons. However, I will have to carve out the insides of the membrane buttons to get the push buttons inside.

Spacers of the original keypad membrane, which will be removed in the new keypad to make room for the PCB

The membrane has spacers around it to fit the original keypad tightly inside the housing. With the spacers, the thickness of the original keypad (without the buttons) is 4 mm. With the spacers removed, the thickness of the PCB (without the buttons) with the membrane placed on top is 3 mm. This means that the new keypad should fit easily inside the housing.

Having figured out all the details I set out to make the PCB. First I made a simple schematic for the button connections in KiCad, followed by the layout. Since I will be using surface mount push buttons, I kept the components and traces all on the top layer.

Layout of the new keypad

Layout of the new keypad

The layout is very similar to the layout of the laminated traces of the original keypad, except I avoided a via since I didn’t want to go into a second layer. Three hours of work developing, etching, drilling and trimming later I had the PCB ready for soldering.

The new keypad PCB is ready to solder

The new keypad PCB is ready for soldering

Although I have had a bit of practice soldering  surface mount components before, this is my first time trying it on one of my own PCBs. I have stayed away from surface mount components before mostly because I didn’t have a soldering iron designed for surface mount devices. Also I didn’t have flux, which is the secret sauce to soldering SMT components properly.

I still don’t have these equipment, but decided to give it a go anyway since I didn’t really have a choice but to use surface mount push buttons. One of the biggest difficulties with soldering SMT components is holding it in place while trying to solder since you only have two hands to hold the soldering iron, solder and the component! Yes, I did consider melting the solder on the iron first and then bringing it to the component pad, but in the time it takes to do that, the flux inside the solder smokes away making it very difficult to make a good connection.

Thankfully, I had bought this PCB holder with alligator clips and it did a really good job of holding the push buttons in place while I soldered.

The alligator clip holding the push button in place while soldering

The alligator clip holding the push button in place while soldering

As it turned out soldering the surface mount push buttons wasn’t too bad. I found this more satisfying than soldering through hole. The solder did spread a little bit along the track since I don’t have a solder mask on my home made PCB.

The push buttons neatly fit inside the housing where the holes for the buttons are located

The push buttons fit inside the housing where the holes for the buttons are located

The next step is to solder a connector from the keypad PCB to the control PCB, where the processor is located. For the connecting wire I chose an old ribbon wire I found in my  collection of scrap wire, which had six wires – exactly what I needed! I soldered a female header to one end and soldered the other end to the keypad PCB.

Ribbon wire that connects the keypad PCB to the header of the main control PCB

Ribbon wire that connects the keypad PCB to the header of the main control PCB

After soldering all the components it was time to test the device. As expected it worked without any issues and with that satisfying feel of a real button press.

The final step is to put everything back inside the housing. In order to fit the membrane of the original keypad on top of the new keypad push buttons the insides of the membrane buttons need to be carved out. However, this task turned out to be rather difficult since the membrane buttons are strechy and didn’t flake off very easily.

After a few unsuccessful attempts, I managed to poke through one of the buttons with an X-Acto knife, partly removing it from the membrane. And then I had the idea to remove the membrane buttons from the membrane and then glue it on top of the push buttons. Removing the membrane buttons from the membrane was easy since the buttons were connected to the rest of the membrane with a very thin layer.

So I placed the new keypad PCB inside the housing using the rest of the membrane (without the buttons) and white electrical tape to insulate the traces from the metal housing.

The new keypad for the door entry unit installed

The new keypad for the door entry unit installed

My attempts to attach the membrane buttons on top of the push buttons were fruitless. I tried several different types of super glue and even double tape, but nothing would make the membrane stick to anything! May be it needs some special type of glue to make it stick, but at this point it is not worth it to try and find it.

After all the new keypad works better than the original, which is the main problem I set out to fix. Sure the buttons aren’t labeled, but that will make it that much harder for burglars to try to figure out the correct password.

How reliable is this new keypad? Only time will tell. But for now, it is fixed!

 

Fixing Keypad door entry – The problem

Last year I installed a keypad door entry unit in the back door of our house so we don’t always have to stumble for keys to get inside. This was really handy since my brothers tend to misplace their keys often or leave them at home.

The keypad door entry unit

The keypad door entry unit

It worked great but now some of the buttons have stopped working, and some of the buttons don’t always work, which means getting inside the house is not always guaranteed. Great to keep potential thieves away but not great when you have to wait outside until someone with the keys shows up.

So I took it apart the other day to see if I could easily fix this problem. The keypad has a rubbery membrane type surface on the top with six buttons. Underneath this membrane there are a series of conductive traces which are laminated. Underneath each button of the membrane, two of these traces interlace, but without making contact as in the image below. On top of the region, where the two tracks interlace, there is a round conductive pad. When the button is pressed, the round conductive pad makes contact with the two traces acting like a momentary push button switch.

Underneath the key pad membrane is a set of laminated conductive traces

Underneath the key pad membrane is a set of laminated conductive traces

Altogether there are six traces, which connect to a PCB header through a laminated ribbon. On the PCB there is a MSP430F2111 microcontroller that does all the processing of the keypad input. The specialty of MSP430F2111 is that it is optimized to achieve an extended battery life. This makes sense why they decided to use it on this device.

Inside the housing there is a DC motor, which moves the deadbolt to lock or unlock the door when the correct password is entered on the keypad.

The dead bolt is turned by a DC motor

The dead bolt is turned by a DC motor

Being optimistic, I assumed that the PCB is still functioning properly and that the problem is in the keypad. To test this I briefly shorted two pins of the header where the keypad connects to the PCB, simulating a button press on the keypad. a “beep” from the piezo buzzer indicated that the button press event was successfully registered by the MCU. This could mean a few possible scenarios:

  1. The keypad button doesn’t make full contact with the two traces when pressed
  2. The conductive pad underneath the button gets stuck on the two traces when pressed and doesn’t get released when the button is released
  3. The traces are damaged or worn out

Either way, this is a very bad design and one that cannot be easily fixed, since all the traces are laminated. However, I don’t want to throw this away nor buy a new one and have to deal with the same problem a few months later. So I am going to make my own keypad interface for this unit with REAL push buttons.

So the first thing I did is to figure out which traces belong to which buttons on the original pad.

KeypadTraces

 

 

 

 

 

You may have noticed in the table above that trace 6 doesn’t connect to any of the buttons. In fact, trace 6 surrounds all other traces in the laminate and acts as a shield. This prevents accidental button presses due to electrostatic discharge (ESD).

Now I have all the information needed to make a functioning key pad interface to this device. All I need is six momentary push buttons wired to the six traces according to the table above.  Sounds like a very simple fix. However, I also need to make sure that it fits inside the housing and looks as close as possible to the original. This means I have to place the push buttons exactly where the keypad buttons are located – sounds like another PCB!

Taking measurements of the keypad housing to figure out the exact locations, where the push buttons need to go

Taking measurements of the keypad housing to figure out the exact locations, where the push buttons need to go

So the next step is to get measurements and figure out the exact locations of the buttons with respect to the housing. Once the measurements are taken I can design the PCB in KiCAD. To get the measurements, I removed the housing from the unit and drew the outline of it on a sheet of paper, and then measured the distances with a ruler.

The laminate and the keypad membrane together have a height of about 2 mm, which is slightly larger than the thickness of the pre-sensitized boards I am using to make PCBs (1.58 mm). However, with the push buttons, the height of the PCB will be much larger than the original keypad. Also I am planing to use the existing keypad membrane on top of the PCB. This will make it difficult to get everything inside the housing.

So I will have to take measures to reduce the overall height of the PCB. This means I have no choice but to use surface mount push buttons. This is going to be very interesting as I have never used SMT components in my PCBs before. Also I will trim the vertical spacers off of the keypad membrane. I am hoping that this will bring the height down closer to the height of the original keypad.

Hopefully by my next post I will have figured out which push buttons I am going to use and the layout of the PCB. Stay tuned and 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!

PCB making at home – Etching

This post continues from my previous post, where I developed the Music and Lights PCB using the UV exposure method. Once an etch resistant image of the layout is successfully placed on the Copper board it is time to do the etching. Etching is the process of removing unwanted Copper from a Copper clad board.

Ferric Chloride used for etching

Ferric Chloride used for etching

 

The etching solution I am using is called Ferric Chloride, a corrosive chemical that will dissolve exposed Cu and pretty much any metal. It also leaves a stain on pretty much anything it touches. When working with Ferric Chloride, it is very important to be in an area with good ventilation as it tends to produce a strong fume (specially when you just open the bottle or container used to store it)

Compared to the photoresist developing process, the etching process is slow. The amount of time taken to etch the board depends on the board size, temperature, amount of etchant and circulation. I finished etching my board in about 40 minutes.

And these are the steps, continuing from the previous post

Warning: Ferric Chloride is corrosive. Wear safety gloves when handling. Work in a well ventilated area.

Step 20: Pick a plastic container and place the Cu board with the etch resistant layout image inside.

Step 21: Pour Ferric chloride into the container until the board is completely covered. Do not dilute with water.

Fill the plastic container with Ferric Chloride until the board inside is completely covered

Fill the plastic container with Ferric Chloride until the board inside is completely covered

Step 22: To increase the etching rate agitate the solution every few minutes by tilting the container back and forth.  Examine the board and flip the board every 5 minutes for the first 20 minutes or so.

The exposed Cu will start to disappear from the edges first. When the exposed Cu has disappeared from about half of the board start monitoring the process more frequently. If left for too long in the etching solution it will start eating through the etch resist as well.

Step 23: When exposed Cu from both sides of the boards is etched away remove the board from the container and rinse with plenty of cold running tap water. Dry the board with tissue or soft cloth.

 

The back side of the PCB after etching

The back side of the PCB after etching. Notice on the right side how the etchant has started to eat away through the etch resist. This side was slightly overexposed during the development process.

As you may notice in the image above, the right side of the bottom PCB layout got a bit eaten away by the etchant. This is because this side was over exposed during the photo development process. Fortunately it is not too bad as the affected area is mostly the ground plane. However, I will have to take extra care when soldering components to ensure that good connections are made.

Top side of the board after etching

Top side of the board after etching. Notice how the top side component pads line up perfectly with the bottom side component pads

Step 24: Use tissue paper and nail polish remover to wipe off photoresist from the board and expose the Copper.

Use nail polish remover to wipe away photo resist to expose the Cu after etching

Use nail polish remover to wipe away photo resist to expose the Cu after etching

Step 25: If necessary, trim the edges of the board with a fretsaw.

If necessary, trim the edges of the board with a fretsaw

If necessary, trim the edges of the board with a fretsaw

Step 26: If you have through-hole components, drill the holes with a PCB drill.

Tip: I used a 1 mm drill bit for larger components like switches and power connector, and a 0.8 mm drill bit for other components.

Drill component holes with a PCB drill. I used 1mm and 0.8mm drill bits

Drill component holes with a PCB drill. I used 1mm and 0.8mm drill bits

That’s it! Now in my hands I have a home made PCB for the Music and Lights system.

Now you might be wondering why in the world go through all that trouble to make your own PCB at home when you can get a better one manufactured professionally. I totally agree that it makes more sense nowadays to get your PCB manufactured, plus you will have a solder mask and a nice silk screen too. But making your PCB at home is fun, and you get to control and see the whole process. It is a path with many challenges and finding ways to overcome them is the best part.

Now to the final note about making PCBs at home,

What to do with all the chemicals when you are done with them

You shouldn’t dump used chemicals down the drain, nor flush it down the toilet nor throw in the dumpster. They will destroy your plumbing and could do terrible damage to the ground water and environment.

Safe and easy way to dispose of them is to contact your local hazardous waste disposal company. I store my used Ferric Chloride and photo developer solution in plastic containers, usually the ones they came in, until a sizable portion is ready for disposal.