March 31, 2013

LED Cube: 3x3x3 cube soldered

Last time I hinted that I finally put together the full 3x3x3 cube.

From Building LED Cube

From another perspective it is better visible that I changed the soldering process a bit from the first layer compared to the others.

From Building LED Cube

The top layer has some brownish residues on the bottom of the LEDs. These are traces of the soldering flux which burnt into the LEDs bases when I kept the soldering iron a tad too long close to them. For the other layers I left out the additional flux and also tried to keep the heating phase as short as possible on the pins. The result is that the two lower layers have clean LEDs. But two of the joints broke again and had to be fixed during the first test in the breadboard so they don't seem to be as stable. Another thing I should remember for later is that I should sand the iron wires next time before soldering. They look a bit dirty in the cube, swallow some light and probably are harder to solder that way too.

Nevertheless the finished cube allowed some cleanup of the crowded breadboard by reducing the required traces to only a single "bus" and relocating the layer control. Furthermore the "bent wire" connection for the planes (visible in the photos from last time) have been replaced by croco clip wires for a higher reliability and flexibility.

From Building LED Cube

And powering up the cube and testing all LEDs for correct functionality shows everything working as expected and its whole glory.

From Building LED Cube

The observant reader may have noticed that the circuit of the layer logic has changed since its last appearance. This is the intermediate result of many hours of playing working with my latest technical acquisition. But more on that in a later post.

As for the grid construction of the cube in general: I doubt that I could solder the big 8x8x8 in the same manner as I did the small cube. With the small one I initially soldered the three 3x3 layers individually and then put the layers together by first attaching the corner connections and then the inner leads. As I could do this by hand it just worked but in the height of 8 layers stabilizing one (unstable) 8x8 layer for soldering and keeping the distances exact is nearly impossible. So I need some sort of metal or wooden rack during soldering but I'm not sure yet how it should be constructed and used. There are some ideas floating in my head but I have to think more about those and probably test some of it.

March 26, 2013

A trapdoor in Apache Commons CollectionUtils (and its docs)

A few days ago I hit a problem while refactoring some legacy Java Code. Following my own advice to use safe and simpler library methods I changed the code-block

List<String> list = dao.getEntries(id);
if(list != null && list.size() > 1) {
  doFancyLogic(list);
}

to

List<String> list = dao.getEntries(id);
if(CollectionUtils.size(list) > 1) {
  doFancyLogic(list);
}

Should do the same, looks nicer and should be safer too, right? Imagine my confusion when suddenly several unit tests began failing at other parts of the code not directly related to this change. When I found out that this single line was the cause of the other errors I of course looked up the JavaDoc for CollectionUtils on Google. According to the docs at http://commons.apache.org/collections/apidocs/org/apache/commons/collections/CollectionUtils.html the size() method should return 0 when presented with a null collection. Things were very strange here. In fact, it took me a few days to find out what's wrong.

In fact, I did not recognize that the access to the JavaDoc was redirected to https://commons.apache.org/proper/commons-collections//apidocs/org/apache/commons/collections/CollectionUtils.html, which did not show the documentation of the latest stable CollectionUtils docs (as it did until a few weeks ago) but showed the version of the SVN tip. It took a roundtrip through the Apache Commons main page to find the correct JavaDoc page for the current stable 3.2.1 CollectionUtils at https://commons.apache.org/proper/commons-collections/javadocs/api-release/org/apache/commons/collections/CollectionUtils.html. And, surprise surprise, there the API for the size() method looks a bit different: "Throws: java.lang.IllegalArgumentException - thrown if object is not recognised or null".
Well, so much for the praised null-safety of Apache Commons... In the current implementation, CollectionUtils.size() is of no use for me and I reverted the refactoring.

In the end I was a victim of partly my own assumptions for the null-safety of Apache Commons and partly a very weird redirection of the Google search result URL. I still have no idea why this URL suddenly gets redirected to a different version than it did until a few weeks ago but I hope that either Google soon updates its search result (unlikely as there are loads of references to this address) or Apache corrects it to its former destination. For the safety of users in my opinion the correct version which shows up should be the one of the latest stable version, not an arbitrary SVN version.

Lesson learned: also check version of JavaDoc if something smells fishy, even if it has been correct in the past.

March 21, 2013

LED Cube: The case of the un-solderable iron wire

A little more than a month ago I failed soldering the iron wire for the first LED grid. At that time I didn't know what went wrong. Well, in the meantime I found out, adapted my approach and succeeded in soldering the first layer.

What went wrong? I purchased annealed iron wire instead of a plain (galvanized) one. Seems that I didn't recognize that there were two different kinds of iron wire available at the store and (of course) I picked the wrong one. Apparently solder does not stick to untreated annealed iron wire as the surface is pretty much fully oxidized so that solder doesn't stick without more aggressive solder aids like acidic solder flux. Annealing also makes the wire softer which I don't appreciate as the cube should be stable and sturdy. So the usage of plain galvanized iron wire is not only the solution to my soldering problems but also the preferrable solution anyway.

The difference of the wires is obvious once you know of the types. The annealed one is on the left:

From Building LED Cube

Using the new iron wire the first layer was soldered together quickly

From Building LED Cube

I haven't been honest in the beginning of this post. Meanwhile I not only soldered a single layer but all three layers of the 3x3x3 cube and put them together on the prototyping board. First tests in action were successful and promising. But more on that and why I doubt that I can build the 8x8x8 cube in the same procedure (horizontal layer by layer) next time.

March 3, 2013

Repurposing an ATX Power Supply

For my LED Cube Project I already hinted that I may use an old ATX power supply as repurposed power source. In the past two weeks I found some evening time to work on that subproject. The plan was to use an old ATX power supply which I had left from old computer parts and equip it with banana sockets to make the common PC voltages easily available to use for my electronic projects. This repurposing seems natural as the voltages available from PC ATX power supplies are the same which are most commonly used in hobby microelectronics (3.3V, 5V, 12V). Additionally these devices provide a high stability and current capacity as they have to offer those requirements for stable computer operations which demand extremely fast switching load capability and still let the PC rely on a stable supply.

I found several resources on the internet which explained how to refit an old ATX power supply to offer nearly stabilized Lab Power Supply capabilities. It seemed not too hard and I decided to use the information from that descriptions to add the banana sockets, status LEDs and the switch directly into the metal case of the power supply itself. From the pictures on the internet that seemed possible without much problems.

Since that is now finished and (surprisingly?) working as expected I'd like to share my experiences.

Update 2013-03-08
I did not use fuses for the power lines when modifying my PSU. In theory the PSU should turn itself of in case of shorts but there may still be the possibility for very high currents during a short period of time. It is highly advised to add properly sized (check the rated max current) fuses to each supply current line!

This was the old power supply which I could scavenge from a retired computer.

From ATX Power Supply Repurpose

From the outside it looked pretty innocent. During my preparation research I learned that ATX power supplies have some characteristics which have to be considered during modification and utilisation of the electronics.

  • altough there is a standard for ATX power supplies, some supplies do not meet certain requirements (esp. behavior in edge cases)
  • activation is pretty easy, just connect PS_ON (green) to GND
  • to provide stable voltages many power supplies require a certain minimum load
  • power supplies are not guaranteed to be short-safe
  • a signal on the PWR_OK line does not guarantee a stable power source (especially on cheap supplies)
  • stored leftover energy in the power supply can be lethal, so extreme caution is highly recommended

To find out the exact behavior of my power supply I tried out various connectins and measurements directly on the ATX connector. As the side of the supply told it was capable of up to 22 Amps on the 5V line so I've been already very careful here and checked the ATX connector layout several times to prevent accidents and violent reactions within my hands. I've been a bit nervous during that measurements that's maybe also the reason why I forgot to take photos of this. Well, I learned following from these tries:

  • PS_ON is really easy to control
  • my power supply also requires a minimum load
  • the PWROK signal works as expected
    • no PWROK without load
    • PWR_OK turns off again if load is removed later on
  • the standby lines keep their voltage quite some time after disconnecting the supply from main power, indicating a high internal capacity

Before I decided to rip open the guts of the supply, I left the box sitting unconnected for two days to be absolutely sure that I'm not suprised by some leftover charge. After two days the box was stripped naked.

From ATX Power Supply Repurpose

The open supply made me realize some additional but unexpected problems. Firstly there was much less space available for additional wires.Secondly the space on the front panel was obstructed by heatsinks. Therefore it would be a pretty limited working area and I also had to place the banana connectors between the heatsinks. Luckily at least all cables were properly colored and even correctly annotated on the PCB. So I continued and marked the locations of all additional components on the frontplate.

From ATX Power Supply Repurpose

During my tests on the breadboard I realized that load resistors (I used two 5Ohm/5W ceramic resistors in serial) get quite hot when connected to power, so I decided to not have them dangling around in the box but clamp them tightly on one of the heatsinks. Checked, that this solution also fits in the tight space with the banana connectors and wires in place and continued to the next step: drilling the holes in the front plate.

From ATX Power Supply Repurpose

I chose the size of the holes by measuring the dimensions of the banana sockets, LED covers and the switch with a caliper. After that I drilled smaller ~1mm holes to better be able to control the position during drilling and re-check the dimensions and gaps between them. During that I had to reposition the holes for GND and 12V as I did not initially take onto account the metal bridge of a hanging transformator, which I removed for the work, behind it. After that I extended each hole to its final size with the correct drill.

Quickly after beginning the first hole I saw that the case was thicker than I anticipated and much more flings built up than I expected. I was worried that these could pour into the power supply and cause unpleasant surprises when they survived the final cleaning between the contacts on the supply board. During drilling I could only make sure that the outer side of the drilling holes did not spray flings into the case so I folded up some newspaper pieces as protection and sticked them tightly on the back of the holes to catch all flings which would otherwise fall into the PSU on the inside during drilling. This worked remarkably well.

From ATX Power Supply Repurpose

After the holes were finished I began to mount the status LEDs, the power switch and the first two banana sockets.

From ATX Power Supply Repurpose

Also the load resistors were soldered together, clamped on the heatsink and, as almost everything I mounted inside the PSU, protected by maybe a bit too much shrink tubing.

From ATX Power Supply Repurpose

With the more complex wiring in place I continued with the connections to the remaining voltage sockets which should not take too much time. At least that's what I thought. In reality connecting the remaining four voltages caused much more trouble than the first part. The main problem for me was that I initially tried to always connect all available wires for a certain voltage rail to the banana socket. I failed with this target as it was very difficult to screw the wires onto the sockets in the very tight working area between the components of the PSU. Furthermore the thick pack of wires were squeezed out of the screwings when they were tightened. In the end I decided to only connect two or three cables to the sockets, clip off the rest and isolate those with shrink tubing. For the 3V3 connection one of the cables I connected was the brown 3V3_SENSE connection which is necessary for a stable 3.3V supply voltage.

Another problem was that the black shrink tubing was very difficult to get over the socket connectors when the cables were in place but with a lot of fiddling I managed to pull all of them over the sockets and properly isolate the power rails.

From ATX Power Supply Repurpose

Finally I cleaned out the PSU with a compressor and lots of air, did a thorough visual inspection of the modifications and the board, re-installed the initially removed transformer and closed the case of the PSU. The ATX bench power supply in its final beauty:

From ATX Power Supply Repurpose

After carefully plugging in the PSU and using a rubber glove to turn on main power on the backside I did a quick check if the case was free of erronous current. Then I again carefully turned on the new switch on the front, checked the safety of all metal parts once more and finally did a touch-test if it's really safe to the bare hand. Being confident that everything was OK and the LEDs correctly indicated the status I took a check of the voltage levels on the sockets with the multimeter.

From ATX Power Supply Repurpose

My multimeter showed all voltage levels to be within acceptable limits (11.7V, 5.1V, 3.4V, -5.1V, -11.4V) and without any fluctuation. I therefore consider this PSU repurposing sub-project a complete success. What's still left is to stick rubber bumpers on the bottom of the PSU and add properly printed annotations to the elements on the front instead of the pencil writing. But since I don't have any of that around that'll have to wait a few more days.

If you're interested in more images, there are many more available in the album which also show the progress in a bit more detail and from different angles. Included are also some shots of the mess on my desk during the project and an accident with a banana socket where it broke when I tried to screw it tight with too much wires.

Some resources for those who are interested (sorry, most of them are German):

March 1, 2013

Using Keywords in Firefox for fast navigation and instant search access

Just to share a small tip which over time has saved me lots (really, lots of lots) of time.

It is possible in Firefox to define a bookmark as a shortcut which can be entered in the URL bar of the browser. So for example if you often visit a certain webpage with a long or complicated URL, e.g. https://en.wikipedia.org/wiki/Star_Trek:_The_Next_Generation you most certainly add it as a browser bookmark at some point. Maybe you even put that bookmark on your favourites bar so that you only have to travel a short distance with your mouse to open the page.

A browser bookmark already saves a lot of time but there is still some more potential to speed it up and this is where URL shortcuts enter the stage. To be honest it's not only the shortcut alone but a combination of a keyboard shortcut and URL shortcut. But first things first.

To define a bookmark to be available as URL shortcut you have to enter the Firefox bookmark manager. Then navigate to the bookmark and click it. Its properties are now shown in the lower part of the window. To define an URL shortcut for it click on "More" and a line "Keyword" should appear. Whatever word you enter here is later an alias for this URL in the browser. For example you could enter "st" in the bookmark for the Star Trek URL above. From now if you just enter "st" in the browsers URL bar, https://en.wikipedia.org/wiki/Star_Trek:_The_Next_Generation is loaded.

This is fast but still not much faster than clicking a bookmark. To make it really faster you have to activate and enter the URL bar by using the keyboard shortcut CTRL-L. CTRL-L and entering "st" should now really be faster than moving the mouse if you're just a bit experienced with touch typing on a computers keyboard.

But wait, there's more!

If you have defined a keyword for a bookmark it is possible to supply parameters to this bookmark. This work by using "%s" at the portion of the URL which should be replaced by anything which you write after the URL shortcut into the URL bar.

For example if you dislike the CTRL-K keyboard shortcut to jump to Firefox' search box you could decide that you want https://www.google.com as the keyword "g". Edit this bookmark again and change the bookmarks URL to be "https://www.google.com/search?q=%s". Now you can also add the search queries to the URL shortcut/keyword on the URL bar. Entering "g star trek" should provide lots of joy to the average trekkie :)

At work my favourite URL shortcuts are defined as following:

  • ora -> http://%s.ora-code.com for quick access to explainations of Oracle error messages. Eg. entering "ora ORA-01455" leads to a good explaination of the cause of this error.
  • leo -> http://dict.leo.org/ende?search=%s translates german or english words into the respective other language.
  • wiki -> https://www.wikipedia.org/wiki/%s is a shortcut to the Wikipedia article. Most words are already directly available on wikipedia so this works 90% of the time for me.

Many webpages offer a search functionality and if you want to make this accessible in a very quick way just look how the search results page URL is composed and replace the portion of the search term whith %s for your bookmark.

Simple, fast, unbelievable effective.