<p>OpenSCAD would be well suited for creating something made up of relatively simple shapes, where different dimensions are needed for some parts of the shapes - like the diameters and offsets of your stepper motor shafts.</p>
<p>A solution in OpenSCAD could look something like this:</p>
<pre><code>outer_diameter = 8.5;   //Outer diameter of the adapter
stepper_length = 12;    //Length of the stepper shaft
stepper_diameter = 4;   //Diameter of the stepper shaft
stepper_d_offset = 1.6; //Offset from the center of the shaft to the plane of the D

//4mm shaft: d = 4, offset = 1.6
//5mm shaft: d = 5, offset = 2
//6mm shaft: d = 6, offset = 2.5

thickness_mid = 2;      //Thickness of the massive section between stepper and lego shafts

lego_length = 10;           //Length of the lego shaft
lego_diameter = 4.9;        //Outer diameter of the lego shaft
lego_internal_width = 1.9;    //Width of the slots for the shaft
lego_corner_radius = 0.5;

cutout_size = lego_diameter;
cutout_translate = cutout_size / 2 + lego_internal_width / 2;
$fn = 128;               //Accuracy / resolution of circles
eps = 0.01;

module fillet_square(width, radius) {
    translate([radius - width / 2, radius - width / 2, 0])
        minkowski() {
            square(width - 2 * radius);
            circle(radius);
        }
}
color(0,0.5)
union(){
    linear_extrude(height = stepper_length + eps) {
        difference() {
            circle(d = outer_diameter);   
            difference() {
                circle(d = stepper_diameter);
                translate([0, stepper_d_offset + stepper_diameter / 2, 0]) {
                    square(size = stepper_diameter, center = true);
                }
            }
        }
    }
    translate([0, 0, stepper_length]) {        
        linear_extrude(height = thickness_mid) {
            circle(d = outer_diameter);
        }
    }
    translate([0, 0, stepper_length + thickness_mid - eps]) {        
        linear_extrude(height = lego_length + eps) {
            difference() {
                circle(d = outer_diameter);
                difference() {
                    circle(d = lego_diameter);
                    translate([cutout_translate, cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                    translate([cutout_translate, -cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                    translate([-cutout_translate, cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                    translate([-cutout_translate, -cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                }
            }
        }
    }
}
</code></pre>
<p><a href="https://i.sstatic.net/HbuR4.png" rel="noreferrer"><img src="https://i.sstatic.net/HbuR4.png" alt="enter image description here" /></a></p>
<p>You can then export your .stl file (or any other format) for 3D-printing from OpenSCAD.</p>

CC BY-SA 4.0
2022-06-09T11:50:55.347Z
Great answer, I'd consider a larger `outer_diameter` for increasing the load bearing capacity (torque). Maybe mentioning that you shouldn't print this upright might be useful.
0scar
CC BY-SA 4.0
2022-06-11T12:53:30.610Z
Thanks for the solution.  Installed OpenSCAD and pasted in your code the part rendered without issue!
Gary Kindel
CC BY-SA 4.0
2022-06-09T07:13:25.590Z
2022-06-09T07:13:25.590Z
towe
<p>I am working on a <a href="https://bricks.stackexchange.com/questions/17128/looking-for-a-pc-controlled-motor-that-allows-for-very-small-and-precise-movemen">prototype</a> and I have a need for a motor shaft to Lego axle adapter for use with a stepper motor.</p>
<p>My overall project entails controlling a stepper motor using C# via USB connection to make very small rotations which will adjust the height of a specimen stage (constructed from Legos) for a stereo microscope.</p>
<p>I need adapters similar to <a href="https://www.cgtrader.com/free-3d-print-models/hobby-diy/mechanical-parts/6mm-dshaft-to-lego-axis-adapter" rel="nofollow noreferrer">6mm D shaft to Lego axis adapter Free 3D print model</a> but for 4 mm dia motor D shaft and 5 mm dia motor D shaft</p>
<p>The purpose of the adapter is to allow very small and slow rotations.</p>
<ul>
<li><p>I do not want to own the model designs, ideally they can be given away for free (<a href="https://www.cgtrader.com/free-3d-print-models/hobby-diy/mechanical-parts/6mm-dshaft-to-lego-axis-adapter" rel="nofollow noreferrer">similar to the link above</a>).</p>
</li>
<li><p>I need several of the adapter pieces; 3 of each (4 mm and 5 mm) printed and what would be a fair price for this?</p>
</li>
<li><p>I have no idea what type of material should be used to print these, I think Acrylonitrile Butadiene Styrene (ABS) would do.</p>
</li>
</ul>

CC BY-SA 4.0
2022-06-09T06:13:40.313Z
This seems like a nice exercise to practise beginner CAD skills in.

b) 50 / hour of design time, 5 / hour of print time is what I usually use.
c) ABS, ASA, HIPS or, if possible, Nylon
d) Artillery Hornet, though purchasing suggestions are out of scope for this SE.
towe
CC BY-SA 4.0
2022-06-09T11:47:05.990Z
Hi Gary, welcome to 3DPrinting.SE! Please note that printer recommendation is out of scope, I've removed the request from the question. Feel free to drop by in our [public chat channel](https://chat.stackexchange.com/rooms/79830/public-3d-printing-room).
0scar
<3d-models><3d-design><bricks>
Stepper motor D shaft to Lego axle adapter
Gary Kindel
# Stepper motor D shaft to Lego axle adapter

(Asked by: username_0 on 2022-06-06)

I am working on a [prototype](https://bricks.stackexchange.com/questions/17128/looking-for-a-pc-controlled-motor-that-allows-for-very-small-and-precise-movemen) and I have a need for a motor shaft to Lego axle adapter for use with a stepper motor.

My overall project entails controlling a stepper motor using C# via USB connection to make very small rotations which will adjust the height of a specimen stage (constructed from Legos) for a stereo microscope.

I need adapters similar to [6mm D shaft to Lego axis adapter Free 3D print model](https://www.cgtrader.com/free-3d-print-models/hobby-diy/mechanical-parts/6mm-dshaft-to-lego-axis-adapter) but for 4 mm dia motor D shaft and 5 mm dia motor D shaft

The purpose of the adapter is to allow very small and slow rotations.

* I do not want to own the model designs, ideally they can be given away for free ([similar to the link above](https://www.cgtrader.com/free-3d-print-models/hobby-diy/mechanical-parts/6mm-dshaft-to-lego-axis-adapter)).
* I need several of the adapter pieces; 3 of each (4 mm and 5 mm) printed and what would be a fair price for this?
* I have no idea what type of material should be used to print these, I think Acrylonitrile Butadiene Styrene (ABS) would do.

**Tags:** 3d-models, 3d-design, bricks
> **Comments:**
> **username_1**: This seems like a nice exercise to practise beginner CAD skills in.  b) 50 / hour of design time, 5 / hour of print time is what I usually use. c) ABS, ASA, HIPS or, if possible, Nylon d) Artillery Hornet, though purchasing suggestions are out of scope for this SE.  
> **username_2**: Hi Gary, welcome to 3DPrinting.SE! Please note that printer recommendation is out of scope, I've removed the request from the question. Feel free to drop by in our [public chat channel](https://chat.stackexchange.com/rooms/79830/public-3d-printing-room).  

---

## 1 answers

### Answer by username_1 on 2022-06-09. Score: 5 | Accepted answer

OpenSCAD would be well suited for creating something made up of relatively simple shapes, where different dimensions are needed for some parts of the shapes - like the diameters and offsets of your stepper motor shafts.
A solution in OpenSCAD could look something like this:
outer_diameter = 8.5;   //Outer diameter of the adapter
stepper_length = 12;    //Length of the stepper shaft
stepper_diameter = 4;   //Diameter of the stepper shaft
stepper_d_offset = 1.6; //Offset from the center of the shaft to the plane of the D

//4mm shaft: d = 4, offset = 1.6
//5mm shaft: d = 5, offset = 2
//6mm shaft: d = 6, offset = 2.5

thickness_mid = 2;      //Thickness of the massive section between stepper and lego shafts

lego_length = 10;           //Length of the lego shaft
lego_diameter = 4.9;        //Outer diameter of the lego shaft
lego_internal_width = 1.9;    //Width of the slots for the shaft
lego_corner_radius = 0.5;

cutout_size = lego_diameter;
cutout_translate = cutout_size / 2 + lego_internal_width / 2;
$fn = 128;               //Accuracy / resolution of circles
eps = 0.01;

module fillet_square(width, radius) {
    translate([radius - width / 2, radius - width / 2, 0])
        minkowski() {
            square(width - 2 * radius);
            circle(radius);
        }
}
color(0,0.5)
union(){
    linear_extrude(height = stepper_length + eps) {
        difference() {
            circle(d = outer_diameter);   
            difference() {
                circle(d = stepper_diameter);
                translate([0, stepper_d_offset + stepper_diameter / 2, 0]) {
                    square(size = stepper_diameter, center = true);
                }
            }
        }
    }
    translate([0, 0, stepper_length]) {        
        linear_extrude(height = thickness_mid) {
            circle(d = outer_diameter);
        }
    }
    translate([0, 0, stepper_length + thickness_mid - eps]) {        
        linear_extrude(height = lego_length + eps) {
            difference() {
                circle(d = outer_diameter);
                difference() {
                    circle(d = lego_diameter);
                    translate([cutout_translate, cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                    translate([cutout_translate, -cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                    translate([-cutout_translate, cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                    translate([-cutout_translate, -cutout_translate, 0]) {
                        fillet_square(cutout_size, lego_corner_radius);
                    }
                }
            }
        }
    }
}


You can then export your .stl file (or any other format) for 3D-printing from OpenSCAD.

> **Comments:**
> **username_2**: Great answer, I'd consider a larger `outer_diameter` for increasing the load bearing capacity (torque). Maybe mentioning that you shouldn't print this upright might be useful.  
> **username_0**: Thanks for the solution.  Installed OpenSCAD and pasted in your code the part rendered without issue!  

---

