I think it might be time for me to tidy a bit.
Nightmare Workbench
April 22nd, 2007 by Keith NeufeldRice Krispies Five-Digit Counter
April 19th, 2007 by Keith NeufeldLook what my wife found in a Rice Krispies box!
It’s a five-digit counter module! Oh, it’s supposed to count your steps while you walk around at Disneyland, but why shouldn’t it be able to count other things???
Okay, let’s do it.
Digging In
Here’s the back side of the case.
OH NOES!!! Triangle-drive screws! Whatever shall we do???
Here’s the inside. The metal arm at the upper left has a small weight, nearly balanced by the hairspring. It bobs up and down when you walk, making contact on the downstrokes with the metal tab at the corner of the PC board.
The Guts
After removal of the two screws holding down the weight, the active electronics pop out–still running.
Disassembling the screws from the back of the PCB enables it to be separated from the screen.
Note the anisotropic strip on the LCD. It looks like a strip of rubber, but conducts electricity only in the direction of its width (which is oriented vertically here). It interconnects the display contacts on the PCB with the contacts on the LCD, just by virtue of being squeezed between them.
Mickey, Meet Jack
It’d be nice to be able to continue using this as a pedometer, but connect something else to count. And it’d be nice if connecting something else disabled the internal counter so you didn’t get extra counts from bouncy bouncy, right?
So we need a closed-circuit jack. It feeds a default signal to the destination, and disconnects the default when you plug something in. Think of plugging headphones into a receiver and it shutting off the speakers . . . or plugging a headset into a cell phone and it disabling the built-in earpiece and mike.
[A few frustrating minutes with a good soldering iron and a bad piece of solder wick later . . .]
The jack. Or in French, Le Jacques.
According to my continuity meter, the connections closest to each other on each side are normally closed (NC), and open to break the connection when a plug is inserted. The ones nearest the plug end make connection with the plug, and the ones furthest from the plug end get disconnected.
This jack is made for a stereo plug (common plus two wires), but we only need mono (common plus one wire). Which of the contacts touches the tip, and which the sleeve? I don’t know! We’ll connect both!
Hold. Mark. Drill tiny. Enlarge. Enlarge. Enlarge. Step-drill. Step-enlarge. Step-enlarge. Voila! Or in French, voila!
Mickey, Meet Wire
Hum tiddle-um, time to do some wiring. Need to break the connection on one side of the weight-switch and reroute it through the default (NC) pins on the jack. The big metal strip that the weight hits is pretty directly connected to what turns out to be the + power lead, so it’s easier to interject into the hairspring’s connection (the big solder blob in the lower middle).
Scrape, scrape, scrape, scrape, scrape. Clean the green varnish off the trace. Then cut the trace (just above the mounting hole).
And solder on some fly wires to go to the jack. I knew that my leftover wire wrap would come in handy someday. One piece to each side of the cut trace, and one piece to the + power supply (to take the place of the weight switch).
After some notching of the LCD case (more than was intended, thanks to lack of planning), the module can be closed back up. I highly recommend putting the battery connector in the wrong place, so there can be more takey-aparty and putty-back-togethery. Then wire to the jack, connecting to both sides as mentioned earlier. (See the bare wires running across the left end?)
Or in French, Voilalala!
One completed, rewired, general-purpose, five-digit decimal counter.
Debugging a LogoBoard
April 18th, 2007 by Keith NeufeldAfter the 2006 Technology: Art and Sound by Design final exhibit, Steve Atwood worked on building his own LogoBoard to use in his sculpture. He found that his board wasn’t working and was overheating, and asked for my help troubleshooting it. To my recurring shame, I’ve had his board ever since with very little progress to show for it. Time to rectify that.
The Board, the Symptoms, and Initial Efforts
Steve built his circuit on a prototyping board with a .1″ perforated .1″ grid and connecting traces on the back, much like a solderless breadboard. The PIC microcontroller is in the center, with various components, connections, and wires surrounding it.
The main thing I knew when Steve gave me the board was that the LogoChip was overheating. I measured the resistance from the LogoChip’s power pin to ground pin and got some very low value like 4Ω, so I knew something was broken, but not dead shorted. I replaced his chip with one of my own and tested again; mine overheated and had the same resistance as well, so his problem wasn’t just that his chip had burned out.
And there it sat for a year.
Drawing the Schematic
In order to do any further debugging, I needed to determine and draw out exactly what was connected where, so I could examine the schematic and find what looked amiss. And the easiest way I’ve found to make a schematic from a PC board is to recreate the circuit in design software, building out the schematic and a reproduction drawing of the physical PC board at the same time. When the traces on the board drawing match the traces on the board, the schematic is correct and complete.
Working with two windows in EAGLE, I created a new project and added all of the components from Steve’s board. I had to fudge on the screw terminals and the crystal oscillator because I didn’t have library parts for them; but for a quick job like this I feel okay substituting a .1″ header and simply remembering what’s really going on. I carefully placed each component on the PCB diagram at the exact space corresponding to its placement on the real board.
Once I had the parts placed, I turned to the back side of Steve’s board and began tracing connections. I added a connection on the schematic for each connection on Steve’s board, switching frequently to the PCB editor to draw out the physical path of the traces whose connections had been entered so far. I drew it as a double-sided PCB; where Steve had jumper wires on the top, I made a via and drew a top-side trace.
When I was finished, I had a fair facsimile of Steve’s board. Oh, there were some messy bits where jumpers overlapped and fly wires left the board, but it wasn’t too bad.
And more to the point, the schematic made it fairly easy to identify the problem. There are blocks of the circuit whose functionality isn’t identified (although it’s fairly easy to determine). But they’re not where the problem lies.
If you look closely at the power wiring to the PIC chip, you can see that it calls to have ground wired to pins 8 and 19 and V+ only to pin 20; but instead, ground is wired only to pin 19 and V+ is mistakenly wired to pin 8 in addition to pin 20.
Voila! Problem solved. Well, identified, anyway. I’ll leave it to Steve to rewire that.
Solder Splash
One more thing. When I was tracing the connections on LED2, the “run” light, I noticed solder splash between its upper pin and the ground bus. It’s at the right edge of the highlighted area, trying to hide underneath the blue jumper.
I haven’t checked it with a continuity meter, but it should be cleaned up to be safe. If I’m correct that it’s shorting the two wires, then the bicolor LED would still light one color (green or red) when port C3 (pin 14) is raised; but would remain dark when port C0 (pin 11) attemped to raise but was shorted to ground.
And with that, the board’s ready to go back to Steve.
CdS Photocell
April 17th, 2007 by Keith NeufeldA cadmium sulfide (CdS) photocell is a passive component whose resistance decreases when light shines on it. CdS photocells can be used to detect when lights turn on, to orient things toward a light source (electronic sunflower), and to detect shadows passing across them.
To use a CdS photocell, you put it in series with a resistor and put a voltage across them. This forms a voltage divider: the voltage at their junction is determined by the proportion of the two resistances. If you want brightness to increase the measured voltage, put the photocell on top; if you want darkness to increase the measured voltage, put the photocell on the bottom.
All that remains is to determine an appropriate value for the complementary resistor. Assuming you want output voltage to increase when brightness increases, the goal would be to make the output read as close to 0V as possible when it’s as dark as you expect it to be, and as close to your maximum voltage as possible when it’s as bright as you expect it to be.
To begin this calculation, I measured the resistance of the photocell (out of circuit) in light and dark conditions. With the photocell shown above, I found the following values:
450KΩ | in the dark (my finger pressed over it) |
36KΩ | in average light |
7.6KΩ | in bright light (under my fluorescent desk lamp) |
I discovered later that the photocell’s carrier PCB isn’t entirely opaque and a noticeable amount of light does leak in around the edges even when the face is covered. The resistance in true darkness would probably be even higher.
I decided to scale the photocell’s circuit to the range from darkness to normal room lighting, so calculating for a resistance range of 450KΩ to 36KΩ. Because this is only a single order of magnitude variation of resistance, I could already tell the voltage swing of the output wasn’t going to be as large as I’d like. I picked a 100KΩ resistor and estimated the voltage range:
5V * (100KΩ / (100KΩ + 450KΩ)) ≅ .91V
5V * (100KΩ / (100KΩ + 36KΩ)) ≅ 3.7V
So it has a swing of about 3V out of a 5V range. Not ideal, but it still provides a fair amount of resolution.
Finally, I connected the photocell to my LogoChip’s A0 input and confirmed its behavior by running print read-ad 0
. I got a wide range of values out of the A/D converter, making this circuit quite usable for microcontroller interfacing.
I also posted a cookbook version of using the photocell on the TASD class wiki.
Making Googly Eyes, Part 2: Construction
April 16th, 2007 by Keith NeufeldAs noted in Googly Eyes Part 1, I built a demo back in February out of a CD-ROM drive optical sled assembly and a couple of ping-pong balls. In the earlier installment, I discussed reverse-engineering the sled’s electrical connections; now here’s how I rebuilt it to operate eyeballs.
I had thought I might find some googly eyeballs in the Wal-Mart craft department, for making big puppets or something. But all their googly eyes were the flat, button-like kind that just stick onto a surface, so I went with my fallback plan of ping-pong balls.
I drew an eye onto two of them, with a black pupil and green iris. I didn’t mean to get the iris quite so dark, but at least I made it with radial lines.
I located and marked the north and south poles of the ping-pong ball as carefully as I could, then drilled through with PCB drill bits. After stepping through several increasing sizes, I was able to use my stepped drill bits to make nice, round, even holes for the axle. I stuck a bolt through and threaded a nut up fairly close to the ball, so it could swivel but not move up and down much.
The sled assembly didn’t have the right sized holes in the right places, so I used big fender washers to make things fit. The eyeball-mounting nut is tightened against the fender washer, with another washer and nut on the bottom side. The bolts continue through the frame and act as legs to raise the underside of the carriage off the surface it’s sitting on, with cap nuts (acorn nuts) for feet to keep the end of the bolt from scratching.
This was actually a bit less than ideal, because the mounting hole for the right eyeball (left edge of the picture) is in a section that’s bent up and raised above the plane of the other holes. I tried compensating for the height difference with an extra nut under the left eyeball, but it’s still not quite right. Probably a washer in between the two nuts would fix it up.
Finally, I needed to translate the sled’s linear motion into the eyeballs’ rotary motion. I turned a loop into the end of a couple of pieces of stiff wire, and . . . had to take the eyeballs back apart again. I drilled another hole in the back of each one, then pushed the wire loop into the interior and reassembled them with their bolts going through the wire loops. Once reassembled, I dabbed some hot glue where the wires came out of the eyeballs; now I could use the wires as control rods to rotate the eyes.
I removed all the optical parts from the carrier sled, then ran a bolt up through it to the height of the eyeballs. I made a loop in the center of another piece of wire and sandwiched it between two nuts on the sled bolt, then made a loop at each end around the eye control rods. After a little tweaking of the angles, I got it set up for fairly smooth movement, with the ends bent to keep things from slipping out of the loops.
In Part 3, I’ll discuss the software that moves the motor and watches the optical disk to monitor travel.
Testing the Luxeon I LED
April 13th, 2007 by Keith NeufeldI have some ideas for things I’d like to do with really bright LEDs, and Philips has the brightest that are readily available to hobbyists right now. They’re brand-named Luxeon, and they’re manufactured and marketed by a wholly-owned company named Lumileds.
A typical 5mm LED can pass 15-20mA of current. Lumileds’ first product to market was the Luxeon I, which (when properly heatsinked) can pass 350mA of current; their more recent LEDs can handle even more. An LED’s power-handling capacity is mainly limited by heat, and Lumileds has found a way to bond the LED die to a heatsink that extends out the base of the package, for further external heatsinking. This allows their LEDs to pass vastly more current without burning out.
A while back, I found a good price on some Luxeon I emitters (just the LED; Luxeons are also available premounted on a star-shaped base) on eBay and bought a small batch to experiment with. Because I knew that external heatsinking was required to drive them at anywhere near their capacity, I set them aside until I’d have an opportunity to build a test PCB.
Design Considerations
Two documents from Lumileds proved particularly helpful:
The LED’s heatsink (“slug”) is not electrically neutral, and must not be connected to either the anode or cathode. It must not be soldered, and should be joined to a heatsink with thermal grease or epoxy. So a carrier PCB should have a large copper plane for the slug, and the electrical connections for the anode and cathode should interrupt the plane as little as possible.
The Thermal Design Guide goes on to say that standard PCB substrates don’t dissipate heat well enough for Luxeons, and aluminum metal-core PCBs are recommended. Each LED should ideally have 36 in2 of heatsink, and an LED with only 1 in2 of heatsink can be operated at room temperature but may reach up to 70°C.
Whatever. I have plain old PCB, and it’s going to have to be good enough to test with.
The Electrical Drive document recommends powering the LEDs with a constant-current source. LEDs are commonly powered with a series current-limiting resistor; but at the high operating current of Luxeon LEDs, a great deal of power is wasted (and converted to heat) in a series resistor. Constant-current drivers place a very low-valued “sense resistor” in series with the LED, then measure the voltage drop across the sense resistor to feed back and control the supplied power.
Whatever. I have a plain old resistor, and it’s going to have to be good enough to test with.
Resistor Selection
This was actually a pretty quick calculation, and I did it in my head because I don’t mind being a little sloppy with this test rig, but it’s good to run through the details anyway.
The Thermal Guide recommends no more than 100mA without good heatsinking, but I figured I’d shoot for 200mA (out of 350mA when properly heatsinked) and see what happened.
The voltage drop across the resistor (VR) is equal to the supply voltage (VS) minus the diode’s voltage drop (VD):
VR = VS – VD
With a 5V supply and approximately 3V drop across the diode, we get
VR = 5V – 3V = 2V
For a target current of 200mA:
R = VR / I
= 2V / .2A = 10Ω
Then the power-handling capacity of the resistor needs to be:
P = I V
= .2A * 2V = .4W
So I pulled a 10Ω half-watt resistor out of my parts bin and was ready to go.
Constructing a Test PCB
I didn’t feel like etching a board, and I don’t have a milling machine built yet, so I went the scabby route and hand-milled a board with a rotary tool.
First I traced the LED’s outline onto a scrap of PCB (a little over 1 inch square), marked pads to surface-solder a resistor and power connectors, and drew in connecting traces.
I outlined the paths I needed to cut to isolate the traces from each other,
then chucked a milling bit into a rotary tool and got to work.
The milling bit has burred edges and was really intended for cutting PCB edges rather than milling trace isolation, so it did a pretty nasty job.
It cleaned up okay with some 600-grit sandpaper, though. I hadn’t bothered cleaning the board at all before I started, since I knew I’d want to sand to knock down the burrs after milling anyway.
Since I couldn’t find my old tube of thermal grease and my wife was running into town anyway, I asked her to pick some up for me. While I waited, I couldn’t resist soldering on the, uh, resistor.
When she got back, I dabbed a little bit of thermal compound onto the LED’s slug, jammed it onto the board, and soldered it down. Its leads are pretty flexible, so I tack-soldered one, then pressed down on the LED’s lens to make good contact between the slug and the board while soldering the second lead.
I cut a couple of one-pin sockets, soldered them to the board, and was ready to roll.
Ow. It’s Bright.
I wired the test board up to my bench power supply and eased up the voltage control. Around 3V the LED sprang to light: BAM, and it was on. From there to 5V, the brightness increased; and I can get even a little more by going up to 6V before I get nervous and back it off.
The LED is extremely bright, for an LED. I couldn’t get a good picture of it without my camera washing out–this is sitting on bright white typing paper directly under my desk lamp. Imagine the whole thing that much brighter.
Also, the Luxeon has a great viewing angle. They advertise it as 120°, and I can definitely believe that.
Turning out the room lights made for a good demonstration but another misrepresentative photo:
It lit the part of the room around my desk well enough to see, although not nearly as brightly as I’d like. I think the Luxeon I LEDs are rated at 40 Lumens, and a 100W incandescent is around 1600 Lumens. We have a ways to go before we’re lighting our houses with LEDs.
The batch I got was called cool white, and it had a very blue cast to it. I’m interested in getting my hands on some warm white next, and maybe some amber.
For now, I’m pleased with the results of the test. I can test different drive methods now, including replacing the 10Ω resistor with a smaller sense resistor if I choose. I have a visual reference of the apparent brightness, and I know I don’t like the color temperature of this particular bulb. And I measured the thermal temperature while it was running–the PCB right around the LED got up to 86°F after a few minutes while the rest of it stayed cool, which is good to know.
I just remembered I have a 1400mA Luxeon III that the eBay seller threw in with the Luxeon I’s I bought . . .
PWM Control of a Larger DC Motor
April 7th, 2007 by Keith NeufeldA year or two ago, I bought a couple of cheap cordless drills at Harbor Freight with thoughts of tearing them down to use the motors for MOSFET-controlled robot drive systems. Yesterday in lab, several guys were talking about how to control DC motor speed for their final project. Serendipity kicked me in the butt and got me prototyping.
The Circuit
The obvious approaches to varying DC motor speed are varying the supply voltage and varying a resistor in series with the motor (which amounts to the same thing). The problem is, DC motors don’t run well on a low supply voltage, and the response is very non-linear.
The usual solution is to use pulse-width modulation (PWM): turn full power to the motor on and off rapidly, increasing (modulating) how long the power is on (pulse width) to increase the motor speed, and decreasing the pulse width to decrease the motor speed. And the PIC (the underlying hardware of the LogoChip) has built-in PWM control, because it’s designed to be used for a wide variety of applications just such as this.
The LogoChip/PIC can’t supply enough power to drive a large motor, so the total control circuit involves a LogoChip, a MOSFET power transistor, and some “glue” circuitry to interface the two together.
If I’d been building the circuit on a breadboard, I’d probably have started by plugging in components and wiring them up, because mistakes are easy to correct by unplugging and replugging. But since I was using larger components that I was going to need to solder, I didn’t want to have to change too many connections; so I started by drawing the schematic I intended to build.
(First I reread my May 2006 post about driving stepper motors with MOSFETs. They don’t use the same circuit, but I had taken the time to review my textbook and figure out how to treat MOSFETs right; and my blog isn’t just for y’all–it’s secondary storage for my own memory.)
The PIC’s PWM output is on port C2. The MOSFET’s gate needs at least 7V to saturate (turn all the way on), so port C2 controls the base of an NPN transistor (any common NPN will do; I happened to have a 3903) that switches the MOSFET gate between 12V and ground. The N-channel MOSFET in turn provides a ground path to turn on the motor when the MOSFET’s gate voltage is high.
The only snag is that the bipolar transistor inverts the control logic; so when C2 is high, the motor is off; and when C2 is low, the motor is on. Oh well. We’ll compensate in software.
Wiring it Up
I started by bolting one of my IRF510 MOSFETs to a heatsink. I should have used thermal grease, but I didn’t have any handy and I’m doing a quick test. And I should have used an insulator (since the FET’s tab is wired to drain, and that’s not going to be ground, and the heatsink might bump into something that’s grounded), but the heatsink seems to be anodized and sorta insulated already and I’m just doing a quick test.
I could have used the cordless drill’s battery to power the motor, but I didn’t feel like rewiring that much of the drill right now. So I settled on using my trusty old PC power supply–and I desoldered a connector from a dead CD-ROM drive to mate with the power supply. (Bench vise, heat gun, and pliers.)
I wired the MOSFET to the power connector and left fly wires to go to the motor and the LogoChip. As always, I put heat-shrink tubing on each solder joint to be safe. The 10K pull-up resistor at the end of the blue wire, hidden behind the yellow wire next to the power connector.
The 5V supply on the power plug isn’t needed, so I insulated it as well.
Connecting the Drill
The largest DC motor that I could think of having at home was the cordless drill. It’s not as big as the windshield wiper motor that Team Doccia might be using, but it’s the best I could do. Here’s the victim with its the case removed:
The motor is the silver and white cylinder in the center of the top of the picture. The tan cylinder to its right is the planetary gear system that reduces speed and increases torque.
To the left of the motor, you can see the MTP15N06V MOSFET that normally runs the drill. I could have reused it, but (1) then I’d have been done before I even started; and (2) I wanted to test with a FET that I had lots of, so someone else could use exactly the same circuit. Both the drill’s MTP15N06V and my IRF510 have a built-in reverse-biased diode to shunt the back-EMF spike that occurs when the supply voltage is removed from an inductive load (like a motor).
I pulled the the motor out of the drill casing, soldered on the leads from the FET wiring harness, and jammed it back in. I could have laid in on my bench for testing, but I was afraid the counter-torque when the motor started up at high speed might roll it right off the edge. The gearbox has a tab on the bottom that mates with the case and keeps it from twisting.
LogoChip Wiring
Tom left a nice prototyping area on the LogoBoard when he designed it, so I built the rest of the circuit there. I soldered a header socket into the connector for pin C2, plugged the NPN transistor into the breadboard section, and plugged in the base resistor and the gate and ground leads from the FET assembly.
Here’s what the whole works looks like when it’s all hooked up:
Control Software
For prototyping, I reused my old motor-pwm-demo.txt program, even though it has some extra stuff that’s not needed here. I called pwm-init
and then pwm-set 255 255
to shut the motor off. (Remember, it’s backwards logic because of the inverting effect of the NPN switching transistor.) pwm-set 255 0
turned the motor on at full speed, and pwm-set 255 128
selected a medium speed. pwm-set 255 196
was about as slow as it could reliably go.
To explain the code, the first parameter (the one that I’m always calling with 255) is the period of the control pulse–the higher the number, the longer between consecutive pulses (i.e. the slower the pulse train). The second parameter is the pulse width–how long each pulse output should be on. So pwm-set 128 64
should have about the same effect as pwm-set 255 128
, only twice as fast (half as long).
Unfortunately, that ain’t quite so. Due to the inductive effects of the motor coils, some frequencies of PWM control work better (more efficiently) than others. In this case, the lower control frequency is more efficient–the motor runs a little faster at 255/128 (longer pulse = lower speed) than at 128/64 (shorter pulse = higher speed).
Worse, the motor would probably like it even better if the control frequency were even lower. But I can’t do that–I’m already running the PWM clock at its lowest speed and dividing that speed as far down as it goes. This is as good as it gets.
Final Thoughts
Motor On at Powerup
When the circuit powers on, port C2 is set as an input, so the MOSFET’s pull-up resistor pulls the line high and the motor turns on at full speed. That’s bad; you never want mechanical systems initiating motion before the control systems come online.
The circuit should really be redesigned to use non-inverting buffers to get around this problem. But for now, at a minimum, the motor should be turned off in the LogoChip’s powerup
routine:
to powerup
pwm-init
pwm-set 255 255
end
Operating Temperature
With an ambient temperature of 72°F, the FET got up to about 96°F after running for a few minutes. The FET is rated for 250°C and its rated capacity only drops from 5.6A at 25°C to 4A at 100°C, so it’s well within safe operating conditions. If a larger load were required, I might look at using more FETs in parallel. (I don’t even remember whether you can do that, so I’d start with the Malvino textbook and review whether parallel FETs are subject to thermal runaway.)
Low Torque
The drill really doesn’t have much torque using this driver at low speeds. Granted, the drill is rated for 18V and I was running it 12V. But I was hoping to get away with using open-loop control for robotics, and it looks like I’ll probably have to put optical encoders on the wheels to make sure they’re really turning as fast as I told them to.
I’m still optimistic that a windshield wiper motor is geared down enough, and natively runs at a low enough speed, that this control method will be adequate for Team Doccia’s breathing mechanism.
Making Googly Eyes, Part 1: Reverse Engineering
April 2nd, 2007 by Keith NeufeldBack in mid-February, I wanted to demonstrate motor control with the LogoChip to class, but it’s hard to see what a motor is doing unless it’s geared down and attached to something. I decided to make googly eyes that could look around, and here’s how I went about it.
CD Read Sled
Although the motion of each individual eye is rotary (right to left; these can’t look up and down), to synchronize their actions, I needed linear motion.
Digression: Predator species have eyes on the front of their face, to triangulate the distance to their target. Prey have eyes on the sides of their heads, to keep the widest possible view of their surroundings and watch out for predators. Predators’ eyes generally move in synchronization. Of course, they may look slightly inward when watching a nearby object (binocular convergence; think of looking cross-eyed at your nose); but for a simple model like this, two eyes always looking in exactly the same direction is adequate.
I figured my best shot was something from a dead CD-ROM drive, so I went down to examine my stash. What I call the read sled assemblies looked the most promising–they’re the ones that move the read head in and out along the radius of the disc to find the right position to play. The tray motors might also work, but the trays have a good 5″ range of motion. The ∼2″ range of the read sled seemed much more useful.
Several of the assemblies I examined used a stepper motor, but I wanted to demonstrate a simple DC motor, so I kept looking. Finally I came across this one, which had a DC motor (on the underside), a nice geartrain, and an optical encoder (the faint grey circle between the green PCB and the medium black gear) to determine the position of the sled.
The motor was mounted from the back side, and the optical disk was press-fitted to its shaft.
Reverse-Engineering the Optical Assembly
I was interested in trying to reuse the optical assembly so that I too (well, my program) would know where the sled was, so I desoldered the flex pcb ribbon cable and set about figuring out the connections on the PC board.
The larger black rectangle that overlaps the optical disk was obviously an optointerruptor–one side has an LED and the other side some kind of optical sensor. When a hole in the disk passes between them, light is transmitted; when a bar passes between, the light is interrupted, and the receiver can tell the difference.
The two smaller black rectangles (southwest of the screw head) are surface-mount resistors, reading “181″ (180Ω) and “752″ (7.5KΩ). I could visually follow some of the traces (the light green lines) on the board, but I got lost with exactly what happens underneath the resistors.
I assigned numbers to the five solder pads from the cable, arbitrarily numbering from the outer edge of the board. (In retrospect, that was incorrect–the pad to the left in this photo is shaped differently than the others; that makes it pin number 1. Ah well.) Then I made this table (actually edited here on my blog–all the notes have been sitting around for six weeks, and it’s only the narrative that I’m adding later) describing where each pin went, to the best of my visual acuity.
Pin | Connection |
---|---|
1 | motor black wire |
2 | motor red wire |
3 | interruptor |
4 | interruptor end of 7.5KΩ resistor |
5 | both resistors |
Pins 1 and 2 obviously run to the motor, and it was pretty clear that they didn’t have any connections to pins 3-5. So I used my ohmmeter to measure the resistance in each direction between each pair of pins out of 3-5. I got this:
4 → 3: 50KΩ 3 → 4: ∞ |
5 → 3: 40KΩ 3 → 5: ∞ |
5 → 4: 7.5KΩ 4 → 5: 7.5KΩ |
It was obvious that pins 4 and 5 were connected directly via the 7.5KΩ resistor. It was also apparent that there were diodes from pin 4 to 3 and from pin 5 to 3. That gave rise to this diagram:
Which made a lot more sense once I redrew it like this:
Pin 5 is the supply voltage, pin 3 the ground, and pin 4 the readout of the voltage divider between the 7.5KΩ resistor and the photosensitive diode. Voila!
Using the Optical Encoder
A 180Ω current-limiting resistor with a 5V supply would give ∼24mA of current through the LED, and that seemed a little high. I’m guessing that part of the circuit ran on 3.3V, making the LED current ∼14mA–a more reasonable value.
I wanted to shoot for 15mA, so 4.3V / 15mA ≅ 290Ω, of which 180Ω was already in the circuit, leaving 110Ω to add. I had a 120Ω resistor in my bin, so 4.3V / (180Ω + 120Ω) ≅ 14mA, which was close enough. I used the 120Ω resistor to wire pin 5 to the 5V supply, placing it in series with both diodes. (I figured its impact on the 7.5KΩ resistor and photodiode whould be negligible.)
Turning the encoder wheel very slowly and carefully and reading the voltage at pin 4 yielded a minimum voltage of .77V and a peak of 3.4V. (Alas, I don’t remember which was when the light was blocked and which when it was passed . . . probably the photodiode conducted and pulled it down to .77V when light was passing . . . but I don’t know that I really care.)
I didn’t really want to have to use an A/D converter input and deal with a 10-bit numeric value when all I needed to know was whether the light was blocked or passing. But I wasn’t wild about feeding a continuously varying analog voltage into a TTL input–it tends to make them overheat. Happily, the PIC datasheet (p. 102) revealed that pin A4 has a Schmitt trigger input, and my problem was solved.
A Schmitt trigger has hysteresis–the input signal has to rise above a certain point (the “high-water mark”) before it reads high, then fall below a lower point (the “low-water mark”) before it reads low. It’s intended for reading digital values from analog signals, it was exactly what I needed, and it worked exactly as desired. I fed the optointerruptor signal into A4 and got clean, predictable digital results.
Next Steps
That’s probably long enough for one post. Next: Building the eyeball assembly and programming the motor.
Piezo Elements for Percussive Input
April 1st, 2007 by Keith NeufeldHarry Partch and Piezo Instruments
Lauren Hirsh, a WSU percussion student, WSU Internet radio goddess, and all-’round CRATEL regular, is involved in a performance of Harry Partch compositions this spring. Partch composed for new instruments he created, and the percussion department is attempting to build at least one or two of them for the concert. Lauren is taking on the task of building one, I believe the boo.
The boo is a marimba-like instrument made from tuned bamboo tubes arranged in six ranks. Rather than try to reproduce the tonal qualities of the original instrument through physical means, consideration is being given to building an input interface and using electronic reproduction of the boo sounds. In other words, Lauren wants to build a synthesizer keyboard shaped like a marimba. And several of us involved in CRATEL are intrigued by the challenge.
Tom McGuire has done all the work so far. He got a piezo element and hooked it up to the LogoChip. When you strike it, it generates a voltage; he’s working on capturing the voltage in a capacitor until the LogoChip can come along and poll it. The capacitor doesn’t have a drain resistor; he’ll turn the LogoChip port into an output at 0V after he’s read it, to drain it manually. In other words, he’s making a piezoacoustic version of the CCD camera. Brilliant!
Here’s a picture Tom sent of the element attached to a PVC faux bamboo tube:
Sources
Tom has a few piezo elements, but maybe not enough for the whole instrument (even though Lauren only wants to construct a couple of ranks). But tonight, I mentioned the situation to my friend Joel, and he rooted around to bring out four boards with a dozen piezo elements each, which he’d be happy to donate as long as they don’t all get used up.
Each piezo has a rubber-covered button stuck onto the front–Joel thinks they may have come from an ATM or some other heavy-duty input system. It doesn’t feel like they can be removed easily, and I don’t know whether that will prevent them from being useful.
Worse, they’re a bit corroded, and trying to remove the silicone that holds down the wire tends to rip the foil right off the back. I don’t know if there’s enough salvageable here or not, but I wanted to post the pictures to let Tom have a look.
One I haven’t torn yet:
LED Gloves
April 1st, 2007 by Keith NeufeldBackground
Steve Wilson is a graduate student involved in WSU’s CRATEL (Center for Research in Art, Technology, Education, and Learning) program, and his video synthesizer was sponsored for further development in last year’s BETA (Bridging Entrepreneurship, Technology, and the Arts) competition.
One of Steve’s challenges for his video synth, and an interest in general, is creating expressive interfaces to electronic instruments. He describes it in a post to the Technology: Art and Sound by Design class mailing list. Basically, it comes down to the idea that acoustic instruments offer an immense amount of control over the sound that comes out through physical manipulation, and electronic instruments tend to offer much less control, and through mechanisms mainly like knobs and sliders.
While brainstorming with Steve about his synth, several of us came up with the idea of an interface like a plasma globe, which you control by moving your fingers over the surface. A cheap videocamera inside could watch what was happening and control the action.
Apparently a group of engineering students have been working on the globe subproject for six months without much progress to report. Although their difficulties seem to be mainly lack of organization and lack of time, others of us had talked about how clear an image might be obtainable on the camera with the globe lighted from the inside or outside.
Finally it occurred to me (while driving home from work) that gloves with LEDs on the fingertips would make lighted spots that should be very easy to see from the inside of the globe. Different colored LEDs on different fingers would allow the driver software to identify the different fingers; and pressing the LED against a translucent surface will produce a sharper point than holding it further away, so it might even be possible to determine approximately how near a fingertip is to the globe’s surface. And if made properly, the glove could be worn without impeding other use of the hand–just adding lights for the globe.
Time to prototype.
Gloves
I was hoping to find a cheap lycra glove to make something like the original Dataglove. (Yes, I have a Dataglove system. No, you can’t play with it.) What I found instead was certainly cheap, but knit cotton instead of lycra. Heck, for 96¢, it was good enough.
When I put the gloves on, I could feel that they’d been assembled somewhat sloppily. Inside-out, it was easy to see that there was a lot of extra fabric inside the fingers outside the stitching:
So I trimmed it a little closer and more evenly around the fingertips, for better fit and comfort.
LEDs
I wanted to use surface-mount technology (SMT) LEDs, so they’d fit flat against the glove surface. The ones in my stockpile are out of broken digital office phones, used to light up beside the line appearance and feature buttons.
I wanted to be sure I knew the polarity before I started attaching things and soldering them together, so I tested first with my meter. The LEDs actually lit with the small amount of current it supplies, which was kind of cool. Curiously, the green LEDs have the anode on the end with the cut corner, and the red LEDs have the cathode on the end with the cut corner. On each LED that I identified, I marked the anode end with the color of the LED. (The ones on this sheet are tinted to indicate their color, but the ones I’d already removed weren’t.)
The phone flex-PCB has a 300Ω resistor in series with each LED, so I tried out a couple there on the strip. Nice and bright.
Soldering the LEDs
My plan was to solder wire the LEDs, then sew the wire through the glove to the back side, where I wanted to attach a battery holder. I got out some fine wire, scraped off the enamel insulation, wrapped it around the fly leads on the LED, and soldered it up.
Sewing
After I had both wires soldered to the LED, I threaded one at a time through a needle, held the LED about where I thought I wanted it on the fingertip, and started sewing. The goal was to get the wire from the tip of the finger to the back of the hand without leaving any large loops that might snag on anything, and without reducing the stretchiness of the glove. The latter factor called for a zig-zag stitch, which with a single thread looks like a running pattern of slash marks.
Once I got the wire stitched around to the back side, I followed along the back of the finger and then curved toward the center of the back of the hand.
Glue for Protection
I needed something to protect the LEDs on the fingertips so they wouldn’t snag. When the wires were safely stitched around out of the way, I got out the hot glue gun, put on the glove, put a dot of molten glue over the LED, and pressed the glue into a perfectly-shaped dimple in a USB serial connecter that I lifted from the CRATEL lab. It soaked into the fabric a bit, adhered very well, and made a nice smooth bubble over the LED.
Well, mostly nice and smooth. Hot glue tends to stretch like pizza cheese, and I made a little boo-boo.
Battery Holder
For now, I settled on prototyping just two fingers, because I have only two colors of SMT LEDs, and because it seemed like enough for a proof of concept. I steered the appropriate wires onto the same paths and ran them up to where I wanted the battery holder.
Then I clipped the wires short, scraped the ends, folded the glove over to get room to work, and wrapped the wires around the leads of a surface-mount coin-cell holder salvaged from a PC motherboard.
I soldered them on, then folded the battery holder leads underneath so they wouldn’t poke through the glove and scratch up the hand. Laid back out, it looked like this.
The Lights
I didn’t bother with a switch on the prototype–just pop in the coin cell and the LEDs come on. And because I’m using an old, small battery, I didn’t bother with current-limiting resistors–the internal resistance of the battery seems to be enough to limit the current to the LEDs.
Due to the idiosyncracies of my digital camera, the green LED on the index finger doesn’t look very green in this picture, but it really is. It’s a lot dimmer than the red LED, though; and I’m not sure why that is. Before going beyond a prototype, I’d want to pick current-limiting resistors to more closely calibrate the brightness of the different LEDs.
I don’t have a translucent globe to use, but I borrowed a hemispherical Tupperware bowl from my friend Lawrence’s daughters. (Don’t ask my why the girls have their own set of Tupperware–I really don’t know.) It works well enough to demonstrate the idea:
You can clearly see where the red LED is touching the bowl. Now all we need is a videocamera, some fancy software to track the lights, and an interface to a video synth.
Seriously, all of those things are Steve’s domain. I just wanted to see whether I could throw together a working glove, and I think this’ll do.
Oh–and when you want to shut it off, you take out the battery and drop it into the thumb.