Konubinix' site

Make a New Wheel for a Toy With Openscad

tag: learning 3D printing

Make a new wheel for a toy with openscad. Let’s take advantage of this to try practicing literate programming.

Measuring the wheel

Let’s measure the remaining wheel to find out what we need to create.

It has a diameter of 12mm.

A depth of 5mm.

The inner hole has a outer diameter of 5mm and a inner diameter of 3mm.

Making the wheel

Let’s try to first make the wheel, that’s to say: a 12mmx5mm cylinder with a hole that is at one side 5mm large and the other side 3mm large.

What we cannot see in the pictures is that the hole diameter change is about at the middle of the depth.

The body is quite simple. Let’s center it to ease putting the hole afterwards.

module wheel () {
    cylinder(5, 6, 6, center=true, $fn=100);
}

Then, the hole is simply the union of two cylinders, one at the top and one rotated to be at the bottom.

module hole(smallholeradius, bigholeradius) {
    cylinder(2.5, bigholeradius, bigholeradius, $fn=100);

    rotate(a=[0,180,0]) {
        cylinder(2.5, smallholeradius, smallholeradius, $fn=100);
    }
}

Put together, the wheel now looks like this.

module wheel () {
    cylinder(5, 6, 6, center=true, $fn=100);
}

module hole(smallholeradius, bigholeradius) {
    cylinder(2.5, bigholeradius, bigholeradius, $fn=100);

    rotate(a=[0,180,0]) {
        cylinder(2.5, smallholeradius, smallholeradius, $fn=100);
    }
}

render () difference() {
    wheel();
    hole(1.5, 2.5);
  }

The result is the following

The wheel is not bad at all, but the holes are too small, the cap of the axis does not fit in the bigger hole and the axis does not fit in the smaller hole.

Let’s try by increasing the hole diameters by 1mm, hence increasing the radius by 0.5.

module wheel () {
    cylinder(5, 6, 6, center=true, $fn=100);
}

module hole(smallholeradius, bigholeradius) {
    cylinder(2.5, bigholeradius, bigholeradius, $fn=100);

    rotate(a=[0,180,0]) {
        cylinder(2.5, smallholeradius, smallholeradius, $fn=100);
    }
}

render () difference() {
    wheel();
    hole(2, 3);
  }
openscad /tmp/test2.scad -o ~/p.stl
cura ~/p.stl
clk 3d print --flow

Measuring the axis

It is about 8mm long, including 1mm for the cap.

The cap has 4mm diameter.

The diameter of the axis cylinder is about 3mm.

Making the axis

The axis is a 7mm long cylinder with a diameter of 3mm, with a cap being another cylinder of 1mm long and diameter 4mm.

module axis () {
    cylinder(7.5, 1.6, 1.6, $fn=100);
}

module cap () {
    cylinder(1, 2, 2, $fn=100);

}

Then, putting them together

rotate(a=[0,180,0]) {
    axis ();
    translate([0, 0, 7.5]) cap();
}
module axis () {
    cylinder(7.5, 1.6, 1.6, $fn=100);
}

module cap () {
    cylinder(1, 2, 2, $fn=100);

}
rotate(a=[0,180,0]) {
    axis ();
    translate([0, 0, 7.5]) cap();
}

Conclusion

It worked, but either I’m missing something or, the labists x1 mini is bad at printing circles.

Also, the axis appears to be too small for the printer to make a smooth job. But it did the job anyway.