Archive for the ‘General’ Category

Rez Trance Vibrator mystery LEDs, and how to control them

ASCII Trance Vibrator with the LEDs populated

ASCII Trance Vibrator with the LEDs populated

So, a friend of a friend recently managed to buy the original Rez, complete with new-in-box Trance Vibrator. But the peripheral didn’t work – it would be detected, but otherwise not do anything. Knowing I had produced a compatible open source version of this hardware, she brought it over for a look. The motor was seized up, probably due to not having spun in over a decade, and easily fixed with a drop of sewing machine oil. But while I had it open, I decided to resolve a longstanding mystery about the device. You know I’m a sucker for LEDs.

Mystery LEDs

Looking at the PCB reveals footprints for 3 non-placed LEDs and associated current limiting resistors. Facing them on the front side of the case are 3 rectangular pockets of an appropriate size to receive such LEDs, but no openings exposing them to the outside world. (Similar walled structures are used around LEDs in close proximity in other gadgets to block light from the neighboring LEDs.) It’s possible such openings were originally intended to be drilled later… or the mold design was hurriedly changed to remove them, but the pockets themselves remained.

So I stuck some 3mm LEDs there to see what would happen. I assume they were probably meant to be Red/Green/Blue, but I just used the colors I had on hand, along with a trio of 1k 0805 surface-mount resistors.

I don’t have Rez or a PS2, so I fired it up with the test utility I wrote for the Drmn’ Trance Vibrator project. The LEDs light in a changing pattern in response to changes in motor drive level. I wasn’t sure if it was intrinsically tied to motor intensity or some other data, so a quick test was in order. A faithful implementation of the ASCII vibrator’s USB protocol includes some redundant data, which could be omitted without affecting device operation, so I suspected the smoking gun would lie in these extra bytes.

Sure enough, the LEDs can be set arbitrarily via a byte in the USB packet, independently of motor control. The low byte of wIndex, specifically the 3 LSBs, directly set the LED states. The LSB controls “A1” and the next two control “A2” and “A3”, respectively. Although the LEDs can be controlled independently of the motor, the official Rez game always sets the low byte of wIndex equal to the low nibble of the motor power level it is commanding. Observing a USB packet dump of a level playthrough reveals no attempt to drive the LEDs independently. (Since that feature never made it into the released Trance Vibrator itself, it’s not surprising that the game’s developers didn’t agonize over what they could do with it. I’m a little surprised the game passes any data for that byte at all.)

LED control is all-or-nothing. At this point I suspected the high byte of wIndex (always sent as 0x03) might control intensity, but fuzzing around with this value or the others (e.g. the bRequest of 0x00) has no effect.

Here is a quick Python script demonstrating blinking the trance vibe LEDs.

And a video of them in action:

But why were the LEDs removed?
The first answer that may spring to mind is cost cutting… but it doesn’t make too much sense at first, because LEDs are pretty cheap. Or are they? Simply poking them out of holes the front of the enclosure would wreck the watertightness of the enclosure without some kind of gaskets, sealants, or clear windows to cover the openings. Even though the game’s creator says the device was not intended to be sexual, if you put humans near something that vibrates, the first thing they will do is stick it on their fun bits. No. Exceptions. Having openings in an ultimately line-powered device meant to be used that close to the body might have opened them up to regulatory headaches, e.g. medical-grade power supply isolation, and might just not have been a good idea overall.

Tickle_me_elmo

Oh boy… that tickles!

The most logical reason for the removal of the LEDs, though, is that they just wouldn’t really work. Unless you are a contortionist, there are very few ways one could use this device as intended and still have them in your line of sight. I suppose it’s possible they were meant to work as a very early Ambilight-type system if played in a darkened room, but you’d still need some pretty bright LEDs and a pretty small room. It also wouldn’t work from a shirt or pants pocket, or with the protective cover on.

The rest of the circuit

Operationally, the circuit inside is actually pretty close to Drmn’ Trance Vibe, although approached in a very circuitous way. Both generate a PWM signal that controls a transistor to modulate the motor speed. In the ASCII vibrator though, rather than directly generate the PWM signal from the microcontroller, it instead outputs an 8-bit value via I/O pins to a crude DAC (R-2R ladder), which feeds into an opamp (buffer?) and eventually a TL5001 discrete PWM generator. This drives a transistor, which may in turn drive another identical transistor to drive the motor. I have no idea what the 3rd large transistor, next to the PWM generator, is for – I didn’t feel like digging to that level of detail on borrowed hardware that I had to return in working condition :-)

There is a non-stuffed mystery jumper near the large inductor at center, which receives (or would) its output from a similarly non-stuffed diode, and leads to an I/O pin on the microcontroller. In my quick testing, this appeared to be an analog signal which remained at or near ground through all normal operation. I suspect it connects to the overcurrent signal on the PWM generator, and would cause the CPU to halt the motor if tripped, but don’t bet the farm on this. It doesn’t appear to invoke a bootloader, diagnostic mode or anything similarly interesting.

Here are hi-res pics of the PCB, if anyone is interested:

Top of ASCII Trance Vibrator PCB

Top of ASCII Trance Vibrator PCB

Bottom of ASCII Trance Vibrator PCB

Bottom of ASCII Trance Vibrator PCB

Solar seed warmer to get a jump on spring

Spring is coming… here is a tiny little hacklet from the bench of Tim.

I live in New England. I don’t mind it here, but the growing season is a bit short. So here is a scheme to give outdoor direct-seeding a little head start.

Seeds for many food plants, such as melons and peppers, will not germinate until temperatures rise above a certain point consistently. They could in theory be started indoors, but I’ve never had good luck with this in a prison-windowed New England house: even if I remember to water the seedlings consistently (hint: I don’t), regardless of how well I position them in my best south-facing window, they still end up weak and spindly for lack of sunlight. If they don’t outright die when hardened off and transplanted, they seem to go into some kind of shock and stop growing for several critical weeks. I’ve found direct-seeding outdoors is a lot more reliable overall. The tradeoff is that by the time it gets warm enough long enough to trigger germination, they will not set fruit until the tail end of the growing season. What a pain!

The previous homeowner was nice enough to leave behind some things, including some solar garden lights. A quick tweak to them makes them into seed warmers.

Solar garden light converted into a nighttime seed warmer

Solar garden light converted into a nighttime seed warmer

String of low-valued resistors insulated with black heatshrink

String of low-valued resistors insulated with black heatshrink

Assembled view of the seed warmer element

Assembled view of the seed warmer element

Ingredients:
1 old solar garden light
Heat shrink tubing
A few low-value resistors (5-10 ohms)
Small bit of copper tubing

Process:
Sould be pretty self-explanatory from the pictures.
solder one to a few of the resistors in series to achieve the desired length. Connect to each end of the resistor string with some thin insulated wire. Heat shrink this assembly so that the wires exit on the same side (the heat shrink will prevent the bodies of the resistors from wearing through against the tubing and shorting out). Cut a piece of copper tubing to a sufficient length that this can be stuffed inside. For best results, the assembly should be a snug fit inside the tubing to ensure good thermal contact. Finally, seal the ends of the tubing with RTv or similar watertight material, and optionally coat the copper with something to prevent corrosion.

Remove the LED from the solar light, and wire the heating tube in its place. DONE!

Now, when you plant a hill of outdoor seeds, drive the heating tube into the center of the hill, and place the solar light off to the side a bit (so it is not shading the hill). The sun will help keep them warm during the day, and the heater will take over during the cold nights.

Notes:
How much heating will you get? Short answer is “it depends”. In theory, you can measure the voltage output by the light unit and use Ohm’s Law to calculate the power dissipated over your chosen resistors (power in Watts = I*V = V^2 / R). Depending on the design of your solar lights, the output voltage may not be remotely constant or easily characterized, and the circuit inside may have its own current-sourcing limit, reducing your total output. The actual amount of heating you get may be pretty modest. You will not (and should not) find the tube uncomfortably warm to the touch during operation. Fortunately, dirt is a pretty good insulator.

Some plants just plain don’t like to grow in the cold, even if you can trick them into germinating early. For better results, combine with a coldframe to keep the aboveground bit a little warmer too.

So, it appears MakerBot have gone full evil now…

We shuddered when it was announced that MakerBot were taking the next version of their RepRap-based printer design closed-source. We crossed our fingers when the CEO responded to the flap saying they’d be “as open as possible“. We watched with popcorn the various flaps about Thingiverse, legal mumbojumbo, attribution and moral rights.

But now this. MakerBot has been awarded a patent on the conveyor belt. (Specifically, use of a conveyor belt “with a 3D printer”.)

I don’t know about you, but I can’t possibly think of any device for converting a computer file to a tangible work product that uses rollers to clear its work product from the work area to make room for subsequent work product. Certainly no such analogous device exists, or else 3D printers wouldn’t have such a clever and unique name.

While I am here, to forestall successful patent attempts on other obvious means of clearing work product from a work area, I hereby disclose the following novel invention:

1) A work producing system and method comprising a work producing machine, a means of executing stored instructions (sometimes called a “computer”), a set of instructions (sometimes called a “program”, or “software”) that instructs the work producing machine to produce a work product responsive to a description (sometimes called a “file”) describing the work product, a means of conveying said description to said system, and a means of conveying said instructions to said machine. (The system description may optionally include such novel and non-obvious components as RAM, a CPU, wires, wifi, power from the power company, etc.)

2) The claims in Claim 1 where the work-producing machine further includes a method of clearing prior work products from its work area.

3) The claims in Claim 2 where the work-clearing means includes a pushing means to push the old work products from the work area.

4) The claims in Claim 2 where the work-clearing means includes a pulling means to pull the old work products from the work area.

5) The claims in Claim 2 where the work-clearing means includes a scraping means to scrape the old work products from the work area.

6) The claims in Claim 2 where the work-clearing means includes a gravitational means to remove the old work products from the work area. An example of such a means is a tilting means which tilts the work surface, a rotational means which rotates the work surface to a nonhorizontal position, or an antigravity device which causes a local gravity inversion in the vicinity of the work surface.

7) The claims in Claim 2 where the work-clearing means includes a vibrational means to shake loose the old work products.

8) The claims in Claim 2 where the work-clearing means includes additional work surfaces which can be exchanged with the work surface on which work products have previously been produced, and a means of exchanging said work surfaces. (The unused work surface may, for example, be physically exchanged with the used work surface of the same machine, or exist in a second work-producing machine which takes over work production jobs while the first work surface is full.)

9) The claims in Claims 3-7 inclusive, where zero or more said means are combined in such a way as to improve the reliability of clearing work products from the work area.

10) The claims in Claim 9 where the pushing means further comprises a solid object configured to move across the work area, thereby pushing work product out of the work area. Compare “broom”, “push bar”, “squeegee”, “bulldozer”. Since patent examiners have the imagination of a goldfish, I should point out at this time that moving the work surface with respect to the pushing device is the same as moving the pushing device with respect to the work surface.

11) The claims in Claim 9 where the pulling means further includes a magnet. Magnets are magical. (Computer-controlled electromagnets are even more magical because computers are magical and electricity is magical.)

12) The claims in Claim 9 where the pulling means further comprises a suction mechanism and a means of moving said mechanism into contact with the work product and to a location outside the work area. (Compare: “vacuum pick and place”)

13) The claims in Claim 9 where the combined pushing and pulling means further comprises a robot arm and a means of moving said mechanism into contact with the work product and to a location outside the work area. (Compare: Industrial pastry sorting robots). Since I may have been unfair toward goldfish in Claim 10, I should point out that the non-difference between moving the work surface vs. the pushing device also exists for a *pulling* device. Or basically any other device or combination of such devices.

14) “Pushing”, “bumping”, “kicking”, “nudging”, etc. are the same thing. Just throwing it out there.

15) The claims in Claim 2 where the work-producing machine is configured to produce works which are of a 3-dimensional nature.

16) The claims in Claim 15 where Claims 3-14 are restated here by reference.

17) The claims in Claim 16 where the system further includes a means of collecting the removed work products (sometimes called a “bin” or “bucket”).

The IOC, Trademark Law and You

Yes, it’s true! With the London Olympic Games and Paralympic Games Act 2006 (UK), and similar laws pushed through in other countries as a condition of hosting a certain large quadrennial event (US- Amateur Sports Act of 1978; Canada- Olympic and Paralympics Marks Act), any infringing use of IOC ‘properties’ (similar to, but stronger than, trademarks) such as combinations of the words ‘summer/games’, ‘summer/2012’, the interlocked rings, etc., are a criminal (not civil) matter.

The following Venn diagram explains in more detail.

Not Dead

Really! Just busy with some real-life stuff, namely wedding related and home renovations. I haven’t forgotten about this pick & place stuff! Lately I’ve been spending most of my project time on getting Mosquino toward an official 1.0 release. The rev2 boards just came in, so once all the parts are in I should have one ready to test soon. Here they are!

As usual, click for fullsize. Clockwise from the bottom-left are a bistable display shield, microSD shield, low power boost board (as low as 0.6V to 3.3V), Peltier shield (thermal to electricity, ~20mV to 4.1V), vibration energy harvesting shield, a stackable LiPol / thinfilm battery power shield, and of course the Mosquino mainboard itself. You may have seen early versions of some of these on the Mosquino page already, but these implement bug fixes and the latest/finalized Mosquino pinout. Can’t wait to get playing with these!

(And no, purple is not the official / final color – The PCBs were made via Laen’s sweet batch PCB service; he likes to experiment with the colors from time to time. It’s not a ripoff of Lilypad…although the Peltier board can potentially harvest from typical bodyheat gradients (>=2degC), which is an interesting development for wearable computing projects to say the least!)

How to use your own modem with Comcast

Typical frog in a hot pot scenario; when I joined Comcast the modem lease was like $1.50 a month, and I didn’t even think about it. As of recently it’s now crept up to $7.00 a month, which kind of made me sit up in shock. How much do those things actually cost, anyway?

Answer: $16 on eBay!

Ditching the leased Comcast cable modem in favor of your own is a surprisingly simple process. In my experience, Comcast won’t even try to (intentionally) stonewall your request or tell you it can’t be done in order to keep the revenue. Unfortunately, their techs are not exactly the brightest lights in the harbor, so you might have to train them a little on how to do it. Here’s how…

Step 1: Buy the modem
Go to your favorite new or used equipment source and buy the modem. Make sure your purchase includes any necessary power cord (wall wart); if not, buy that too. Theoretically, any DOCSIS 2 or later modem will work with most cable Internet packages, but to be sure, check this list for modems tested and approved by Comcast for compatibility. Extremely fast or fancy internet packages might have special requirements. Personally, I just searched eBay for the exact model # of my existing leased modem, and bought that one. My total cost was about $21 for the modem and a 12V wall adapter.

Step 2: Plug in the modem
Before you go connecting anything, turn the new modem over and copy down the “HFC MAC” number printed on the bottom to someplace more convenient. Note, there may be several different numbers printed on the modem; the “HFC MAC” is what you want. Technically the “number” is in hexadecimal, so it can also include the letters A-F. Double- and triple-check that you copied it correctly!

Disconnect your leased modem and plug the new one in its place. Verify that the lights come on and blink just as with your old one. (It will still ‘see’ a modem signal when connected, even if it’s not activated yet.) Once it’s lighting and blinking, power-cycle your wireless router (or whatever attaches to the modem Ethernet cable) to make sure it picks up a fresh IP address from the new modem. Just to be safe, reboot your computer(s) after this to make sure the newly rebooted router gives them a fresh address too. Now your modem, wireless router and computer will be “connected” to one another as far as your home network is concerned, although they won’t be able to reach the Internet through the new modem yet.

Step 3: Activate the modem
The one and only piece of information you (and Comcast) will need for this is the “HFC MAC” number you wrote down earlier. Call the Customer Service # on your Comcast bill, and say to them:
“Hi, I’d like to use my own modem and return my leased modem.” When I did this, the main customer service gave me a separate phone # dedicated to handling this request. Call that # and repeat the request.

The Comcast person on the phone will ask for the number from your modem. Not all of them are smart or well-trained, so they may not know which number, nor tell you the correct number to provide. Whatever they say (or don’t), give the “HFC MAC” you copied earlier. Now, this is important! Have the Comcast person input the number and then recite the number back to you, to make SURE they input it correctly. This is important!

Before you hang up, start accessing Web sites and see if they start working. If the Comcast person input the # correctly, your Internet should start working again almost immediately. If not, login to your wireless router’s status page (consult its manual for how to do this) and make sure it obtained an IP address, gateway IP and DNS servers from the modem. This information may be listed under a section titled “DHCP” (a protocol for devices to request and assign IP addresses.) Try powercycling the router again while the modem is activated to make sure it gets an address.

Step 4: Return the old modem
Hopefully, everything is working now! The last thing to do is to pack up the old modem and its wall plug in a box and return it to Comcast. If it came in an official Comcast box (e.g. “self-install kit”) and you still have that box, use that box – but if not, my experience is they aren’t that picky (I used a shoe box). There is a brick-and-mortar Comcast service/payment center by my house, so I just returned it in person. If this is not an option, ask the Comcast person how to return it by mail. My experience at the Comcast payment center was very positive – just handed the modem over, they scanned a barcode on the bottom and it was automatically credited to my account. They handed back a receipt with my name/account # and the modem details on it and I was on my way. My next bill had a partial refund for the part of the month I was no longer leasing the modem. Done and done!

If all does not go well…

If your new modem isn’t delivering the Internet goods after activation, the Comcast person (billing department) will transfer you to a separate department (tech support), who have the power to ‘ping’ your modem and make sure it is visible on their end. ‘Your’ modem in this case is defined as the modem matching the HFC MAC # linked to your account, which is why it’s very important that the billing person has input the correct #, and input it correctly, BEFORE this point. Otherwise they can ‘ping’ all day and not get any result because their system is looking for the wrong damn modem! The Tech Support person has the power to ping but NOT the power to add or correct MAC #s on your account, so this sucks. Likewise, the billing department has the power to enter MAC #s, but NOT to ping the modem! If this magic number entry gets cocked up somehow, it will take a 3-way conference call between you, tech support and billing to sort it out, and not all Comcastic techs know how to pull this off with all those complicated phone buttons. I spent two hours bouncing between departments because the barely-English-speaking billing person miskeyed the # the first time.

For the insanely bored or curious…

“MAC” number stands for Medium Access Control number, which is a globally unique number (burned into the device by the manufacturer) that identifies YOUR device among the millions of others out there just like it. The “medium” referred to is the physical cable. Since your block’s local cable segment is a shared resource, this number is necessary to identify you as a paying customer and route the right bits to and from YOUR specific modem. The difference between the separate “HFC” and “CPE” MAC #s is that the HFC number (I’m told this stands for “Hybrid Fiber-Coax”, i.e. residential cable networks) is the one that’s visible on the coax (cable) side of the modem that your ISP sees, and the other (“Customer-Provided Equipment”) is the Ethernet-side number that’s visible to your equipment (e.g. wireless router). Don’t tell Comcast that number by mistake; they can’t see it on the cable end.

I P, U P, everybody (DHC)Ps…

My page that tells you your IP address is up and running again, after a PHP configuration change by my web host knocked it out. Anyway, enjoy the glory of finding out your external IP address without getting socked by porn popups!

Image segmentation for PnP optical placement





Quick ‘n dirty (but working!) image segmenter for randomly-strewn part identification. About 1 page worth of scripting takes an image of objects on background, determines which part is the background, determines the outside contour of each object and numbers each as a separate object. Now that it’s known where to look for one specific object, the task of identifying that object (or just matching it to another just like it) becomes a whole lot simpler. Combined with the auto-aligner, this reduces a “naive” (bruteforce cross-correlation between needle and haystack images) image matcher to only having to scan against 4 orientations (90-degree rotations) to find which has Pin 1 in the right place (and whether it’s the same part, etc.) Hopefully as I dig deeper into opencv, there is a less-naive algorithm builtin for this that does not rely on contrast/color historgrams: most electronic parts basically consist of a flat black body and shiny reflective metal leads (i.e. appearing the same color as your light source and/or the background, and/or whatever happens to be nearby at the moment). Edge-based stuff still seems like a better approach, though I would welcome being proven wrong if it means not having to write the identifier from scratch myself :-)

Steps in brief:
The first image was taken using the actual webcam that will be attached to the pick n place head, looking at a handful of representative parts on a piece of white paper. This image was dumbly processed using a Sobel edge-detector (it’s builtin to Gimp and I was feeling lazy), Gaussian blur to expand the soon-to-be-resulting mask around the part a little and close any gaps in the edge-detection result, and finally threshold the result to produce the second image. The goal in these steps is to produce a closed-form contour blob for each part that’s at least as wide as the part, while minimizing stray blobs from random noise / dirt specs / etc. (internal, fully-enclosed blobs/noise due to part features/markings is OK). Finally, opencv’s FindContours function is run (mode=CV_RETR_EXTERNAL) on the resulting image, returning a vector that contains a polygonal approximation of each external contour found. Each discrete (non-touching) contour blob is returned separately, that is, every part in the frame is now effectively tagged and numbered!

There are a couple noise points identified in the image above. Better-chosen constants for the initial image operations (threshold, blur radius, …) may help, but I’ll probably end up having it measure the area of the blobs and throw away any that’s too small to possibly contain a valid part. Switching to a more advanced edge-detector, e.g. Canny, may help too. In any case, the full image matcher should figure it out eventually :-)

Code Demo – basically ripped straight from the pyopencv examples
Segmentation example – requires Python (2.6) and opencv 2.1.0 / pyopencv.

Pick ‘n Place Head

This weekend I got some parts in and put together a preliminary placement head for my open-source pick ‘n place project. My requirements are that it be buildable with off-the-shelf parts (ideally same-source, to save on shipping) and no special equipment, allow +/-180 degree rotation while maintaining an undisturbed vacuum, and support interchanging of the “tools” (vacuum needles). All that’s really needed to build this are the discrete parts shown, a bit of drillable plastic (e.g. Delrin) for the base material, and a drill. A drill press would be handy (a CNC mill *really* handy, and not such an out-there thing to have considering you are probably retrofitting this onto one).

This head consists of a hollow rotary shaft with a Luer lock fitting on one end, right-angle flexible tubing barb on the other end, and a large toothbelt (notched belt, timing belt) gear in between. The shaft is held in place but allowed to rotate by a pair of bearings, and the rotation is provided by a small stepper motor at the other end of the toothbelt. The gear ratio is approximately 5.2:1, providing a rotational resolution of about 0.35 degrees/step with a common 200 step/rev stepper motor (if no microstepping is used). Finally, just to the left of it is a 1024×768 Webcam with manually adjustable focus and a ring of built-in LEDs for lighting. The webcam mounting is definitely not ideal, given the camera’s weird eyeball-like shape. Tentative plan is to lash it down with some string, align it nicely with respect to the CNC table, then backfill the opening the camera’s butt sits in with epoxy.

The hardest part was finding a combination of parts that would all fit together nicely. Currently, the fits are mostly exact to “pretty damn good”, but a bit of adhesive is needed to join them permanently.

Parts List
Unless otherwise noted, all of these parts were sourced from Small Parts Inc. in the US due to the large selection and an actually competent parametric search engine, which was a great help in finding combinations of mutually-fittable parts. Accordingly, measures are in Imperial unless noted otherwise (that’s just how they come here).

Partnumber Desc.
3002DSTNTG18 Nice Ball Bearing 3002DS, .250″ bore x .6875″ OD x .250″ width
BFM-250-P Mounted sleeve bearing, .250″ ID, 1 17/32 center-to-center bolt spacing
B00137SITY Steel tubing, 1/4″ OD .152 ID, 12″ long
40DP-14/S-01 Timing Belt Pulley Delrin, 0.0816 Pitch, 40DP, .350″ Diameter, 1/8″ Bore, For up to 1/4″ Wide Belt, 14 teeth
40DP-70/S-01 Timing Belt Pulley Delrin, 0.0816 Pitch, 40DP, 1.806″ Diameter, 1/4″ Bore, For up to 1/4″ Wide Belt, 70 teeth
TB188-090-01 Timing Belt Urethane/Polyester, Single-Sided, 0.0816″ Pitch, 0.1875″ Wide x 7.3440″ Long, 90 Teeth
LCX-LC005 Male Luer Lock to tubing adapter, .145″ OD hose barb (mates well enough with .152″ ID steel tubing)
F1-EL001 Elbow Connector , Classic Barbs for 3/32″ ID Tubing, .145″ OD
HSTA-08-24-10 1.5″ aluminum standoffs, 8-32 thread
B00137UP68 (Optional) 11ga Steel Tubing, .120″OD, .094″ID (for mating 2mm shaft stepper motors, if used, to the 1/8″ pulley

Misc. Parts
2x 2″ x 4.5″, 1/4″ thick pieces of Delrin or similar
4x 1/2″, #4-40 bolts and nuts (assuming 2 bolts for stepper motor)
4x 1/2″, #8-32 bolts for standoffs
1x Webcam, manual focus, hi-res and builtin lighting strongly recommended
1x 3mm shaft stepper motor*
1x Method of attaching to your mill – a bit of aluminum angle bracket, or a dovetail, etc., depending on your mill.
1x 3-way air solenoid valve
1x Vacuum source (see here for a cheap one)
Air tubing and appropriate couplings to your solenoid valve. The head’s air path terminates in a 3/32″ hose barb, so you’ll want a 3/32″ to (whatever) barb adapter, or a 3/32 that screws directly into your solenoid. Those using metric are on your own :-) but will probably have an easier time of it anyway.

* The timing pulleys and stepper motors only come in a handful of diameters (imperial for the pulleys and usually metric for the small motors), so a 3mm (.118″) motor onto a .125″ ID pulley was the closest I could come up with in a reasonable amount of effort. Any small, el-cheapo permanent magnet (“tin can”) stepper motor should work here, but sourcing it may be annoying. Off-the-shelf 3mm-shaft motors I found are Jameco’s ValuePro 42BY48H08, Anaheim Automation’s TSM42 series, and Portescap’s 42/44 series e.g. 42×048 and 42S100. This surplus stepper is also worth a look, but you’ll have to remove a pre-attached plastic(?) gearhead. Beware, many of these smaller motors are 7.5deg/step, so even with the gear reduction, you will probably want to look at microstepping them to ensure adequate rotational resolution. Also, most of the companies selling them have no online click-and-buy ordering; you’ll have to phone up a salesdouche at the least, hope that you are worth their time to buy One Lousy Motor, and possibly haggle (“Request a Quote”). How companies that don’t know what their product costs stay in business is beyond me, but that’s a rant for another day.

If you want to skip that hassle, I’ve taken an alternative approach and simply bodged a surplus 2mm-shaft motor up to a 3mm shaft by gluing a short piece of thicker steel tubing onto the existing shaft (see partlist).

Design Files
CamBam drawings with machining operations for the top and bottom plates. The machining ops assume 1/4″ thick plastic, 1/8″ endmill for most cuts, and .166″ (#19) drill for the #8-32 bolt holes into the standoffs. It’s designed for the Cubeternet webcam (or equivalent eyeball-cam) and a stepper motor with 42mm center-to-center mounting holes. You can get the free CamBam at http://www.cambam.co.uk/.

Note, I made some small improvements to these files after the above prototype was carved, so what you see in the file will not match it exactly. In particular, the standoffs were moved to more optimal places and a feature has been added allowing the motor to be slid to remove any slack in the belt.

Assembly
The assembly should be pretty self-explanatory. One bearing on each of the Delrin plates (inset the ball bearing if you can; otherwise gluing it down should be fine). The hollow shaft goes thru the bearings, Luer adapter and hose barb go on either end (use adhesive, just don’t clog the air path with it). The motor shaft center should sit just a hair (50-100 mils?) over 1.75″ from the hollow shaft. On mine, an online calculator produced the 1.75 figure, but the belt turned out to be a bit loose once built this way. If possible, make an elongated hole for one of the motor screws so the motor position can be adjusted to tension the belt. You could probably also insert a peg somewhere in the belt path to push it inward and take up the slack. With the camera focus set such that the largest part you will ever populate can fit in-frame, find the resulting camera height (distance from part) and set the depth of the shaft so that the camera is “in focus” maybe an inch or two above the placement position (i.e. with the needle touching the board). This will allow the head to focus on parts without touching the needle down.

For my build, I used instant glue to attach the Luer adapter to the needle shaft, and hot-melt glue to tack down the large pulley and hose barb. None of these parts should be seeing significant force; if they are, you’re Doing It Wrong and the hot glue should hopefully break loose before something more important does. Using a non-permanent adhesive for the hose barb and pulley also allows this assembly to be disassembled later if needed. The shaft itself is free-floating and the large pulley rests against the ball bearing due to gravity. This will prevent damage due to crashing the needle into the table or too-tall part, but if you experience problems with the shaft riding up on its own, try adding a bit of extra weight or put a dab of adhesive where the shaft passes through the lower bearing.

Suggested “v2” improvements
–Move air valve (if/when one is specified) onto head to minimize air volume between valve and head. Needed? (may be beneficial for reversed aquarium pumps or other weak vacuum sources)
–Bump detect: rather than firmly adhere the shaft into the bearing, allow it to float up and down, normally resting by gravity with the large pulley against the ball bearing. Place a contact switch just above the pulley: if the head/part contacts the surface with more than minimal force (enough to lift the shaft), contact switch is triggered. This could be used to halt the machine if a bump was not expected. If the switch’s trigger position is reliable enough, it could be used intentionally to automatically determine component heights.
–Probe function: There is a conductive metal path from the needlepoint all the way up to and including the bearing outer race, so it would be easy to touch a contact here and use the needle to probe for any conductive objects (e.g. find the tabletop if it is metal, or some capacitive shenanigans for PCBs/etc.). Useful?

Toward an open-source Pick and Place machine

So, there’s some really cool, empowering stuff going down these days with regard to manufacturing. Cartesian machines (i.e. CNC mills) are relatively simple to build from off-the-shelf parts; there are a bajillion people doing this and plenty of ready-made open-source designs available. More recently, hobbyists have gotten in on designing open-source rapid prototypers (3D printers); as a result, designs have now crossed the sub-$1000 threshold off-the-shelf, and you can even build a GPL’ed 3D printer that can almost replicate itself!

One thing that I haven’t seen cross the blood-brain barrier of proprietary commercial systems is pick-and-place machines that can assemble electronics. These things are badass; full of automated win and articulating robotic arms, but they’re also damned expensive: the crap ones start at >$10k and use literally a fishing-lure-and-weight type arrangement to peel back the tape covering tape-and-reel parts, so you have to keep resetting the weights. Those with more advanced / less manual feeders scale skyward from there. And of course, the software end of these things, especially machine vision algorithms to place parts more accurately, is some serious $ecret $auce. So… let’s change this!

Most of the “big stuff” is straightforward: The PCB layout software generates a list of coordinates for each part. A small vacuum needle mounted on a Cartesian head picks up each part from a known location, rotates it 90/180/etc. degrees as needed, and sets it down at its coordinates. It does not even need to be 100% accurate: surface tension of the solder during reflow will pull most minorly misaligned parts back into place.

The big barriers are:

1) Low cost / self-manufacturable feed mechanisms:
Electronic parts are packaged in several different ways, most commonly tape-and-reel, plastic tubes, or in trays. Each has a different, maybe cumbersome, way of knowing the location of the next part in the package and freeing the part from the package. Picking up stuff and putting it down is easy compared to dealing with the wide variety of tape and tube sizes reliably. Oh, and if your board uses 50 unique parts, you need 50 feeders. Hence the emphasis on making them cheap and mass-self-produceable, e.g. by CNC or casting or 3D printing.

and/or…

2) Machine Vision
For larger parts, once the first part is successfully picked (e.g. by human intervention), it is enough to know how many parts per inch of tape, advance the tape a known amount per pick, then just grab blindly for the part and plant it at its destination coordinates. But for smaller and finer parts, this is not accurate enough: the parts can be slightly off-center or crooked in their tape wells, and this becomes significant as the part size decreases. Professional machines use a set of cameras and image processing algorithms to recognize the part, find its dead center and correct any rotational error. In theory, a suitably good vision system would allow you to peel back the tape and just sprinkle the parts on the table, forgoing feed mechanisms entirely at the expense of some small manual labor. Actually programming this algorithm on the other hand…

Another nice thing to have would be:

3) Automatic needle swapping. Many more advanced CNC mills are able to spit out their current tool, e.g. a specific size drill bit (in a known location in a tool rack) and pick up a different tool. It would be nice for the pick and place machine to be able to change to smaller and larger needles/suction cups to handle large and small parts seamlessly. If not, placements can be sorted, e.g. smallest to largest, so that the needle only has to be manually changed a couple times.

I’ve made some very initial feasibility-study stabs at building such a machine, and begun building a bit of hardware. I created a separate page for this project with more detailed specs/documentation and progress so far:
Pick and Place Project

I quit, I win, final, no talkbalks

It’s like third grade all over again, except that I could theoretically have ice cream for breakfast if I wanted to.

Windows 2000/XP Driver for (some) Veo Stingray and IBM PC Camera V5000 webcams

UPDATE: For Veo Stingray drivers, try these first. In case they disappear… Stingray 300V (Win98/ME/2000/XP) and Stingray 323V (Win2k/XP only). The one sold by AllElectronics uses the 323V driver.

I picked up an old “Veo Stingray” camera from surplus dealer AllElectronics. These things are pretty junk by modern standards (320×240 resolution, unsightly rounded “looking through a tube” image), but it does have the variable (manual) focus I needed for an imaging project, and the price was right. As for drivers… the company that makes this thing seems to have evaporated, and the particular variant (USB product ID 808B) seems to have never been heard of by anyone, even though there are some identical cameras with slightly different internal hardware (and different Product ID) floating around. They all are (were?) manufactured by Xirlink.

This particular variant can be identifed by USB VID 0545 (Xirlink), Product ID 808B.

Here is a solution that might work (but see update above first): This camera and several IBM PC Cameras use the same or similar chipsets (Sunplus SPCA5xx)…with a small tweak, the IBM camera driver can also be tricked into supporting the ‘808B’ Stingray (maybe others?) by adding its VID/PID to the driver .INF file. Kinda like slipping your cuckoo egg into another nest.

This file includes the IBM driver and tweaked .INF. The following devices are supported:

%XIRLINK.DeviceDesc%=Xirlink.Device,USB\VID_0545&PID_8002
%XIRLINK.DeviceDesc%=Xirlink.Device,USB\VID_0545&PID_8080
%XIRLINK.DeviceDesc%=Xirlink.Device,USB\VID_0545&PID_8009
%XIRLINK.DeviceDesc%=Xirlink.Device,USB\VID_0545&PID_808B

To install, follow the README.TXT included.

Win2K/XP Driver for Veo Stingray (808B) and IBM V5000

Linux?
It looks like several open-source driver projects may support the Veo Stingray, IBM PC Cameras and similar SPCA50xx variants (not to mention the classic Dakota Digitals). Note, if your exact ID is not listed as supported, you may be able to get it working with a tweak similar to the above. Have a look at:

http://xirlinkwebcam.sourceforge.net/
http://www.linux-usb.org/ibmcam/ (older project)
In addition, the package ‘gspca’ may work for these and many other SPCAxxx-based (and other!) webcams. See here for the gspca/spca5xx project and a list of supported cameras.

Tubthumping (or, Sears/Kenmore washers are shit, do not buy them)

So there we are, minding our own business, when an angry demon springs to life in the basement. He is on a rampage, pounding against the walls with all his might, THUMP THUMP THUMP THUMP BANG BANG BANG. We race downstairs. Turns out it is only the Sears Kenmore front-loading washing machine’s internals beating themselves to death during the final spin.

After ruling out an unbalanced load (even fully empty, BOOM BOOM BOOM), I lookup the symptoms online. After a few thousand pages of angry ex-customers’ rants, without even lifting a wrench, there is no doubt what the failure is.

All available evidence confirms that this machine is DESIGNED TO FAIL EVERY FIVE YEARS*. The fuse is an innocent-looking metal bracket on the back of the spinning clothes basket known as a spider; its purpose is to support the basket on the drive shaft leading back to the motor. This spider, an uncoated pot-metal part made of a brittle Al+Fe alloy, is fully exposed to and tumbles its way through all the detergent, bleach, dirty laundry water, etc. After a few short years of this, it corrodes through and shatters during the spin cycle! Of course, you can’t buy just this part; you have to plunk down for the entire basket/etc. assembly at $200 a pop**. Guess who now has a nice spare stainless steel basket laying around to turn compost in, heh.

My brief description does not do this problem justice, but there is an excellent video from a former Kenmore owner detailing this spider issue and several other, likely intentional, design flaws.

So, you probably guessed what I did next – took it apart. The insides of the plastic wash tub are a bitch to get at (nondestructively); the whole thing has to be carefully unhooked from a pair of shocks and large springs, liberated from half a dozen hard-to-reach hoses and tubes with fiddly retaining clips, and the glued-on rubber seal cut away from the front of the machine. There are also cinderblock weights (yes, really!) on the tub which ought to be removed unless Hulk Hogan is helping you lift it out. On mine, the bearing surfaces were also so rusted, it took beating the living hell out of the shaft with a big hammer to separate the assembly from the tub.

Here is what I found inside:



One rotted, broken-ass spider. Surprised? Also note all the "used to be spider" white crud packed in beneath the bearing.


One rusted-out shaft for a rotted, broken ass-spider.


One reaction vessel washtub for a rotted, broken-ass spider. Yuck, my clothes were in there? The white crap looking like crushed concrete at the bottom is corroded bits of spider that haven’t yet ground away at the pump impeller while making their way to the city’s sewer. You can also see where the grease has begun leaking out from the cheap rubber lip seal that’s supposed to be keeping water out of the bearings.


One rusted-out hole for a rusted-out driveshaft to grind slide into. "That’s not my mating surface, baby!"

All this because Sears/Kenmore*** could have easily solved this with $1 worth of engine paint (etc.) to coat this fiddly metal bracket, but chose not to. Also, like in the video above, my outer tub has a nice deep gouge line where the screws in the wildly-flailing basket tore it up. Luckily we were home when it went, and our catlike reflexes caught it before they could carve all the way through.

*says everyone on the Internets. Don’t McLibel me.

** and if you want to save the hassle of retaining clips patwanging across your basement and the Hulk sneaking looks up your skirt, and have the new part installed by an authorized repairman… there’s a reason they have those commercials with the repairman playing Solitaire all day because no support calls come in… it really is cheaper to buy a new machine. ($75 diagnostic visit + $450-$700 repair quotes vs. $500-600 for current units.)

***technically, Sears/Kenmore just buy the appliances from other OEMs and put their names on them. This particular model (417.42142100) is made by Electrolux; others are rebadged Frigidaire or Whirlpool units. Unfortunately, all seem to share a similar design, right down to the fail timer.

No, she cannot has cheezburger. Laser pointer, yes!

We got a kitty last weekend. Like many new additions of the human kind, we hadn’t really planned on it*, but now we are in love with her. Her name is Spirit (she comes pre-named).

She had no trouble settling into the new house, except for spooking out at the noise from the radiators at first. She’s such a little attention whore – follows the hyoominz all around, and if we are on the couch, sits down next to someone and headbutts them ’til she gets belleh rubs.

So far she has also discovered that Christmas tree ornaments swing and make a tinkling noise when swatted at, knitting needles move and click while in use, and must therefore be attacked, and – OMG WIIMOTE CURSOR!

http://www.youtube.com/watch?v=pr2UmofoYAE

http://www.youtube.com/watch?v=dFuf_wMFs1E

*Somewhere between “rescue mission” and “interstate feline trafficking” does the truth lie.

Banned from Google (or, How I Became A Dirty Rotten Spammer)

An update, 1/28/2011: It turns out there was a legitimate problem on the site after all! Specifically, hacked by spammers at some point and filled with invisible links & keywords. Skip down to the comments for the details, and be aware that the rant that follows is based on a fairly complete lack of information! (Said information being over a year in coming, but I have to say that hearing it from the man in charge himself pretty solidly exceeds my expectations….and makes me hang my head in shame a little for even thinking of defecting to Bing.)

So, as of sometime within the last few weeks or so, I am a convicted Google Spammer! As you may guess from this tone, I have not actually done or considered any such thing. But as tends to happen when you take all humans out of the loop and put all faith in the smartness of an infallible Algorithm, you throw your fair share of babies out with the bathwater, and today, one of those babies is me. I discovered this (not like I would have gotten an email or anything) when I happened to Google the name of my product to get to its mainpage (much faster than typing the full URL, which is longish), and it wasn’t there. With some further digging, I found my entire domain and all subdomains have been blacklisted from Google’s index.

That particular level of digging leads to a tool called Google Webmaster Tools, which, after proving myself the owner of the site, returns this:

This site may be in violation of Google’s quality guidelines. More Details
Pages on your site may not appear in Google search results pages due to violations of the Google webmaster guidelines. Please review our webmaster guidelines and modify your site so that it meets those guidelines. Once your site meets our guidelines, you can request reconsideration and we’ll evaluate your site.
Submit a reconsideration request

Full stop.

These webmaster guidelines cover “quality” (i.e. don’t spam the index)–including such helpful first-grade spam no-nos as not stuffing pages with invisible keywords, bogus META tags, providing special fake pages to known search bots, and other stuff that might have worked on Lycos in 1996–as well as various style-guide suggestions, admonishing webmasters to be on their best grammar, and even going as far as discussing size and placement of images on the page. Is a webmaster really expected to perform feng shui to stay in Google’s good graces?

Anyway, I’m at quite a loss to explain why I would be banned from Google, as getting an entire high-ranking site removed from a search index seems like something that would require some pretty big-ticket shenanigans. Of course, this is The Algorithm we’re talking about; there seems to be no indication that a live human was involved in this decision*.

Of course, any of the usual SEO tricks would fit the bill. But I don’t engage in any of that (for here, the boards or the main site), and the only “optimization” I do to this blog’s traffic is to post something interesting once in a while. (Really, since everything on this server is ad-less and free anyway, the only thing More Traffic can get me is a bigger bandwidth bill.) I do know that Google will display warnings / block content if it detects a site has been compromised, but a thorough dig through the server-side files indicates this is not the case, either.

So what’s left are some straws to grasp at:

  • Legitimate incoming links from adult-ish sites and adult-ish search queries for my side project
  • “Bad Words” or links appearing in message board posts (forget this piddly blog, what the rest of the free world knows cexx.org for is one of the oldest continuously running spyware help forums in existence. Posts here–especially diagnostic logfiles posted by affected users– contain references to bad programs/sites, links to same, and repetitive content (e.g. Windows registry trees) that occasionally generate false positives. A human would easily see that we are helping people rather than spamming the world; The Algorithm may not do as well.)
  • Occasional comment spams slipping through in UGC (“User-generated content”, the current buzzword for “stuff the site owners didn’t write themselves”, such as blog comments, message board posts, every video on Youtube, etc.) As you can see from the numbers showing at the bottom of this page, comment spam is as fundamental to the Internet as the threat of rickroll, and the filter’s doing pretty well at blocking them. If transient v1@gra comment spams were grounds for being delisted, half the internet wouldn’t show up. Then again, for those of us who have not used Lycos et al lately, how would we google-addicts know if half the internet wasn’t showing up in our searches…?)
  • My content being scraped and appearing on third-party spamblogs (yes, it happens. I–of all people!– have fired off a couple DMCA takedown demands in the last couple years, but really, for splogs on splog-friendly Korean ISPs this has about as much effect as firing off complaints for every email spam your receive. These automated scrapers usually end up scraping from someone with deeper pockets and much better arm-twisting power at some point, and the problem (for lil old me) solves itself.)
  • Old pages/posts, dead links, occasional bad grammer or speling mistakes?
  • Maybe Google are still mad at me for exposing a huge bug in their search some years ago? (In theory, this would make it trivial for someone to determine whether they ranked higher than a competitor, or see how a specific tweak to their keywords/etc. affected their ranking. But since I’m pretty sure no humans were actually involved in this, I kinda have to rule this hypothesis out…)
  • Statistically anomalous distribution in keyword content of sites that link to mine?
  • Statistically anomalous distribution of topics I discuss, tag clouds, etc. (or as mentioned earlier, help forum posts)
  • Someone I’ve pissed off in the past robo-submitting my URL to the automated “report a spammer” page?**
  • Googlebombs or other shenanigans performed (maliciously or not) by third-party sites?
  • Wild Conspiracy Theories (paid off by a malware company? Malware authors have been trying to block their victims from being able to reach help forums such as cexx.org’s for years; maybe the’ve found a way to up the ante. Or maybe Sergey bought my Trance Vibrator and didn’t like it.)

The possibility that any site could be delisted by the actions of third-party sites (e.g. competitors) is simply disturbing. As unlikely as I’d hope it to be, Google’s complete secrecy regarding its delisting criteria (even I, after proving myself the legal owner, can’t get boo about what’s going on with my own site) makes such a scenario impossible to rule out. For what it’s worth, Google does explicitly mention links to “bad neighborhoods” in this Guidelines page, and some sites by and for the SEO people (who presumably know their stuff, this being their entire business model) seem to think this does apply to incoming links as well.
That is unacceptable.

If I haven’t gotten to the bottom of it soon, my only choice might just be to block Google from the site outright (why pay for the bandwidth their crawler uses if we are being excluded from the results?) and personally wean myself from Google search, for whatever that is worth as a personal stance. Is my best alternative really “Bing, and it’s done“?? Google, you really put me between a rock and a hard place.

* nor, based on analysis of the server logs, the “Reconsideration request” you can submit via the Webmaster tools thingy. Unless there are human reviewers lurking in an underground bunker somewhere disguised as residential cable customers from Peoria, or a vast distributed network of speed-readers who are each assigned one line to read, the speed of the hit-streams identifiable as coming from Google during the time of said review easily beat my personal best, and, much like the MTV Music Awards, show no evidence of human intelligence.

** From said page: “If you believe that another site is abusing Google’s quality guidelines, please report that site at https://www.google.com/webmasters/tools/spamreport. Google prefers developing scalable and automated solutions to problems, so we attempt to minimize hand-to-hand spam fighting. The spam reports we receive are used to create scalable algorithms that recognize and block future spam attempts.” Great, The Algorithm is now in charge of deciding who the humans on the Web are.

My quickie guide for setting up mspgcc for ez430-cc2500

Mostly for my own reference for the next time I have to set it up on a new machine, but may help others on their first time install. Valid as of Feb. or so this year.

Software ‘shopping’ list (all free/OSS tools)
Set up the toolchain (mspgcc). There seem to be several important tools
missing from the mspgcc distro as of this writing, including ‘make’ and
msp430-insight (graphical debugger) that the docs claim are included
with the package. So the complete shopping list is:

mspgcc-win32:
http://downloads.sourceforge.net/mspgcc/mspgcc-20081230.exe?use_mirror=voxel
NOTE: This binary IIRC was not linked on Sourceforge’s downloads page at the time; there was only an older build and this link had to be fished from semi-private newsgroup postings. If there is a newer binary available, download that one.

MinGW/msys (provides ‘make’ and some utilities) :
http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe?use_mirror=voxel
If it gives you the options of installing minGW and msys, say YES to both.

CoreUtils (provides unix-like ‘rm’ tool required by make) :
http://gnuwin32.sourceforge.net/packages/coreutils.htm

Skipping the debugger for now until I figure out how to use it myself ;-) Seems to work occasionally under win32, but it’s flaky.

Required Knowledge Assuming you already know C and have the appropriate chip documentation/datasheets.
Have a quick read-through of the mspgcc FAQ and manual. Both are
reasonably short for what they are.
FAQ: http://mspgcc.sourceforge.net/faq/t2.html
Manual: http://mspgcc.sourceforge.net/manual/

The manual contains a lot of advanced stuff you can skip at first, or
skip entirely. This includes (at minimum) the stuff about customizing
the startup/end procedures, stack, the entire ABI section, inline
assembly, and stuff about building mspgcc (the package you get is
already built).

Get familiar with ‘make’. Outside of kinky application-specific tools
like the Microchip assembler/compiler and ‘IAR Kickstart’, the rest of
the free world uses make to automate compiling, linking,
installing/running and packaging their code. Go into the mspgcc
‘examples’ folder and find the blinking LEDs example (e.g.
E:\mspgcc\examples\leds). Open up the file called Makefile in Wordpad
and have a look inside. This is the master script that will smartly
handle all your compiling, programming the chip, and avoid you rewriting
lots of code whenever you change chips. The contents will probably look
like gibberish, there are only a few parts that are important for our
purposes. The make tool installed by mingw32 is named ‘mingw32-make’.

How make works is you specify one or more ‘targets’, i.e. things make
can do. Running make with no target specified compiles your program.
Some other targets are ‘mingw32-make clean’ (delete your old build and
any scratch files), or ‘mingw32-make download’ (compiles your program,
downloads it to the chip and runs it). All the necessary commands to
handle each target are in the Makefile.

Since the top half of the ez430 kit is essentially the USB Sy-Bi-Wire programmer, you have to change the download command to:

msp430-jtag –spy-bi-wire -lpt=USBFET -e leds.elf

I.e. in the Makefile you’d find and change the download section to:

download-jtag: all
msp430-jtag –spy-bi-wire -lpt=USBFET -e ${NAME}.elf

As long as you have the Makefile open, now is a good time to find the
CPU= line and change it to match the msp430 variant you are actually
using. In the case of the eZ430 board:
CPU = msp430x2274

Now when you #include the base generic as you will for most any
mspgcc project, it will automatically switch in the correct headers and
peripheral support for that specific CPU.

DIY-Spy: a homebrew 2.4GHz wi-fi spectrum analyzer

I was reading the Thinkgeek catalog a while back and an interesting gadget caught my eye: “Wi-Spy”, a 2.4GHz spectrum analyzer on a USB stick. Coming from the world where “spectrum analyzer” refers to a big benchtop box with a name like Le Croyright, we can’t afford those Agilent on it, my first thought was, “A good spectrum analyzer in the GHz range is like a gazillion bucks; what’s really inside this thing?”

Not much, it turns out. After seeing the guts I would not use this device for anything remotely demanding accuracy, but on the bright side, it would be pretty straightforward to make your own that works just as well! Possibly with parts that are already on your board (*cough*XBee).

According to this review and a couple other tech sites, the innards of the original are nothing more than a Cypress WirelessUSB SoC (CYWUSB6934) and USB interface. According to this updated review, the latest version switches to TI/Chipcon’s CC2500 radio ($2.15 USD in quantity) and retails for $399.

The “WirelessUSB” and CC2500 radios are inexpensive 2.4GHz radio chips used in devices such as cordless mice, game controllers and remote controls. What it has in common with many other digital radios is an RSSI (Received Signal Strength Indication) register, which can be read out to provide a measure of how much signal (i.e. interference) is present on any given channel. Wireless gadgets normally use such a mechanism to find the cleanest channel to broadcast on. Most any radio chip with an RSSI readout should work here: XBee, TI/Chipcon’s CC25xx parts, Nordic, etc. I have a big nut going right now for Nordic’s nRF24L01, but unfortunately this does not have an RSSI measurement to speak of (there is a 1-bit “collision detect” flag that warns if the RF energy on the current channel is above a set threshold).

So essentially, the firmware running on the dongle consists of:

for (channel=0; channel<255; channel++)
{
WriteReg(RF_CHANNEL, channel);
signal=ReadReg(RSSI);
send_usb(signal);
}

Hell, why didn’t I think of selling $2 of chip and 4 lines of code for $400? ;-) (I’ve even used those old Cypress radios before on a work project – Unigen’s ready-made JUNO module shown here is about 7 bucks.)

The DIY-Spy

As proof of concept (and a cool toy for anyone who has one of these lying around), I have implemented a working Wi-Fi spectrum analyzer on TI’s ez430-RF2500 development kit ($50), a 2-part USB dongle which consists essentially of a CC2500 radio strapped to an MSP430 low-power microcontroller (detachable bottom half) and a USB interface which enumerates as a virtual serial port (top half). The top half doubles as a standalone MSP430 programmer, so this kit is a great cheap way to get started playing with them.

Being the lazy efficient person that I am, I grabbed mspgcc and an existing ez430 RF demo program (JM Kikori’s RF2500 test application – raw transceiver) and just tossed the infinite RSSI loop into the middle of it.

Here is the main addition (simple & sweet). Forgive WordPress’ complete mangling of the formatting.


static void dump_rssi()
{
int i;
char rssi;
for(i=0; i<256; i++)
{
hal_spi_radio_writeReg( MRFI_CC2500_SPI_REG_CHANNR, i); // Channel number. Default spacing is ~200KHz/channel
hal_spi_radio_cmdStrobe( 0x34 ); // enter Rx mode (not needed except to start autocal)
rssi = (hal_spi_radio_readReg(MRFI_CC2500_SPI_REG_RSSI));
uart0_polled_putc((rssi&0xFE) | (i==0)); // Cheap speed hack: write upper 7 bits of RSSI value (throw away LSB). Use LSB to signal start of 256-channel RSSI byte list
hal_spi_radio_cmdStrobe( 0x36 ); // enter IDLE mode (not needed except for autocal)
}
}

The only real divergence of this from the pseudocode loop above is that the CC2500 requires periodic (or frequent, depending who you ask) recalibration, which can be set to be performed automatically on certain conditions (such as entering Rx mode). This setting is enabled, and the code above toggles between Rx and Idle modes between each channel change to trigger auto-calibration. To make things faster (for me as well as the gadget ;-), rather than perform any kind of real serial handshaking to keep the dongle and the graphing script in sync, I just truncate the least significant bit of the RSSI reading (1/2dBm) and use it to flag the start of the 256-channel sweep.

A more efficient approach would be to perform such calibration once per channel and cache the results (writing them back along with each channel change), which would in theory allow for much faster channel changes. But it’s really a moot point since here the 9600-baud connection to the virtual COM port (MSP430 <–> USB controller) is the limiter of maximum speed.

Most of the time in this project went into tweaking around with the CC2500’s fifty billion or so configuration register bits, not all of which are really documented. In the end I just installed their win32 configuration wizard for the undocumented voodoo (e.g. correct IF setting) and annoying math, and hand-tweaked the remaining settings. For this I set the base frequency to 2400MHz, and the channel spacing to ~ 405KHz, providing the frequency range 2400MHz to 2505MHz across the 256 channel settings. This corresponds to the 2.4GHz ISM band and a little extra. All automatic gain control features are disabled.

Testing
I’ve actually been sitting on this project now for a couple months, since I wasn’t getting the results I expected initially (sitting close to my WiFi access point) and had no good way to test it. Luckily, as it turns out I was tasked with developing some RF gadgets (nRF24L01-based) at work, which could easily be set up to output a raw carrier wave at a programmable frequency. Sure enough, testing revealed some bugs in my initial CC2500 register settings, now corrected.

The video above shows the resulting spectrum output as the nRF’s naked carrier is swept through a handful of frequencies. As it progresses, it should also become evident where my WiFi access point is broadcasting. The green lines show instantaneous signal, the red shows the peak value at each frequency, and the blue shows a running average. The display script is written in Processing.

Downloads

Fairly undocumented; use at your own risk.
diyspy.zip – Source code and .elf binary for ez430 kit (use mspgcc to build from source), .inf file for virtual COM port (win32 only), and Processing script for display.

Protected: A decade of thoughts… // Two’s complement (one’s a crowd)

This content is password protected. To view it please enter your password below:

Steppin’ Razor: Yet Another Cheap DIY, Homebrew CNC

After about an entire year of the parts sitting around, next-week, next-month, ya-I-been-meanin-ta, tonight I managed to get my homebrew CNC router* assembled into a usable (or at least testable) state. The entire design (if you can call it that! – it was really kind of ad-hoc) consists, as much as possible, of parts commonly available from any random big-box home improvement store (ours is the ‘Depot). The only ‘specialty’ (not available from the hardware store) parts are the electronics – stepper motors, driver boards, and power supply for the above – and machine parts such as ACME nuts and leadscrews, and some standard bearings to help hold the leadscrews in place. The machine’s linear bearings – commonly regarded as the holy grail of low-cost DIY CNC machines (good linear bearings are hard to come by and hard to make!) – are pairs of big industrial-style drawer slides (also from the Home Despot), carefully squared and bolted into place. Not a recommended approach for any remotely heavy-duty machine, but since I mostly intend to carve wood, plastics and the occasional PCB, this shouldn’t pose a huge problem.

Some videos of the machine running:
First test: carving a small face in a piece of foam
Closeup on the business end (Dremel-style rotary tool affixed to the Z axis)
The finished piece
Carving some zombies – here I got smart and attached a light to the machine
Bonus: Dry run (Dremel spindle turned off), showing the melodic sound of the stepper motors :-) (And in the background, the current-limit relay in my borrowed bench supply going nuts. The stepper motor drivers are now powered by a beefy 19V 6A power brick intended for a big laptop.)

Pics






The basic idea (for non-techies):
Imagine spinning a nut on a long bolt – the nut moves up or down the bolt depending which direction it was turned. The same can be done by holding the nut steady, fixing the bolt in place and rotating it – the nut will slide left and right. Attach a cutting head to this moving nut, and mount this assembly (that can move in one axis, e.g. up and down) to two more just like it that move in different directions (left/right, in/out), and you have a cutter that can be moved around in three dimensions by spinning the screws. Attach some motors and a computer can turn the screws automatically by driving the motors forward and backward, moving the cutter in a way that carves out a complex shape.

Components of interest (for techies):
3x Vexta stepper motors, PX245-02B-C8 (6V, 0.8A per phase): $5 each on AllElectronics (sold out shortly after I bought mine)
Stepper drivers: 3x Linisteppers, bolted to a pair of Pentium slot-whatever heatsinks and fan.
Lead screws: 1/2″ x 3′, 10 thread per inch ACME threaded rod (enco.com), with matching ACME nuts attached to the linear guides using J-B Weld (this stuff is amazing!). In retrospect, 10tpi is a bit overkill, and I have to spin the motors like crazy to move the axes at any speed (specifically, 10 rotations to move 1 inch), and stepper motors start losing a lot of torque at higher speeds.
Couplings (motor to leadscrews): Fat vinyl tubing sections and hose clamps

There are still some bugs to work out. For one, though the drawer slides on the X and Z axes are working well, the vertical orientation of the slides for the Y table produces unacceptable play. Basically, the internal part of the slide (the part that actually slides) can shimmy left and right slightly in addition to in and out of the rails that contain it, which gets worse the further these inner parts are extended out of the fixed rails. The force of the cutter pushing left and right into the material causes the table to skew a small amount, which both introduces inaccuracy in the cut and causes the Y table to bind (get stuck). I also still have not found a *good* way to hold down arbitrarily sized and shaped work pieces. Detailed build pics, yet-to-be-tested specs (accuracy, etc.), assembly guides(?) will be in a future post.

*What’s the difference between a router and a mill? Semantics, mainly. The terms are somewhat used interchangeably. From what I can gather reading forum posts on the subject, router implies higher spindle speeds, softer and thinner materials being cut (wood, PCBs), and higher speed overall, while a mill implies a heavy-duty, slower-moving machine cutting metal.

Stupid Excel Trick – amuse your friends & bore your enemies

What’s 1-2?

Today, MS Excel tells me it’s +39815. (Tomorrow it will tell me something different.)

Some while back a signup sheet went around the office for our annual lamb roast. Since every problem (nail) in an office environment has a preinstalled office-suite hammer, the signup list was an Excel spreadsheet. Once everyone has entered their number of guests, it totals up how many total guests. Here’s what I sent around before figuring out Excel’s flavor of crack.

Say you don’t know exactly how many guests you will have for the BBQ. Type a range (e.g. “1-2”) in and see what Excel computes for the total numbers of guests/folks.

For “1-2” guests by my name I get exactly 39084 total guests. Fixed by just saying “1”, but now I’m curious. How is it computing this number?

I can see that being parsed as “one minus two” and yielding a negative number of guests, but I can’t figure out what particular flavor of crack Excel is smoking to get 39,084. Anyone?

I mean, if it had returned NaN or +32767 (or some other signed-unsigned integer conversion failure), I might have understood.

An Excel guru eventually figured it out: The field was hard-set as a numeric field (no auto). Still, it parsed the expression, not as “one minus two” but as a date – “February 1, current year”, and since it was a numeric field, represented this numerically the best way it knew how: the number of days since January 1st, 1900.

The flavor is strawberry.