Posts Tagged ‘cnc’

Tape Sprocket Creator

This is a free (open source) Python script for creating feeder sprockets for e.g. perforated tape or film advance. I wrote it for myself to generate SMD tape-and-reel feed sprockets, but it might also be useful for making replacement sprockets for 8/16/35mm film, microfilm and paper-tape systems whose original reader hardware no longer exists or is difficult to find replacement parts for. The output is a .DXF template suitable for laser cutting, 3D printing or CNC machining. “Documentation” below, but it should be pretty self-explanatory. It should work with any modern version of Python (tested on 2.6).


Sprocket design goals / differences from other sprocket types

The drive sprocket’s dimensions are specified mainly by the number of teeth, width (or diameter) of the sprocket holes, and the pitch (distance between sprocket hole centers). The tape is usually advanced either tangentally to the sprocket, or partially wrapped around the sprocket. Thus the distance between the outside edges of any two teeth at any point, either tangent to the sprocket or along the circumference of the sprocket, should never exceed the distance between the outer edges of any two sprocket holes (the taper of the teeth is computed to counteract the radial splay of the teeth). Additionally, a landing area (flank) is cut at the base of the teeth matching the thickness of the tape, giving it a place to ‘catch’ when pressed against the sprocket’s inner diameter. Unlike e.g. roller chain sprockets or spur gears, no undercut (cuts below the inner diameter) is provided for rollers or a mating gear’s teeth, and no special geometry is needed along the sides of the teeth.

Some Terminology:

Pitch: The center-to-center distance between sprocket holes, and thus the sprocket teeth.

Tooth Face: The tapered portion of the tooth. In this application, the tooth taper is calculated to smoothly slide into the sprocket holes as the sprocket rotates.

Tooth Flank: The ‘upright’ (or slightly concave) base of the tooth. In this application, it should be the same height as (or slightly taller than) the tape thickness so that the tape sprockets rest fully within the flank.

Tooth Land: This is the surface left if the tip of the tooth has been blunted or “cut off”. This might be done to fit the sprocket into a particular diameter. I’m an EE; I don’t know what other dis/advantages pointy vs. blunted teeth would have in this application.

Basic usage:

Fill in all the values called for in ‘Basic Parameters’. Aside from angles, which are in degrees, use any unit of measurement you prefer (inch/mm/etc.), as long as it is consistent; output will be in the same units. If you desire a specific tooth taper angle, enter it, otherwise just press “Compute / auto angle” to suggest an angle and generate the sprocket.

Mostly, the pitch and sprocket hole width are dictated by the tape to be fed, and also drive the important diameters. You can get closer to a desired sprocket diameter by adjusting the number of teeth. The important diameters are:

Inner diameter: This is the diameter at the base of the teeth, where the bottom of the tape rests.

“Design diameter”: This is the most important diameter as far as the program is concerned, and is fully dictated by the pitch and number of teeth. The design diameter is the diameter at the top of the tooth flanks, which is the top of the tape. You could also think of this as the outside diameter of the tape if wrapped around the sprocket.

Outer diameter: This is the diameter at the tips of the teeth. By playing with the tooth angle and cutting off the tips (tooth length %), there is some leeway to constrain the outer diameter to fit the available space.

Note that the angle auto-suggest feature is currently broken (will return incorrect results). It will (usually) calculate an angle that will allow the tape to *wrap around* the sprocket at any radius from the base of the teeth, but what you really want is the tape to fit at an arbitrary angle across the teeth (specifically, the outer edges of whatever teeth it intersects while tangent to the sprocket should not exceed the outsides of the sprocket holes). For now you might have to cut a few gears and experiment, or just set the angle arbitrarily high.

Extra Options:
If you will be cutting out the sprocket on a CNC mill, outside pocketing will leave some material at the base of each tooth flank due to the diameter of the round cutter. Enabling ‘Remove cutter leftovers’ and entering the cutter diameter will add DXF points (drill hits) near the tooth edges to remove this material. Users of other fabrication methods can probably ignore this option.

If designing a sprocket in one measurement system for use in another, you can optionally select a unit conversion to be applied when writing out the DXF file. E.g. if your tape is specced in mm but your CAD/CAM software expects inches, select ‘mm to inches’ before saving the DXF.

I wrote this to solve a very specific need for one of my own projects; so very little time and debugging went into it. There is no idiot-checking. Expect errors or bizarre output if you leave necessary fields blank, mix & match units (inch/mm) arbitrarily, enter a negative number of teeth or any other physically impossible geometry. Even if you do everything correctly, there is no guarantee the output will be correct or meet your needs. Please check the results very carefully before you lay out any $$$ to have anything professionally made by a fabrication service!

Right now the arc between teeth is output as a straight line, not an arc or series of tiny lines approximating one. This should not be a huge problem for a reasonable number of teeth, but something to be aware of.

Other notes:

“Auto angle” calculation is only done if the angle field is blank: if there is a number there (including a previous auto-calculation), it will be left alone. If you have changed any parameters and want to redo “auto angle”, please delete the contents of this box.

The sprocket image shown in the program window is not to scale – it is automatically scaled to fit inside the window. It is not unusual for the sprocket to appear to change size dramatically when parameters are modified.

Square Pegs and Round Holes:
Unless you have some fancy software sweeping the sprocket teeth into 3D, you are probably making a flat gear out of flat stock, and it will have flat edges. If the sprocket holes are round, the tooth edges will contact somewhere earlier than the outside diameter of the hole, and so may need to be tweaked – especially if the material is thick relative to the holes. (See the diagram below for an exaggerated example.) Use this formula to calculate the effective tooth width that will exactly fit the hole:

w = sqrt(d^2 – t^2)

where d is the sprocket hole diameter and t is the stock thickness.

Better Better DXF Output for Inkscape (layers!)

I started using Inkscape, a sweet open-source vector graphics program, to produce (and/or steal from the internet and convert) designs suitable for carving on the CNC as Inkscape has a plugin to export the file as a .DXF. Converting some files, I discovered the current export script does not correctly handle all types of transforms, so some parts of the file may export out-of-proportion to each other or in strange size units regardless of the drawing units of the original drawing (Inkscape’s internal drawing unit is apparently equal to 1/90 of an inch, wait, wtf?). Also, if the drawing contains curved (Bezier) lines, these will be exported more or less as-is (DXF splines) and many free/cheap/itch-scratch-ware programs will not handle the resulting file (since the ‘correct’ representation or interpretation of splines is never disclosed in the published DXF file specifications, so everyone kind of does them in their own way, with less-than-stellar results).

Bob Cook noticed these limitations and updated the script to fix many of the ‘unusual transforms’ scaling issues, and convert Beziers to standard polylines that any program will import. It also adds some support for layers, including special ‘drill’ layers whose drawing objects will be output as single points (no lines) for hole drilling.

In theory, the layer support as he implemented it ought to work (it’s correct and in conformance with the DXF spec, which allows drawing objects to be assigned to arbitrarily-named layers throughout the file). In practice, many of the same free/OSS, low-cost and weekend-warrior tools do not handle this any better than splines. I dug up a copy of the DXF spec, played around a bit and found that these programs expect all layers to be formally declared in a DXF LAYER table in the header section of the file before use. So here is an update to the export script that generates a proper LAYER table, allowing a wider variety of toolpath generating programs to import them correctly. So far it has been tested with ACE Converter and CamBam and seems to work well, but as always this is a quick n dirty, not exhaustively tested script and there is no lifeguard on duty. (Inspect the imported files for problems before commanding your big machine to cut them!)

Better Better DXF Output for Inkscape

Just unzip into your \Inkskape\share\extensions directory. Note that the updated ‘’ replaces an existing file.

Note: There is still an outstanding issue with Grouped objects in Inkscape being exported with incorrect size. As I understand it (assuming the document structure sent to export scripts is substantially an SVG file), transforms are applied at the Group level, which is sort of a container that has the actual drawing objects (and possibly further nested groups) as its children. Guessing that to handle this correctly, rather than looking for transforms at the node itself, it must also maintain a stack of transforms that have been applied at the node’s parent level, and parent’s parent, etc. For now, it is an easy workaround to ungroup everything before export. Maybe someone with freetime can update this and release it as ‘Better Better Better DXF Output’ :-) (b3dxf?)

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.)


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 (, 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.


It’s not quite finished yet, but here are some pictures of what I’ve been working on this week, when not making you-know-whats in my basement dildonics facility.

First New England RepRap User’s Group Meeting at Olin College

Toward the end of July a couple friends and I had the chance to drop in to the first New England RepRap usergroup meeting. RepRap is short for Replicating Rapid Prototyper (a.k.a. 3D printer), the goal being an open-source machine design capable of making most of its own parts. The machine itself consists of a lightweight metal scaffold (made from inexpensive standard aluminum tubing and/or Home-Despot-grade threaded rod), a flat (wood/plastic) table, a printhead, and some stepper motors to move the table up and down (Z) and the printhead in the X and Y directions. The “printhead” (rather, extrusion head) pulls a thin strand of thermoplastic from a reel (kind of like extremely thick fishing line) into the moving head, where it is heated to its melting point and, on command, pooped (extruded) out of a nozzle onto the table starting at surface level. Successive layers of molten plastic are laid down, one on top of the next, to create a finished 3D plastic part.

[RepRap Usergroup Meeting Photos]

Here are some photos and a video of a machine in action. This particular machine is an older design, and didn’t seem to have survived the transport to the meeting very well (and based on the printed parts shown at the meeting, might have still been a work in progress – the RepRap blog shows the machine is capable of some much nicer parts). Still, it was cool to see an emerging disruptive technology such as this one in a state that proves its feasibility.