2017-03-08

Getting screwed

For some reason I looked up the wikipedia page on screw threads, well, technically bolt threads, (here). As one may expect this led me to have some fun with 3D models Monday night. It was very educational.

I have made screw threads before on OpenSCAD - it is very powerful. The simple way to make a screw thread is to use the linear_extrude function to extrude a slightly offset circle with a twist setting.

The end result works well enough as a screw thread. For the internal thread in a nut you simply make the circle slightly bigger to give some clearance. However there are a few issues with this.

One is that the cross section of the thread is a sine wave. This is not really a problem, but it is far from conventional. Do look at the wiki page and see the difference. As I say, it works, and is very simple.

But I thought I would have a go at making a standard thread instead. My first idea was that instead of rotating a circle I would create a 2D shape that matches the cross section of a standard thread, and linear_extrude/twist that.

That, in itself, was not easy, I ended up using a lookup function to linear interpolate the radius for each angle: an arc at the higher radius; then an arc linearly reducing to the lower radius; then an arc at the lower radius; then a final arc linearly increasing back to the higher radius. Using lookup and a loop to create a set of 2D points for the polygon function I was able to create the correct shape, and use it with linear_extrude/twist, and it looked fine and worked.

However, I realised another problem with the whole idea of using linear_extrude. It comes down to how it works. It makes a number of slices (you can say how many) and each slice takes the 2D shape, and then a small increment above it, and twisted accordingly, the same shape, and it creates the sides to join them together, like this.

As you see, the triangles are used to make the edge between the two slices.

The issue is when the twist between two slices is large, like this, and each of the side triangles ends up stretched across a chord which cuts off the edge of the circle (or whatever) creating this sort of squeezed middle between the layers.
If you slice exactly at the layer height you are printing and it is all aligned, then this may not matter, but it does not make for a very general purpose model - even slightly off and you will print very different shapes and dimensions. So the only answer is to have a lot of slices so that the twist between each slice is small. When you realise that for a 1mm pitch screw thread that is 360 degrees per 1mm, you need a hell of a lot of slices. You also need a lot of points on the circle simply to ensure the rotation works. Millions of faces for a simple screw thread.

So I started again. I created a set of 3D points of the helix that is the bottom of the outer edge of the thread, then the next edge above it, and then the bottom of the inner edge, and then the top of the inner edge (I did not round the inside of the thread, as that is optional). I added a point for the centre top and bottom, and then used loops to create the triangles for the polyhedron function.

First the bottom, joining the centre to each point at the bottom of the thread.
But as you can see it is not joined to a solid face, so 4 more triangles needed.
Then the side, I need two triangles for each square(ish) section, so they are done in separate loops.
Then the second part of the squares.

Two more loops for the next part of the thread.
The next.
And then finally.
Now the top.
But we still have a hole, so 4 more triangles to seal it up and we have a fully contained solid shape.
And if you want a longer thread... Just keep going.
As you can see, this uses far fewer faces to make the shape, and can be sliced at any spacing you like. It is much quicker to create and makes for a smaller file.

Of course you need the internal thread too, within a nut, for example. In this case I take a clearance value to add extra spacing so that the model will work when 3D printed.
And there you have it, some complicated OpenSCAD, published on thingiverse.

P.S. As someone has commented, there are thread libraries on thingiverse, including some very odd ones, but this was more about education - learning how exactly to use OpenSCAD and the polygon and polyhedron functions like this.

7 comments:

  1. Instructional, but there are an awful lot of screw/nut/thread libraries on ÞV already - I quite like http://www.thingiverse.com/thing:8793 .

    ReplyDelete
    Replies
    1. That is a weird and even less standard screw thread which must have some issues with the angle of the overhang when printing.

      Delete
  2. Thanks for this, I'm in the midst of designing a printed prop where I want to screw some of it together and a standard thread will be good.

    ReplyDelete
    Replies
    1. The real test will be for me to go and buy an M20 but and bolt... I may do that.

      Delete
  3. Would be interesting to see how much torque those threads can hold. I know little of 3D printing, but I assume the head will have been doing circles laying the filament down? I suppose that would put the shear lines exactly as you don't want them in a thread. Does the operator get any say in how the head actually moves, or is that all automatic? Most be some interesting maths involved.

    ReplyDelete
    Replies
    1. There are a lot of options but they feel quite strong. Maybe I'll print one sideways and see if it works. But it may have difficulties that way around.

      Delete
    2. And I did some blog posts of the 3D slicing process (made a working slider myself!) many years ago. It is quite interesting, yes.

      Delete

Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.

Playing with microphones

The latest LED board designs have included a TDK PDM I2S microphone  - the idea was to make sound reactive LED strips. It is tiny (3.5mm x 2...