Thursday, October 19, 2006

LED Christmas Lights

LED Christmas Lights

Recently I bought a set of LED Christmas lights from All Electronics:



These lights are sold as-is because the controlling units overheats. So why buy a known-defective set of Christmas lights? To fix them, of course! These lights are controlled by a programmable chip called a PIC. Careful programming can significantly reduce the power consumption, and fix the heat problem.

What is a PIC?

A PIC is essentially a one-chip computer designed for embedded systems. You can't play video games on it, or even run Windows. It's made to run very simple tasks. A typical PIC only has a few hundred bytes of RAM.

Replacement PIC

The PIC that comes with the LED lights is a write-once device. It can't be modified. Fortunately there are a number of programmable replacements. I choose the PIC16F627a, mostly because I already had several on hand. They're available at mouser.com. for about $1.75.

Original: PIC16C54 (CF745)

New: PIC16F627a


Tools

Writing code into a PIC requires a programmer. Removing the original PIC part requires a soldering iron, and a solder sucker (remover).

Warp 13 PIC Programmer

Soldering Iron

Solder Sucker


Adding a Socket

The LED controller comes with a 18-pin DIP (through-hole) PIC soldered directly into the PC board:


To ease development it is best to remove the original part, and install a socket:


Desolder PIC

PIC chip removed

Socket


Hardware Programming Model

Eight bits (signals) are used to control LED illumination. Four bits are used to select each LED color (red, yellow, orange, and green). Four bits are used to select a bar or arm of the star (e.g. all LEDs on the horizontal axis correspond to bar 3):

An LED will illuminate if both of its bar and, color are selected. Thus, selecting red, and bar 1 will light the two LEDs on the vertical axis:


The following diagram shows the control signal to PIC mappings:

Software

Originally I had hoped to read the software from the original PIC, and then modify it for my purposes. But the PIC16C54 is an unusual part, and my programmer can't read it. So I decided to write everything from scratch.

Pulse Width Modulation

This code uses one of the PICs timers to create pulse width modulated signals. To prevent the unit from overheating the power consumption must significantly reduced. A common trick to reduce the brightness of an LED is pulse width modulation (PWM). Basically this means turning the LED on and off very rapidly -- so quickly it is undetectible to the naked eye.

The brightness, and power consumption are adjusted by changing the duty cycle (percentage of time spent on).

Algorithm

Here's a highly simplified version of the code, written in 'C':

Source Code

Here's the real assembly code:

Conclusions

The power reduction was a success. The lights used to draw a maximum of about 1.8 amps; now it's down to about 430 milliamps. It doesn't get warm even after hours of operation.

Writting display patterns is pretty easy. But because of the limitations in the hardware, there just aren't that many interesting designs you can create.

Here's a video of the lights in action (4MB):

xmas.avi

Thursday, September 28, 2006

Making Sushi

Sushi Chef Neophyte


Making good sushi is no trivial matter. People study for years to become master sushi chefs. And my particular style can best be described as survival cooking. However, making sushi is 50% arts, and crafts. And for some sick reason I enjoy doing meticulous, detailed work. Still, I expected my sushi to look like it was " hacked to death by a blind woodsman."

Tools

Making sushi doesn't require too many exotic tools:




Bamboo mat (makisu)





Sharp knife





Rice cooker


The one key item is the bamboo mat (makisu); it helps keep the rolls even.


Real sushi chefs use special knives, which are only sharpened on one side. My personal opinion is that any sharp knife will work.

Ingredients


California rolls are usually made with avocado, and fake crab. I use smoked salmon mostly because it keeps for weeks in the refrigerator.




Smoked salmon





Avocado





Nori (seaweed)





Sushi vinegar





Black sesame


The salmon, and the avocado need to be sliced into thin strips:




Sliced ingredients



Rice


The preparation of sushi rice is more complex than most people imagine. Traditionally the rice is soaked in water to soften it, then cooked with a piece of seaweed (for flavor). A mixture of vinegar, salt, and sugar is poured over the hot cooked rice, and then fanned until shinny and cool. Experts use a bowl made of bamboo. I use an 13x9 baking pan and an electric fan.




Adding seasoning





Finished rice

Making Sushi


California roll are usually made "inside out" -- that is the nori (seaweed) is on the inside, and the rice, on the outside. Here's how it's done:




Spread rice on nori





Cover rice with plasic wrap





Flip over






Add salmon, and avocado





Roll it up





Add sesame seeds

Finished Sushi




Sushi

Saturday, February 4, 2006

Triops

What are Triops?

Triops are essentially prehistoric shrimp. They haven't changed in about 200 million years.The bigger ones grow to about 2 inches. Average life span is about a month.



Triops


Why raise Triops?

In my case, because they showed up in my cube at work. Our admin, Elena, decided to buy the engineering staff some Christmas gifts from thinkgeek.com. I got a minature monsters kit.



Front of box




Back of box




Estatic Dean


It seemed pretty silly until I started reading about them online. They have three eyes. There are no females, only males, and hermaphrodites. Native Americans of the southwest considered Triops food. One interesting fact that was carefully omitted from the box is that Triops are cannibals. Apparently it is very common for the biggest Triop in the bowl to eat all of its smaller companions. I'm not saying this is a reason to raise Triops, but if you do don't bother naming the smaller ones :)

Just Like Sea Monkeys

The way Triops are sold reminded me of Sea Monkeys. i.e. brine shrimp eggs, packaged in a bright box, and marketed at kids. I had some myself. In the ads the Sea Monkeys wear lipstick, live in castles, and play leapfrog:



Sea Monkey Ad




Sea Monkey Ad




Sea Monkey Calendar




Sea Monkey Package


But in reality they look like this:


My Sea Monkeys experiment predictably ended with a burial at sea. Later I found out you can buy them by the thousands at any tropical fish store -- not as pet, but as fish food.

Day 1


In goes the nutrient pack, gravel, and triop eggs.




Adding gravel




Adding eggs


Day 2


It's alive! Several triops have hatched. They're very small, and
difficult to see:



Triops


Day 7

Five triops are still alive. These things grow at an amazing rate. After less than a week, the largest Triop is about a 1/4 inch.




Triops




Molted skin




Triops


Day 9

No cannibalism so far, but I'm keeping them intentionally overfed. There was talk of starting a dead pool. Basically everybody would choose a triop, and the last man standing (swimming?) would win. But we were stopped by common decency -- that and they all look alike.




Triops




Triops


Day 12


Still five triops. No cannibalism, but I've observed fighting on more than one occasion. If these things really grow to 2 inches, the tank is definitely too small.

One of the Triops appears to have eggs:




Pregnant Triops


Day 14


Here's some more observations on the triops:

  • Triops only have two normal (compond) eyes. The third, which looks more like a blemish, is a nauplius (simple) eye; it's used to determine which way is up!
  • Triops move randomly, aimlessly, almost blindly.
  • The biggest triop keeps picking fights.
  • Some triops dig in the gravel.
  • The triop food smells.
  • The water fouls very quickly, and smells -- even with frequent water changes.


Day 18 (Cannibalism)

And then there were three. When I returned to work on Monday two of the Triops had disappeared. Carefull inspection of the tank revealed this partially eaten body:




Triops


I guess 48 hours with no food in a cramped tank was too much. I'm just glad I wasn't around to witness the carnage. Even though this is expected behavior, I find this very disturbing. I've never had pets that eat each other.

Day 19 (A New Home)

In an effort to reduce cannibalism, I've moved the Triops into my old 10-gallon aquarium. The power filter keeps the water pretty clean so I can over feed them a bit without fouling the water. The extra space, and terrain should give the smaller Triops a place to hide.




New Home




Triops


Day 27


One Triop died while I was away skiing. I'm told it died of natural causes (no signs of cannibalism). Elena couldn't bear to discard the body, so she placed it in a plastic bag and tossed it in the freezer!




Frozen Triop


I suppose this could be useful if we ever want to perform an autopsy. Or cryogenic supsension. In the future, when medical science has sufficiently advanced, we could revive the Triop. ... Hey, if it's good enough for Ted Williams' head ...

Day 41

The largest Triop passed away. At 41 days old, it was officially a senior citizen. Here's a photo the day before it died:




Triop


Here's its final remains:




Dead Triop


Day 43 (The End)


The last Triop died. 43 days is a good long life for Triop, but it's still sad to see them pass on.




Dead Triop


Day 46 (A New Beginning)

Much to my supprise, I found a baby Triop swimming around the aquarium. Based on its size, it appears to be about a week old.




Baby Triop


Triop eggs typically require a wet-dry cycle. They won't hatch until they've been completely dry for a couple of weeks. This is a survival adaptation; the Triops natural habitat is transient pools of water, which are created by seasonal rains. Waiting for a wet-dry cycle ensures a freshly refilled pool. Some eggs require multiple wet-dry cycles. However, a few eggs do hatch immediately.