ElectronicsNerd.com

Misc. Projects
Laundry Timer

No, no, this is nothing to be worn around your neck; it's not an art project, it's a laundry timer! If you choose to disregard my advice, you may find yourself and your project dragged to the nearest expanse of barren ground and incinerated, and I won't have anything to say about it to help you.

For a long time I've used this project's predecessor to time Wash and Dry cycles instead of pressing about six buttons on my microwave oven, but I was never crazy about the LCD. For one, I couldn't read it across the room, and for two, if I had to wire up a parallel LCD I might as well go the distance and put a sweet LED 7-segment display into action. There are a lot of resources out there for using a several-digit display, and I chose the MAX7219, knowing that if I used the PIC16F876A I would have plenty of pins to communicate with this controller, as well as fire off some blinkies and a buzzer.

So the idea is when I press the Wash button, the thing wakes up and goes "chirrrrp-Chirrrp!" and begins counting down. An RGB LED goes blue. At the end of the cycle, I am awakened by a "Beeeeeeeeeeeeep" and the LED goes green. Guess what color it turns when I'm in the Dry cycle? Yep, another cheerful cricket noise sounds and it goes to red, counting down the 50 minutes it takes to dry my clothes. A reset button is provided for resetting the timer to 0000 and turning the light green again, and the program awaits the pressing of either Cycle button.

It's no great shakes, but I consider it a successful device because it is completely custom. I wanted it to do things a certain way, and I poked the parts into the breadboard and wrote the code so it would do things just that way. Why do people buy egg timers? Because an egg takes an odd little slice of time to cook, and a custom timer is a useful thing. Recently I read a Nuts & Volts article about a custom timer that used a whole honkin' AVR protoboard, and cringed at so expensive an approach to such a simple app.

I will say this, if you ignore the advice given in the first paragraph and wear this to an airport, you will only be out about $20 but you can count on a lengthy afternoon learning the reasons Jack Bauer and "24"-style electronics are best left in TV land. The most expensive component is the MAX7219, which costs about $10. But it is so far the easiest way I've found to multiplex up to 8 7-segment display units.

The board shown draws at most 150mA, owing to the 7219's multiplexing of the digits. Unfortunately, there is no provision for activating the colon because of the way the SparkFun display is pinned. To write the program, especially in order to understand the serial communications with the 7219 and implement a timer, I used a Nuts & Volts column written about an implementation for the Basic Stamp. While this was a good start, PicBasic Pro does not recognize Nibble variable types, and so I wrote my own code for a way to make a standard "minutes and seconds" timer work. I'm rather proud of this; you won't see any of the hours of consternation in the finished code, but believe me, it was there and I suffered greatly. I simply used byte variables for both Minutes and Seconds, and when the countdown rolled past zero, the count was forced to 59. Clever, yes? The code for the timer is below. Have fun.

Laundry Timer Code

Paper Debug

In programming, debugging is the process of getting rid of errors in software, usually by using a human-readable display or other indicator to step through the code. Using ICD, or in-circuit debugging, active lines of code are highlighted so that program execution can be observed at a reasonable speed for a human to follow. But I discovered a nifty way to test out what was basically a wireless serial port located across the room. More about the setup later.

I found a VeriFone Printer 250, a serial printer, in the trash. Now why someone would have chucked this fine unit is beyond me; it even had a roll of receipt paper still in it. The first time I hooked it up, I assumed it would be 9600, N, 8, 1 and so I typed some stuff into HyperTerminal and hit Enter. "BrrrrrrriPPPP!" Here it is on the left. I would ask to be forgiven for the ribald language, but I doubt anyone can figure out what I originally typed, so mixed up was the transmission.

When I got it working, I wanted to print my own snarky receipt so I typed "Thank You For Shopping Corporate America" and discovered a curious thing. Both this phrase and the printer's width are 40 characters wide. Coincidence? I even made a terrifically detailed receipt from Corporate America, with an odd list of household items and a total. Since two copies were printed, two different friends of mine have this authentic-looking receipt pinned to their bulletin boards.

Not only did the machine rip to life each time a transmission was sent, letting me know from a distance that a transmission actually took place, but the paper was an enduring and portable record of my experimentation with different settings. Things displayed on an LCD disappear leaving no trace, but printed matter tends to stick around, ask any archivist.

By messing around with echo and linefeeds, I finally got things working smoothly. The unit expects up to 39 ASCII characters followed by a CR, and then it prints a line. If forty characters are received in the buffer, the printer immediately prints what it has, ignoring further input until the line is done. While it has the capability of printing black and red by using a two-color ribbon, I didn't figure out the code to enable the other color. The manufacturer also says the unit can print graphics, but I'm not sure how this is done yet.

Here it is all working, and I've explained the setup in the printed text. All you need to reproduce this setup is a computer network, a MatchPort, and the serial printer. HyperTerminal is routed through COM Port Redirector, a free piece of software from Lantronix, which creates a virtual COM port that is actually the MatchPort's IP address, across the room. The MatchPort accepts TCP/IP packets from CPR via WiFi and spits out RS-232 to the printer. Amazing.

Lantronix devices are a neat way to bridge great distances and have two machines think they're talking directly over a serial cable. Communications can even be protected in a variety of ways, and once things are running, everything is quite cool. I did phone Lantronix with an insipid question, and after all of my personal information was dispassionately squeezed out of me, I got the answer I was looking for. If you look at a Mouser catalog, you'll see products that are marked "bulk" and "sample." What's the difference? Well, silly, the more expensive "sample" ones come in a small box, with a mini-CD containing software. The "bulk" ones come in a big tray with multiple units, and no special packaging or documentation. Yes, you can order QUANTITY - 1 from Mouser, and you can save about five bucks by ordering a "bulk" version, then raid the Lantronix site for the software and documentation. Bulk of one, go figure. Also, if you need the ethernet jack on the unit, make sure you get the part that has one. Some units leave out the jack so you can place it in your project where you like.

3-Button Soft On/Off Circuit
This was one whopper of a cool project. The basic circuit is credited to Dr. Jan Kazula, and the amazing Melanie at the MELabs PicBasic forums explains it well here.

About a year ago I constructed a three-button remote for a solid-state relay project. Press a button, and a code is sent via RF to a receiver inside an outlet box that switches whatever is plugged into the corresponding outlet on. Neato. But all the while the remote is sitting on the coffee table, the microcontroller and the voltage regulator are drawing power. How could I reduce power consumption without putting a dumb on/off switch on the remote? Who ever heard of a remote that you had to switch on before using it? I thought of including a mercury switch, or a capacitive touch-sensing chip, or letting the microcontroller nap every few microseconds, but none of these would do what I wanted the circuit to do, which was to make as little use of the battery as possible.

As soon as I saw the basic circuit, I knew there had to be a way to build it out for three buttons. Of course, this scheme is used inside all sorts of equipment that has to draw nothing while it's sitting, but the process of figuring it out for myself was an incredible way to learn. Now I have a solid understanding of the circuit, and can explain how it works to other people.

So it works like this: When any of the three buttons is pressed, Q1 turns on. This powers the microcontroller while the button is still held down. The microcontroller's first job is to pull the base of Q2 HIGH, providing a path through Q2 to keep Q1 turned on. Then the microcontroller polls the buttons to see which one is low, performs a task (like sending a radio transmission), and then pulls the base of Q2 LOW, turning everything off. The microcontroller senses a HIGH at the other button inputs because they're pulled up with 12K resistors, but a pressed button provides a path from sensing inputs 1, 2, or 3 to ground.

I was surprised to find that an ordinary 7805 regulator attached to a battery with no load is sitting there sucking power. What on earth for? The answer is that (at least in the ON Semiconductor version) there are 22 active transistors inside, as well as a whole bunch of passives like resistors and Zener diodes. Just attaching it to power, there's a basic bias for the device, and the IQ, or quiescent current of the thing is around 5mA. This makes an ordinary regulator a very poor choice for a battery-operated thing, especially if it doesn't have an on/off switch.

So once this circuit worked, I tried out a new regulator I just got from Mouser, the 2950CZ-5.0 low-dropout regulator. Current consumption on my meter went to nil, but I knew it was drawing something. That something turned out to be around 75 uA, or 75 millionths of an amp. Much better. In looking at other power source schemes for the project, I found that the NCP-1400 has a quiescent current draw of 1.5uA to 15uA, and this step-up regulator is probably going to be the final choice for something that has to sit a long time between uses.

The SparkFun FM Radio Module Breakout Board - NS73M

Here's a fun sidetrack project. This FM radio transmitter breakout board allows for stereo audio transmission on the FM band from 87.5MHz to 108MHz at 2mW, and does it quite well. To set up its registers, which dictate frequency, percent modulation, and pre-emphasis, data is sent via I2C or SPI.

I'm enjoying the elegance of synchronous communication these days. It means I'm probably getting a handle on it, and I think the neatest thing is the open-drain bus architecture. You can hang a number of "listeners" off the same clock and data lines, allowing for a sort of network, rather than communicating with each device separately as you'd have to with asynchronous serial. I2C is simple to implement in PicBasic Pro; there are two custom commands for reading and writing that take care of all the complicated signalling. The only thing you have to remember is to add 4.7K resistors to both the clock and data lines.

The picture above shows two things. It demonstrates successful FM transmission at 95MHz, and also shows me that I need a faster scope. This trace was recorded at 10ns/div, and the knob simply doesn't turn any farther. I simply cannot see any deeper than the 95 million Hertz presented here. It's kind of neat the way the carrier shivers along with the audio, which in this case was the Shostakovich Cello Concerto #1 with soloist Carter Brey.

My only gripe about the transmitter chip is that frequency setting requires a little bit of wonky math whose signed numbers will be a pain for PicBasic Pro. Here's the formula for setting frequency, from the datasheet:

fTX=88.5MHz
N = (fTX + 0.304) / 0.008192 = (88.5 + 0.304) / (0.008192) = 10840.33 ...
N = round(N,0) = 10840
Nh = 2A58h Nb = 10 1010 0101 1000b

So in order to make this work for anything other than a fixed frequency, I'll have to figure out how to do this math in a way that's palatable to PicBasic Pro's unsigned math, slicing numbers up and hiding them in variables. Eventually I want to have either an increment/decrement control for transmitter frequency, or at least a potentiometer that's been scaled to the minimum and maximum allowable transmission frequencies.

Update: What I probably want to do regarding this problem is upgrade the PIC to something like the 18F1220, and use the 32-bit math available in PBPL. This way I won't have to devise complicated routines to do signed and fractional calculations. DigiKey sells these PICs for $3.72 in a DIP package.



The MC34063A switching regulator

The PIC microcontrollers I use run on a regulated 5VDC. If I had read my datasheets more carefully, I would have discovered that many of them will run happily on 2 volts. While the simplest thing to do is provide 5V from my bench supply, that's not going to work for a finished project. If I have a wall wart that's putting out a nice, unregulated 12VDC, the first choice would usually be a fifty-cent 7805 linear regulator IC. Along with a couple caps, this will provide up to an amp and a half with a heatsink, and there's the power supply.

But if batteries are going to be the source of raw power, it's important to know how the regulator is dealing with that extra voltage. Anyone who has used one is probably aware of how toasty these regulators get, as if the presence of a heatsink wasn't the first clue. The active element within the 7805 is dissipating the energy as heat within the device. If the battery voltage is about three volts higher than the 5V expected at the output, the unit is about 60% efficient. But if 24V is applied at the input, efficiency drops to about 20%.

A buck-topology switching regulator doesn't waste the extra energy, it chops the power into small slices that pulsate. While you can get a drop-in replacement for the 7805 that operates in switchmode, these units are around $8. Here below you'll see a simple circuit based on the MC34063A, available from SparkFun for $2. This isn't much more than what DigiKey offers it for, and besides, any shipment from SparkFun comes in a hot red box. And as far as being efficient, you can expect around 85% for a wide range of input voltages, if you believe what's written on the tin.

Here's just about the first inductor I ever wound, the green component on the right in the picture. It consists of 48 turns of 22-gauge wire on a ferrite toroid core I liberated from an old computer power supply. Never again will I throw these away, or consider inductors too exotic to work with. The precision required from the homemade inductor is not great, and it's not hard to get things in the ballpark.

The 8-DIP MC34063A is in the center, with a number of support components like caps, a diode, and a 5K pot. I put the pot in place of the two fixed resistors shown in the datasheet, neatly obviating any of the heavier math involved in determining output voltage. Besides the inductor, the sense resistor required is a .33-ohm unit, not easy to find unless you've ordered one or taken apart several power supplies. Luckily I did both. :)

This signal appears at the timing capacitor for the chip's oscillator. It has a peak-to-peak amplitude of 1V, and serves as the timing for the Darlington arrangement (also in the chip) that pumps energy into the inductor. Nothing complicated about this, a repetitive triangle wave that looks pretty much just like the one in the datasheet.

What happens inside the chip is a little more complicated, and I'm still working on an understanding of it, even though it's not entirely necessary. Without too much work, the meter reads an even 5V, with no heat, so I'm done. But I am curious... See, the output switch provides energy until a comparator cuts it off, and the cycle repeats. What you have at the output is a steady 5V without too much ripple. The scope trace below was had by reading just above the inductor, and shows the pumping action. Note that this is not the output taken below the inductor: that's a smooth line at 5V.

Around 12VDC is being switched on and off, many times a second. The ringing on the end of each cycle, I'm guessing, is the result of my not having a fast-recovery Schottky diode and substituting some random thing I had in the diodes drawer. I don't know. It's not like you can get these specialty diodes at the neighborhood shopping plaza anymore, so I'll have to test my hypothesis next time I make a parts order. The ringing could also be evidence of dynamic regulation - the action of switching made visible. But what's important is you can see the chip switching, with an average output below the input voltage because it's off for some of the time. Tres efficient, yes? This is how PWM, or pulse width modulation, can supply a fractional average output by switching a signal on and off very fast. Do that with a lamp and you have a dimmer. Do it with a brushed motor, and you can control speed. Do it with power and you have a switching regulator that can elegantly and economically step between needed voltages.

Here you see 12V going in below and a DVM reading of 5.09V above. Had I chosen a multiturn 5K pot, I could trim things to exactly 5V, but that's not so important. What's really awesome about this switching regulator is that you can put in anything from around 7V all the way up to 40V and the output will not change. And unlike the linear regulator (what's that?) you won't be dissipating heat, only changing how thin the time slices are that power is switched on. An interesting phenomenon is found by sweeping the input voltage around: at some point, the switching will occur at audible frequencies, so you can hear the regulator's little voice, singing it's little song.

It's true, all this switching can cause some problems beyond its being audible. The switching action can be a source of EMI and odd harmonics in a power system, so when powering logic devices or deploying a local regulator in a design, it's probably important to consider shielding and output filtering. But for now I'm pretty happy with the results. Below I've used the same chip to perform step-up, or boost switching regulation.

This time the inductor's a commercial 180uH unit, found at the upper left of the board. Sure is smaller than the hunk of wire I wrapped myself. But again, inductors are special-order or roll-your-own, and SparkFun just happened to have this in stock. This circuit is, again, straight out of the datasheet. Put 12V in one end, get 28V out the other. It has to be remembered that this isn't "free power," only a boosting and switching of the input. You can't expect much more than about 150mA of available current at the output without adding some other parts.

Lately I've gotten into larger circuits that require a variety of DC levels. There might be a display that requires 24V, logic that needs 5V, and a sensor or two that want 3.3V. Using linear regulators to step things down from 24V would sure waste a lot of power and generate a lot of heat. Providing two levels of input power is horsey ("A" battery and "B" battery?) and the linear regulator scheme is just not practical. Adding a couple of switching regulators downstream of the display seems to be the right answer.

Here's what's happening above the inductor. This time, the voltage needs to be stored and released in pulses of short duration. This signal is off a lot more than it's on, suggesting you can't start drawing a lot of power from the circuit. But sure enough, at the output is a real 24V, trimmed again by a pot for my own particular voltage needs. 24V is sort of a standard for many parts like relays, solenoids, mechanical counters, and the like. I'm sure a hefty capacitor will help provide the current for actuation of these devices, once I start trying to use them in projects.

Here's an expanded view of the trace above. Note the ringing off the end of each cycle. Like I said before, I'm not sure whether this is a problem resulting from my use of the wrong kind of diode, or evidence of dynamic regulation. The display here is set for 5uS/Div so that 24V is only switched full-on for about 7uS. Interesting for sure.

The same chip can be used to produce a negative voltage, but I haven't had a need for that functionality yet. One final note, the chip can be put into a step-down / step-up configuration. Initially, it knocks the battery voltage down, but when the battery voltage drops past a usable point, the step-up circuitry takes over. This way you get the maximum use of the energy the battery has to offer. See below:

Updated Tuesday, August 18, 2009. There's an excellent application sheet for this: AN920/D from ON Semiconductor. In it you'll find a fabulous step up/down switching regulator. This has got to be the coolest thing you can do with this chip: make full use of a battery.

I'll tell you, this thing puts out a steady 10VDC with a 5-15VDC input. But you've got to see it for yourself. I replaced the apparently-obsolete MPSU51A with a TIP42 (PNP) I had lying around, because I was just itching to get this thing up and running. Wow, what a great circuit. The next step is to optimize the external components for more useful voltages; I fully intend to go ahead with switching regulators in my battery-powered projects. The trace above shows the fantastic switching action being applied to the inductor.

Laser Projector

Having a laser is of little value without the means to shoot the beam around, so over the past weeks I've been gathering the materials needed to construct a basic laser light show. The first-surface mirrors, liberated from an HP laser printer, were long rods that had to be reduced to manageable chips, and I did this with some help from my friends. The first attempt to reduce them was made by geologist Dr. David Saja, a museum colleague, with a diamond blade. Then he did a spectacular job with a glass cutter and diamond polishing wheel.

So now I have numerous mirror pieces that I hope to mount to servo motors, as shown in a diagram I found at LaserFX.com. Last night I discovered that a semi-silvered Zeiss graufilter (a fancy kind of ND filter) would allow for concurrent effects, with the filter mounted along the same axis as the gating mirrors. And last night I bounced some laser light around, learning quickly how fussy any optical arrangement has to be to get good results.

I don't understand why the XY scanner seems to be the holy grail of laser light shows. Among the various effects obtainable with lasers, the drawing of graphics and text appeals to my hippie sensibilities the least. I much prefer laser beams scanning through the air, and I thought so when I saw my first laser show at the shopping mall in 1984. Now, graphics are speedy animations, in millions of colors, but I still dig the beam effects.

In order to move mirrors at speeds necessary for drawing graphics, motors called galvanometers are employed. These resemble analog meter movements in that varying current produces deflection of the rotor, whose light weight and driving circuitry allow for quick deflections. The galvos are controlled by analog op-amp circuits, and a complete setup can be quite costly. There are other effects that aren't as complex, and I think a rig built with servos, steppers, and DC brushed motors will still look quite nice. ELM has an outstanding laser projector design and tutorial I saw on Hackaday. I bow humbly before this excellent display of several skills, from craftsmanship to demonstration. There's nothing like finding a little Ansel Adams in a living person.

Well check it out. Here's a successful circle-making scanner in action: a small muffin fan with a mirror piece glued on at a slight angle. While that alone is not amazing, I have subsequently mounted the fan on a positionable bracket that sits atop a standard hobby servo. I made two of these units, and one XY scanner that uses servos. When I get around to posting the good pictures from a real camera, you'll see how far my projector project has come. See below.

I'm kind of happy that all the parts come from Home Despot or Radio Shack. Well, truth be told, you have to have a couple servos, but who hasn't a few of those lying around? It was like building with nickel-plated Legos.... Anyway, as I tinkered around with the pieces, I found I could do a lot with just a few parts, as you'll see in the pictures. By gluing a grommet to a 1.5" right-angle bracket, I made mounts for both my laser diode and the lens I harvested from a cheap laser pointer. All the scanner units were made of these same parts, and the little mirror chips that direct the beams are affixed to bent brackets.

Here are the parts for the laser mount. Typically, when one hacks a 16x or greater-speed DVD burner, a diode is elicited. In the case of my laser diode, it was mounted in a nice heatsink, with plenty of space to get at the pins, wire-wrap them, and tack a little solder to the connections. The cool part was the heatsink, whose fins were equally-spaced from the optical axis, and protruded in such a way that the whole block squeaked neatly into the grommet. But I soon discovered that mounting the thing in relation to any lens was going to be a major pain, so I had to figure out a mounting scheme that wouldn't move around.

Most people would say you should get an Aixiz module and mount the diode in a tube with a lens, allowing you to focus the thing, but I wasn't interested in making a laser pointer. I wanted a lab laser arrangement, so I went to Home Depot to look for some parts. The most promising find was this 1-1/2" right-angle bracket, that I then mated to a rubber grommet I got in a joypack from the 'Shack. "You've got questions? We've got batteries." To my amusement, Krazy Glue now comes in a 4-pack of eensy disposable tubes, and setting the grommet down in just the right place without fusing my fingertips was a breeze. Both the laser diode and the lens are pressure-fit into the grommet, and decent alignment is had, as long as the grommets are glued basically in place. The two parts face each other, and can be slid into just the right spot.

Here's the laser diode, with its heatsink, nestled in its grommet. The right bracket houses the lens from the cheap laser pointer. After experimenting with many different simple lens elements, I found that the official laser lens was the most efficient. As I didn't have time to get into a side-branch study of laser optics, I decided to take the existing design on faith, and mushed on. I did find some neat resources by Googling "focusing laser diodes."

This arrangement is the most difficult to get right. Consider all the different incorrect positions of the lens, compared to the one right one. For now, some guide rails are taped down to allow sliding of the lens on this axis. Adjusting focus for a point at a near distance will yield a diffuse spot at a much greater distance after a lot of bounces through the laser effects to come, so the basic beam should be focused on a wall after a bunch of mirror bounces. This way, the beam won't converge or diverge too much for the purposes of the laser show in a particular space.

Along the beam axis are servos with mirrors. They act as beam switchers for four main motorized effects, and their motion is easy to script in software. Once a microcontroller comes into play, MIN and MAX values can be set for safe and sensible beam travel, motion can be ramped, complex scripted actions can be replayed.

Here's a quick shot of the XY scanner. Brackets and mending plates from the Depot are employed to position a mirror glued to a servo above the axis of rotation of a servo below. You can see that the lower servo carries the upper servo, and that the mirror flips any which way in space, remaining basically in the same position, very important for a stationary laser beam. Once switched into the beam train, this mirror has at least 180 degrees in any direction to throw a beam. Pointed into the audience, a shield on the front of the projector will mask the seating area, as well as a safe area above.

What was neat about the parts is that they fit, for some reason, very quickly and naturally together. I don't have a real workshop, and I don't really want too many little bits of ground-up material floating around, so it's nice when things don't have to be cut. Just for fun, I purchased the mini Krazy Glue tubes, a tube of Liquid Nails, some Velcro stick-on strips, and (the most awesome) 3M VHB tape. This stuff sticks to anything and freezes, bonding them together tightly. I stuck a lot of 1" mirror strips to angle brackets with this stuff. And I tacked the servos down onto the shelf board with it. For a time after you tack things together, you can move them around. A while later, you need to apply savage force to separate them.

I plugged the scanner into a 2-channel model aircraft RC receiver to test it, and wow was it fun to drive around. The servos are pretty quick, and it's fun to put a laser dot anywhere in the room and look like I'm flying an expensive model airplane. The effect will look great when the motion is smoothly ramped up and down with a microcontroller. No, it's not especially fast, and it can't do graphics, but that wasn't the point of the exercise. I made something cool, and my efforts satisfied my desire to throw some lasers around without spending a lot of money. But this next effect is cool...

Here's the tunnel scanner tacked to a bracket with VHB, and mounted with a nut, bolt, and washer to an identical bracket. That bracket's attached right to the servo with the addition of a washer. Lots of people have glued a mirror to a fan and shot a laser at it, but I wanted the resulting light fan to move around. Shooting lasers at people is bad, so the effect had to be capable of being aimed, and that's where the brackets came in. A lock washer will be the safest thing to secure this moving effect, but the splashboard on the front of the projector will be the failsafe mechanism to prevent light from ever shining directly into anyone watching, incidentally standing, or even climbing on chairs to touch the beautiful light. Safety definitely comes first with this dangerous science. You'll notice that the mirror is centered over the servo's rotational axis to allow the mirror to turn in basically the same place, just like in the above XY scanner.

While the fan motor spins, the servo whips the light around, you've seen this effect. But I built two of them, so the beam is handed off between them, switching each in turn into the beam train. The fans can scan, or the motors can be independently stopped, making these instruments capable of a variety of effects. An effect that occurs on the right can be repeated by the scanner on the left, giving the appearance of far many more laser sources than the one that actually exists.

Here's the tunnel scanner operating. The laser is the dot in the center of the whirring mirror.. There's a great explanation of basic laser effects at Laser Community, but I warn you that you this media-heavy page may crash your browser. It sure makes my little netbook go bye-bye. Here you can see some inspirational pics and videos useful to the amateur laserist.

My laser projector project is ongoing. Please stop back to see what's new in a few days. It will be a lot of fun adding more beam effects: static multiple beams, diffraction effects, audio-driven beams, and for sure, more motors. I always like to attribute especially neat things I've learned to those persons that devised them, and I'll be packing this section with the resources I've found. I'm having fun and showing you the places I think technologies intersect, and that thoroughness with details takes time. Please forgive any oversights as this is my first website and things are moving very fast!

Motorized Photography Stage

I mentioned that a lot of cool parts can be had from printers and scanners. In taking apart a decent scanner, you will find at least one stepper motor, and I advise you to not be hasty and throw away the synchronous toothed belt and associated gears. You'll notice that there is a machined gripper that moves the optics sled or CCFL illuminator lamp, and this can be adapted to other purposes. In this project, I had my good bud Carl machine a stage so that I could do some focus stacking photography.

The CCFL lamp found inside a scanner (laptop display backlight, fax machine) is worth mentioning, my first extraction of which led to some fascinating sidetrips involving high-voltage power supplies and pencil-lead-thin illumination of the fluorescent kind. This is a great lamp technology similar to to the laser in that high-voltage at low current produces ionization in a gas-filled tube. A reasonable DC voltage (12V here) is stepped up to 1000VAC or more by an inverter circuit, and fed by special spongy high-voltage wiring to the tube, which I found to be usually protected inside a metal sleeve of some kind. Some tubes are ganged together in unshielded groups, and you should be very careful not to break these.

The tube pictured here on the top was perfect for adapting to other purposes (podium reading light?) because there were only two leads for DC input. Other schemes incorporating a voltage comparator for brightness control might be a little difficult to work with, and that's why I haven't worked with the couple that I have. I'm just not sure yet, and I want to be careful. Regardless, you will probably smoke your inverter if your reverse the polarity of the power supply. It pays to read a bunch before mucking around with something exotic like a high-voltage power supply. Or just about anything, for that matter.

Bipolar stepper motors are great because they have a lot of torque. There are no taps in the motor windings like unipolar steppers, allowing for full power to be applied to double the turns of wire with each step. The difficulty in driving them lies in the flipping of polarity so that the number of steps is sufficient to avoid coarseness in the step divisions performed by the motor. A technique called microstepping increases the number of steps per revolution by driving the motor in a complex pattern that energizes both adjacent and nonadjacent windings. Microstepping also reduces vibration in a stepper motor, especially important in the motorized stage project. Vibration is anathema to good photography, but here it is crucial the subject remain stationary with respect to the stage between shots, because several pictures would eventually be combined into one image. And the image produced would render the concept of depth-of-field obsolete.

Without special equipment or techniques, you'll chase your tail trying to render a very small thing very large. If you take a photo of something very small, you'll discover that the resulting picture is sharp, but sharp in only one plane, a plane perpendicular at some distance to the film or the CCD imaging device. Boxes have been created since before photography was invented that exploited the lens-to-projected-image arrangement for artistic purposes, and all the while since their descendants have produced images that are sharp in depth. When the lens-to-imager relationship has been changed from true, the zone of sharpness extends along the plane of focus in an expanding v-shape, allowing objects at varying distances to be rendered acceptably sharp to varying degrees. A view camera can be used when perspective and sharpness need to be controlled in an image, but even the view camera cannot produce an image like focus stacking photography can. For a photo of a small object that is sharp in depth, we'll need a combination of hardware and software.

Focus stacking algorithms analyze successive frames, retaining the most distinct modulations found, while masking areas that exhibit poor focus. They get rid of out-of-focus data through operations producing transparency in those regions, blending them with other, better data via feathered edges. A merged image therefore consists of the sharpest details found in a stack of layers: a smoothly-rendered combination of the best-focused image data that can be found through crazy-fast analysis of each individual image.

I'm not ashamed at all to be using the Easy Driver, a bipolar stepper board that can be had from SparkFun for $14.95 as of this writing. A pair of inputs swaps direction while a pulse input advances the motor in a fixed microstep. Ramp the pulses in software, and you have a smooth ramping up of the motor. Increase the rate of the pulses, and the motor goes faster. This little board was perfect for the project, although I had spent several days on a driver chip that had no integrated translator. Both projects worked, but the board I eventually chose made controlling a bipolar stepper motor a joy.

The only drawback to this board is that it energizes the motor with no input. This was a bummer, as I knew the inertia of the gears at rest would be sufficient to keep the stage frozen, and I didn't need the rig to be consuming current while at rest between exposures. This board gets toasty, and I like to avoid projects' overheating, especially when totally unnecessary, this is why I added a relay, to cut power to the driver board while no positional change input was being sent to the microcontroller. There are two power supply rails, 14.5V 3A, and 5V 1A, and I used a 3055 transistor to allow the higher 12V operating voltage of the relay to be connected through the transistor's collector to ground by the injection of base current from a spare microcontroller pin. Each time a button was pressed on the controller, power and data would be provided to the motor driver board.

So the finished project allows the operator to move the stage up or down in micro or fast mode, with a software ramp built into each motion operation. A delay variable in software ultimately determines the speed at which the stage travels. The gentlest push is applied at the beginning of a movement, and the specimen rides a rail system that was already well-engineered, only the motion is now vertical rather than horizontal. Any more weight and the whole system would have to be reengineered for the torque for which the bearings weren't designed.

Transporting the specimen along an axis without moving the specimen along another can only be appreciated by those persons who have dislocated the shoulder, as the pain attendant to such an event can only be appreciated through direct experience, in an ambulance, screaming. In this project, I think I did a good job of elevating the specimen in stages through the planes required to be photographed, with the ultimate goal of creating a good picture. I trust this rig to the most fragile of subjects, because I built it.


Relays are a great way to get started in electronics. I built this small project to add contact closures to an AMX room control system. This is also a good example of using a Basic Stamp. Operational flow handily follows the board layout, with commands sent to the BS2 via RS-232 from the left. The Stamp's output pins are interfaced with a ULN2803 Darlington array, and the outputs trigger the relays. The power supply is at the lower right, not the best place for it, but hey, I was younger then.

The Darlington stage was necessary because the Basic Stamp II can source about 20mA on each I/O pin, and the relay coil was rated at 100mA. A small current at the base of the Darlington turns it on and allows it to sink the 100mA that the relay wants to draw at 5V.

What can I say about the Basic Stamp(s)? Easy to program, a lot of documentation, expensive. Buy one. If you have never messed around with microcontrollers, this is the one for you. You can check out the BS2 and other Stamps at Parallax. The best deal is "What's a Microcontroller?", a kit that includes a book, Homework Board, and miscellaneous parts. I still have mine and use it for quick setups.


And here's a simple stepper motor control project. This time the microcontroller is the PIC16F877A, and it's driving the unipolar stepper's windings with power mosfets. In this case, the MCU acts as translator and driver, waiting for someone to press one of the two buttons at the top of the picture. No, you can't see them; they're sort of hidden behind their cabling at the top right of the big board. A typical big printer or scanner has two stepper motors, as well as some premium parts worth messing around with.

Unipolar stepper motors like these are simple to home-brew a drive system for, because no polarity-flipping has to occur. The 4-wire bipolar steppers are most easily controlled with a stepper driver chip or driver module board, because of the complexity of the circuitry involved. To drive a bipolar stepper, typically two H-bridges are necessary.

This IR repeater's design is an amalgam of various 555 timer repeater circuits I found on the web. It worked so well I felt I had to immortalize it in a printed circuit board I drew with a Sharpie using the Radio Shack kit. In this circuit, a 2N4401 transistor gates the constant buzz of 38KHz from a 555 timer, also giving visible output from a red LED. I had admired the work I had seen tearing things apart, and I included refinements like screw-down terminals and pin headers for this build. So ready for a box was it, I even emblazoned it with a rather juvenile "Gregtronix" logo and pedantically wrote down the values for all the components. You'll notice that one resistor became three in the upper-right-hand corner, as I trimmed the frequency of the 555 running in astable multivibrator mode, using solder and curse words. Now I include a trimmer for any oscillator, because the breadboard circuit and the final permanent circuit will differ, owing to a difference in capacitance between breadboard and copper traces.

I've included a backside shot of the circuit board, so that you can see the wire I added when the thing didn't power up. I discovered a trace was missing that gave the rest of the circuit a ground reference. In my experience, this is not very favorable for powering up a circuit.

The 555 timer is cool, I just was interested in a more "digital" way of doing things, so I gravitated to my own design based on a 4011 oscillator and 4066 gate. After all, I found this method through a lot of late hours spent tinkering, and I was sort of proud of my success. In any repeater design I've seen, the IR receiver strips the carrier, leaving just the intelligence. Flip the intelligence around through an inverter, have it modulate a fresh carrier, and amplify the product so it can be sprayed out an IR LED, and that's an infrared repeater. If you want long-range transmission, take the intelligence (the square waves seen in the oscilloscope trace at the output of the receiver) and use it to gate a cheap ($7) OOK RF module. On the receiving end, 300 meters away, use this to modulate a fresh 38KHz carrier. That's a basic IR-to-RF repeater. Store the intelligence in a microcontroller, and have human input or sensor data prompt playback, and that's really thinking. An off-the-shelf device becomes a reliable player in a home-built environment.

Going the other way and "learning" the intelligence, capturing the pulse timings into an EEPROM for later playback, that's something I'm very interested in. Microchip, the makers of the PIC, have a method in a white paper for figuring out a number of different formats, but the examples are written in assembly language and geared toward their schematic, which includes octal switches for input. Another project, another day.