OpenSCAD

You are currently browsing articles tagged OpenSCAD.

I built a framework for robot wheels a while back using OpenSCAD and used it to create a few different wheel styles. I recently decided to combine them all into one massively configurable wheel model, and add a number of new features as well. The result is an OpenSCAD file with 46 parameters that provides a limitless set of combinations and wheel designs. I call it One Wheel To Rule Them All.

It includes twelve tread patterns (all configurable in often surprising ways), eight core spoke patterns (also highly customizable), configurable support for o-rings, bands, and even optical encoder timing slots (directional and non-directional), and a lot more. Plus, I’m still adding features as I think of them.

First, here are a few images of the types of the various basic elements, as well as a few variations that show the flexibility of the designs. For example, as shown in these images, the Spiral style can be used to create a variety of interesting designs that you might not think of when you think “spiral.” After the images you’ll find full details on the parameters.

It’s important to note that you can configure this wheel to such an extend that it may not be printable at home with extruded plastic printers. In these cases, services such as Shapeways could come in handy.

The source file is available at http://www.thingiverse.com/thing:21486, or on github at http://github.com/alexfranke/Highly-Configurable-Wheel.

Tire Parameters

Often wheels are built around the tires. In this section, specify the properties of the tires you’re using, and this will define the diameter of the wheel. If you’re using o-rings, the tireCSDiameter should be the cross-section diameter of the o-ring, or if you’re using some other flat tire material (such as rubber bands), jsut specify the its thickness. If you’re not using any tire at all, set the tireCSDiameter to zero.

  • wheelWidth: The width (or thickness) of the the wheel
  • tireCSDiameter: Cross-sectional diameter (CS) — How thick is the tire rubber?
  • tireID: Internal diameter (ID) — How wide is the inside opening?
  • tireStretch: Circumferential stretch percentage (usually 1 + 0-5%) — How much to you want to stretch it to get it on?

Rim properties

The rim sits at at the outside of the spokes and supports the tires or added treads. Installed tires (such as o-rings, rubber bands, etc) are set into grooves carved out of therim, while trads are added onto it. Keep this in mind when you’re using tires — as an example, the rim height should not be smaller than the radius of o-ring tires.

The rim also supports rotary encoder timing holes for wheel feedback. Use the padding parameters to adjust the location of those holes. See the compiler output for helpful information about the distance indicated by each timing hole. Directional timing holes will produce a second set of holes that are 90 degrees out of phase with the first. This allows you to stack sensors at the same location over the wheel instead of trying to position them along the circumference. Directional timing holes essentially double the resolution. You can also double resolution by looking for both rising and falling edges.

  • rimHeight: The height of the rim portion of the wheel
  • timingHoles: The number of timing holes to carve into the rim
  • timingHoleInPad: The inside padding for the timing holes
  • timingHoleMidPad: The middle padding if direction timing holes is selected
  • timingHoleOutPad: The outside padding for the timing holes
  • directional: A directional encoder renders two sets of slots, 90 deg out of phase

Tread Parameters

In this section, specify the properties of the tire tread you want to render. If you’re using a wheel (e.g. o-ring, rubber bands, etc), then use either the “o-rings” or “slots” settings, which will cut a groove (or grooves) in the wheel rim to fit the tires. The othertreat styles will render a tread pattern protruding out from the tire surface by the amount you specify in third part of “knobSize”.

Imagine the tire is mounted on a robot and facing straight at you. The “knobSize” parameter defines the size and shape of knobs in an [x,y,z] format, where x goes across the rim, y goes up and down along the perimeter of the wheel, and z protrudes out from the wheel toward you.

The “staggerOffset” parameter allows you to stagger knobs across the tire by an amount you specify. Set this to zero if you want all the knobs lined up along the perimeter and aligned with the edges of the rim.

“numberOfKnobs” specifies how many knobs there are across the tire, and “lineThickness” specifies how thick the lines are from “drawn” tire styles, such as “x”, “cross”, and “zigX”. You can use these pameters together in creative ways — for example to extend a single tread profile across the width of the tire, or to create a contiguous zig-zag.

Finally, “radialTreadSets” defines how many sets of treads are rendered around the wheel. Each set contains two rows in order to create the staggered effect.

Tread styles are:

    • none: No tread is rendered
    • cross: Each knob is the shape of a plus sign with the specified lineThickness
    • o-rings: Grooves are cut into the rim to accept o-ring tires
    • squares: Each knob is a rectangle, whose size is specified by knobSize
    • spheres: Each knob is a smooth bump, whose size is specified by knobSize
    • cylindersX: Each knob is a cylindrical shape running across the wheel, whose size is specified by knobSize
    • cylindersY: Each knob is a cylindrical shape running along the perimiter of the wheel, whose size is specified by knobSize
    • cylindersZ: Each knob is a cylindrical shape protruding from the surface of the wheel, whose size is specified by knobSize
    • spikes: Each knob is a cone or spike protruding from the surface of the wheel, whose size is specified by knobSize
    • slots: Grooves are cut into the rim to accept flat tires, defined by numberOfKnobs (number of grooves), the first and third numbers in knobSize to define the width of the slots and the depth, and spaceBetweenTires for the distance between the tires and also from the outside edges to the first slots.
    • x: Each knob is in the shape of an “x” protruding from the surface of the wheel, whose size is specified by knobSize
    • zigX: Each knob is in the shape of a zig-zag protruding from the surface of the wheel, whose size is specified by knobSize
    • v: Each knob is in the shape of a “v” protruding from the surface of the wheel, whose size is specified by knobSize
  • treadStyle: none, cross, o-rings, squares, spheres, cylindersX, cylindersY, cylindersZ, spikes, slots, x, zigX, v
  • knobSize: The size of each knob [across wheel, along the perimeter, prodruding]
  • radialTreadSets: How many sets of treads to render around the wheel (2 rows per set).
  • numberOfKnobs: The number of knobs to render per row.
  • staggerOffset: A distance to offset the staggered rows.
  • lineThickness: The line thickness for “drawn” styles, such as “x” and “zigX”
  • maxTires: For o-rings, the maximum number of tires per wheel
  • spaceBetweenTires: For o-rings, the space between each tire, if there are more than one

Spoke-related Parameters

This section is used to define the spoke style of the wheel. Some of the properties are only applicable to certain wheel types, and these properties can be used together in creative ways to create a wide range of tire designs.

The “proportion” property affects how some spokes are rendered. The first number is the proportion of the design from the center of the wheel to the inside of the rim, and the second number is the proportion of the width inside of the wheel. For example, to create spokes that are roughly in the shape of a “U”, you can use a “circle” style, and set the proportion to [1.5, 1.0], for cirle spokes that are 150% as long as the distance from the center to the inside of the rim, 100% as wide.

Use spokeInset to specify the inner and outer inset of the spoke area from the inner and outer faces of the wheel. You can use a negative number to make the spoke area stick out further than than the rim. The hub position will be based on the inner surface resulting from this inset.

The spoke styles are:

    • biohazard: A biohazard logo-inspired design. Set numberOfSpokes to 3 to mimic the logo.
    • circle: Spokes in a circlar or oval form, defined by spokeWidth and proportion.
    • circlefit: The maximum number of circles that will fit between the center and the rim, with a set of smaller outer circles specified by outerHoleDiameter.
    • diamond: Spokes in the shape of a diamond (rhombus), defined by spokeWidth and proportion.
    • fill: Fills in the spoke area with a solid cylinder.
    • line: Straight line spokes, like you would see on a typical wagon wheel.
    • none: Leaves the spoke area empty and does not make for a very useful wheel.
    • rectangle: Spokes in the shape of a rectangle, defined by spokeWidth and proportion.
    • spiral: Spokes in the shape of a semicircle, defined by curvature, reverse, spokeWidth.
  • spokeStyle: none, biohazard, circle, circlefit, diamond, line, rectangle, spiral, fill
  • spokeInset: The [inner,outer] inset of the spoke area from the surface
  • numberOfSpokes: Number of “spokes.” Set this to three if you’re doing the biohazard design
  • spokeWidth: This is how wide each spoke is.
  • proportion: proportion to rim, proportion of width
  • curvature: For “spiral”, this is how curvey the spokes are. >0, but
  • reverse: For “spiral”, setting this to “true” reverses the direction of the spirals
  • outerHoleDiameter: For “circlefit”, the diameter of the outer holes, or zero for non
  • concavity: Concavity distance of spoke area for [inside, outside] of wheel

Hub Parameters

These properties define the hub — or how the wheel connects to the motor. The default values for the captive nut are precise for a M3 nut and will make the nut a very tight (if not impossible) fit. I prefer this because it allows you to “melt” the nut into place with a soldering iron. However, if you don’t have a solder iron or prefer a looser fit, then just adjust the nut diameter and thickness. (M3 hardware is, by default, set to 3mm screw diameter, 5.4mm nut diameter, and 2.3mm nut thickness.) Similarly, the holes for the motor shaft and grub screw are also precise. This allows the holes to be drilled out for a more precise fit. Again, you can adjust these to suit your needs.

The hubZOffset can be used to “sink” the hub into the wheel, and it defaults to half the wheel thickness. For example, when the hubHeight is 10 and the hubZOffset is -2, then the hub will protrude 8mm from the wheel, but the shaft hole will be 10mm deep. The set screw will still be positioned in the middle of the exposed vertical height, and the fillet/chamfer will also be rendered in the correct position. This property is also useful if you want to poke a hole entirely through the wheel. (e.g. If the wheel is 6mm thick, set the hub height to 16 and the hubZOffset to -6, and you’ll get a hub that protrudes 10mm from the wheel surface with a hole that extends all the way through the wheel.)

To mount a servo motor, set includeHub to false, set shaftDiameter so that the hole will accommodate the servo horn screw and any bit that protrudes from the top of the servo horn. Then set the servoHoleDiameter to the size of your mounting hardware, and set servoHoleDistance1 and servoHoleDistance2 to the total distance between mounting holes on your servo (not the distance from the center). These sets of mounting holes will be rendered at 90 degree angles from one another. If you only want one set of holes, set one of the values to zero. Adjust the angle of all the holes to avoid openings in your wheel design if necessary using servoArmRotation.

Use innerCircleDiameter to specify a solid inner circle to use as a base for the hub. This can be useful if you need a a solid surface for servo mounting hardware or for the base hub fillet/chamfer.

Use outerNutTrap to create a nut or bolt head trap on the outside (bottom) of the hub area. Used in conjunction with shaftDiameter and false for includeHub, this will create a wheel that can drive a bolt much like the large gear on Wade’s Extruder. (This feature is inspired by that design.)

Use servoNutTrap to create nut traps for bolts used to mount the wheel onto servo arms. This feature was suggested by AUGuru.

  • includeHub: Set to false to remove the hub and only include the shaft diameter hole.
  • hubDiameter: The diameter of the hub portion of the wheel
  • hubHeight: The total height of the hub
  • hubZOffset: The Z position of the hub, negative numbers from the surface of the wheel
  • shaftDiameter: The diameter of the motor shaft
  • innerCircleDiameter: The diameter of the solid inner circle under the hub, or zero for none.
  • setScrewCount: The number of set screws/nuts to render, spaced evenly around the shaft
  • setScrewDiameter: The diameter of the set screw. 3 is the default for an M3 screw.
  • setScrewNutDiameter: The “diameter” of the captive nut, from flat to flat (the “in-diameter”)
  • setScrewNutThickness: The thickness of the captive nut
  • baseFilletRadius: The radius of the fillet (rounded part) between the hub and wheel.
  • topFilletRadius: The radius of the fillet (rounded part) at the top of the hub.
  • chamferOnly: Set to true to use chamfers (straight 45-degree angles) instead of fillets.
  • servoHoleDiameter: The diameter of servo arm hounting holes, or zero if no holes
  • servoHoleDistance1: Distance across servo horn from hole to hole (0 to ignore)
  • servoHoleDistance2: Distance across servo horn from hole to hole, rotated 90 degrees (0 to ignore)
  • servoArmRotation: The total rotation of all servo holes
  • servoNutTrap: Size [indiameter, depth] of servo arm captive nut, or 0 (any) for none.
  • outerNutTrap: Size [indiameter, depth] of a captive nut, or 0 (any) for none.

Quality Parameters

  • $fn: Default quality for most circle parts.
Share

Here’s a 3D printed T10 lamp shade that I designed and printed last night. A few weeks ago while searching for LEDs, I noticed an ebay listing for very inexpensive 12V automotive lamps that combine nine bright white LEDs. I believe these are sometimes called “wedge lights,” and are used as turn signals or interior lights.

Because reprap printers typically operate with 12V power supplies, I figured this would be a perfect way to light up the print bed. When the lamps arrived last night, I got out the calipers, worked up a design, and printed it out. I had a little difficulty removing the support material, but I’m pleased with the results.

Here it is on Thingiverse: http://www.thingiverse.com/thing:20809

The ebay listing for the LEDs (which were $1.50 for two) was titled “2 pcs WHITE Xenon SMD 9 LED HID 194 168 T10 Car Light.” It was designed exclusively with OpenSCAD.

Creative Commons License
T10 LED Lamp Shade by Alex Franke (codecreations) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Share

UPDATE 6/20/12: Added Netfabb’ed versions.

This is a press-fit lamp shade for inexpensive 12V 9-LED T10 automotive lamps. I believe these are sometimes called “wedge lights,” and are used as turn signals or interior lights. (I got mine on ebay for $1.50 for two, shipping included.)

They’re made for 12V DC operation, which is convenient for reprappers, and they don’t really need to be fastened to the frame if you’re using solid core wire.

These things are quite bright, and the shade does a great job of keeping the light in one place and not in your eyes. They require about 225mm of 3mm filament each (about a nickel).

v1.0 – The original prints shade down, with no built-in support structure
v1.1 – Prints base down with extra support on the shade-to-base transition. (On left in photo printed in white.)
v1.2 – Prints shade down with simple built-in support structure. (On right in photo printed in white.)


Instructions

  1. Print the part. (Check description above for which version to print.)
  2. Strip about 4mm of the ends of a wire (I use twisted pair from old network cable), and insert the bare wire into the holes on the side.
  3. Noting which side is positive, press the bulb into the slot and be sure the wires are pressed toward the back and are not shorted.
  4. Plug it into to a 12V and aim it somewhere interesting.

I created this with OpenSCAD and printed it with yellow 3mm PLA withh a 5mm nozzle on a self-sourced Prusa Mendel. I had to clean up the inside a bit, but other than that it seems to work just fine. Enjoy!

I need to clean up the OpenSCAD file a bit — it was a bit of a quick hack, because I just received the lamps today — but I’ll post it when I do.

Downloads



Licensing

This design is licensed under the Attribution - Non-Commercial - Share Alike license. Find it on Thingiverse at: http://www.thingiverse.com/thing:20809
<br/>

Share

OpenSCAD apparently doesn’t have an easy way to make an arc or wedge, or any way to do a partial rotate_extrude. This presented a problem when I started to design my Parametric Encoder Wheel, because in order for it to look nice, it would need to have lots of extruded arcs or partial rotate extrudes in order to make the holes.

Encoder Wheel, OpenSCAD Arc

Creating an Arc with OpenSCAD

Here’s how I solved the problem. Currently this will render slots up to 180 degrees around, but extending it should be pretty easy. If you’re doing a lot of these in your model, be sure to use render(), or badness will occur.


/* 
 * Excerpt from... 
 * 
 * Parametric Encoder Wheel 
 *
 * by Alex Franke (codecreations), March 2012
 * http://www.theFrankes.com
 * 
 * Licenced under Creative Commons Attribution - Non-Commercial - Share Alike 3.0 
*/

module arc( height, depth, radius, degrees ) {
	// This dies a horible death if it's not rendered here 
	// -- sucks up all memory and spins out of control 
	render() {
		difference() {
			// Outer ring
			rotate_extrude($fn = 100)
				translate([radius - height, 0, 0])
					square([height,depth]);
		
			// Cut half off
			translate([0,-(radius+1),-.5]) 
				cube ([radius+1,(radius+1)*2,depth+1]);
		
			// Cover the other half as necessary
			rotate([0,0,180-degrees])
			translate([0,-(radius+1),-.5]) 
				cube ([radius+1,(radius+1)*2,depth+1]);
		
		}
	}
}

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Share

This is a parametric encoder wheel that allows you to set circumference, internal width, shoulder height/width, mounting hole diameter, number of timing holes, as well as several parameters for captive nuts, alignment/snap-together pins, bolt holes, and inset of those timing holes. Most of the renderings here are for a 608 bearing (for free rotation) and sized to fit another pinch bearing.

The wheel circumference (less shoulders) of the metric and SAE versions is slightly different, and the hole sizes/spacing is different depending upon what distance you want to measure between holes. The distances will be accurate at the surface of the wheel for these renderings.

Instructions

NEW UPDATES — please read below for important information abut which renderings are part of which version!

A note about resolution: The resolution of the renderings is defined by the circumference of the wheel (but not the shoulders) divided by the number of holes. So, if you’re using an optoisolator, you can either count rising edges or falling edges for this resolution. But, you can effectively double the resolution by counting both rising and falling edges. For example, use the 5mm resolution wheel and count both edges (e.g. using Bounce or a pin change interrupt) for 2.5mm resolution.

If you want to just print the stl models…

For most of the models shown, print one copy of the encoder wheel cap, and one of the encoder wheels. Onto an 8mm (or 5/16in) bolt, add a washer, the cap (flat side first), another washer or two, the 608 bearing, another washer, and then the nut. Slide the encoder wheel onto the 608 bearing, but not so far that it contacts the cap. If it’s loose (default 0.5mm play), then put a bit of tape around it.

The 2.5mm version was rendered using the latest v0.9 of this openSCAD file, and includes several of the new features, including captive nuts, bearing constraints, and pins you can use to join the parts together. I’ll update the others as I get these files tested.

If you want to tweak it for your own purposes…

Open the file and tweak the values of these variables in the “User-defined values” section.

General Encoder wheel parameters:

  • bearingSize – The dimensions of the bearing, if you’re using that to define the hole
  • encoderCircumference – The circumference at the *surface* of the wheel (subtract tire thickness, e.g.)
  • internalWidth – The internal width (e.g. tire width) of the wheel. This is the width of a pinch 608 by default
  • collarPlay – The amount of play to build into the internal width.
  • collarHeight – How high the shoulders/encoder extend out from the wheel
  • collarWidth – How thick the shoulders are
  • holeDiameter – The diameter of the mounting hole. This is the diameter of a 608 bearing by default.
  • holePlay – The amount of play built into the mounting hole.
  • timingHoles – The number of timing holes to render. (e.g. 100mm circumference / 5mm per hole = 20 holes)
  • timingHoleInset – How far the timing holes are inset from the edge of the shoulder

Captive Nut traps allow you to tighten the wheel onto a shaft or bearing.

  • nutCount – The number of captive nuts
  • nutDiameter – The distance across the nut, from flat to flat, default M3
  • nutThickness – The thickness of the nut, default M3
  • setScrewDiameter – The diameter of the set screw clearance hole, default M3

The constraint values can be used to add material to the bottom of the mounting hole that partially blocks the hole. This can be useful, for example, if you want to constrain a bearing in the hole.

  • constraintInset – How far the constraint estends toward the center of the mounting hole
  • constraintThickness – The thickness of the contstraining wall
  • capConstraintInset – How far the constraint estends toward the center of the mounting hole on the cap
  • capConstraintThickness – The thickness of the contstraining wall on the cap

Pins or holes allow the cap to be snapped, glued, or bolted to the encoder wheel.

  • pinCount – The total number of pins / pin holes to render evenly-spaced
  • pinLength – The length of the pins/holes
  • pinDiameter – The diameter of the pins/holes
  • useHolesInstead – If true, render bolt through-holes rather than pins and pin holes
  • mateHoleDiameter – Bolt holes are sized to match hardware, not physical properties.

These values define the cap

  • capDiameter – The diameter of the shoulder cap, defaulting to the outer diameter of the encoder
  • capWidth – The thickness of the shoulder cap, defaulting to the thickness of the slotted encoder shoulder
  • capStandoff – A surface rendered on the inside of the cap around the mounting hole
  • capStandoffWidth – The width of the stand-off surface
  • capHoleRotation – Rotation of cap holes (in order to avoid the nut traps)

Other miscellaneous Parameters

  • distanceApart – How far apart the object will be rendered.

Important Notes

I’ve printed it successfully (as pictured) using a 0.5mm nozzle Prusa Mendel down to about 1.6mm. The pins in v0.9 come out quite small, and two of the three default pins were usable once I drilled out the holes. I’m still a bit new at this, though, and I’m still tuning my print quality, so I’d be interested in hearing about anyone else’s experiences with printing these.

Downloads







Licensing

This design is licensed under the Attribution - Non-Commercial - Share Alike license. Find it on Thingiverse at: http://www.thingiverse.com/thing:20491
Share

This is a project enclosure for the Velleman Metal Detector Kit, commonly available at Radio Shack.

Instructions

Clip the PCB into the bottom of the case. (You may need to bend the corners out a bit, but it should snap right in.) The 9V battery fits below the circuit board. There are four little hooks around the perimeter that might print well if you send it off, but I haven’t had success with them on a reprap, so I just hold it together with tape.

Here’s a link the the Velleman kit this was made for: vellemanusa.com/products/view/?country=us&lang=enu&id=350591

Downloads


case_bottom.stl 287.3 KB
case_top.stl 280.1 KB

Licensing

This design is licensed under the Attribution - Non-Commercial - Share Alike license. Find it on Thingiverse at: http://www.thingiverse.com/thing:18825

Share

This is a custom modular Beyblade launcher-compatible spinning top, designed by Jacob (7). He says, “It’s awesome!”

Instructions

Use a 3M metric machine screw with washer through this, and then through one of the custom middle sections. Add a washer and a nut and tighten the two parts together. (If they’re loose, it won’t spin well — if at all.) Finally put a dab of hot glue into a tip, stick it onto the bottom of the screw, and let it rip!

For the square pattern, add some weight to the top by attaching screws and washers using the holes. The other design is supposed to be hearts, but it turned out looking more like a four-leaf clover.

These probably won’t be the highest performing tops you have, but you’ll be the only one who can say you made it yourself. And yes, I know the print quality is awful here — it was one of our first prints.

Downloads



Licensing

This design is licensed under the Attribution - Non-Commercial - Share Alike license. Find it on Thingiverse at: http://www.thingiverse.com/thing:18694

Share