Saturday, May 17, 2014

Experiences making threads for screws and bolts in FreeCAD

BACKGROUND

FreeCAD

I lately started to use FreeCAD. Some say it is not user friendly and polished and complain about crashes. I have been using the latest version available from their daily updated PPA and for me it works extremely well.

For me it is an already very nice CAD software conceived to become an over-average professional CAD package. It is under heavy development and is without doubt the rising star of the free open source CAD (if you are into PCB design, some compare it with KiCAD, the rising star of the free open source EDA software).

In fact FreeCAD's GUI is quite polished for many common operations and features a python interpreter to automate those tasks not yet available in the GUI  and even make fully parametric python coded objects. You can learn more about the project in their web page.

The forum support you get from them is better than many paid support services I have used. You might want to check their forum thread for help on FreeCAD, you will be amazed (please read the sticky post first and give them your version information). It is a great growing community.

It is definitely the CAD solution I will be using from now on.

Making a Thread

All this started for me because I wanted to do a thread in FreeCAD, and I could not make it work (the way I wanted) using different methods known to me or found in the Internet.

I am not a professional of the CAD design, but a newbie. As such I do not intend to tell you how things should be done, but just tell you what I considered, what worked and specially what failed (maybe so that you do not lose your time with it, or so that you invest your time in fixing it...). It might be a good start for those beginners like me.

Of course, you are more than invited to comment below and enlighten me with your superior solutions.


MAKING A THREAD: FOUND SOLUTIONS


The OpenSCAD solution

Many people have developed libraries for OpenSCAD for making threads. One I specially like is this one.

OpenSCAD files and libraries can be (generally) opened in FreeCAD without any (much) effort.


However, all OpenSCAD thread libraries that I have seen, work by making individual elements (e.g. polyhedrons). Take a look at the link above as Blogger can not cope with more images in this post for some reasons.

This has been reported to be functional (e.g. when 3D printing it, see thingiverse link above). Therefore it is probably one good safe possibility to consider if you are thinking on 3D printing your object. The parameters can be changed in the scad file to accommodate it to your requirements. It is indeed a very nice piece of useful engineering.

However it is not what I was looking for. I would rather have an object where a physical face is not a compendium of tiny aligned faces, but a single face. But it may be just what you need.

The FreeCAD MakeScrew Macro solution

Looking for a solution I found a macro for creating screws (version 1.2) wrote for FreeCad. In fact there is also a newer version linked here (version 1.6).



This is actually the work of one quite active user member of the FreeCAD community, ulrich1a, you can find him in the forum.

It looks really nice. Because it was not working with real threads I contacted him in the forum, and he pointed to version 1.7, here. Well this does work for me.


For those interested, the macro is a python script. In order to cut the thread, a single revolution is created. To create this single revolution, an ISO profile is swept along an helix. This cutting operation is then copied and placed on the previous one until the desired thread length is obtained.

The resulting object is a beautiful non-parametric feature. Meaning that you can not change the original parameters that you used for creating it (data properties is empty). Although you can cut it with a cube to take only a part, or make any other operation on it.

However, the python code is there to accommodate it to your needs.

The FreeCAD MakeThread API function solution

FreeCAD currently has a function to make a thread in the Part API.

You can build an object using that shape following this tutorial.

Because I saw in some forum commited changes to this function (I did not actually check the dates), I just pulled and compiled the latest version from Github (Version: 0.14.3539 (Git)).

Still I think I fail to understand the parameters (pitch,depth,height,radius). This is an example with (2,2,8,40). So I expect a thread of 2 mm pitch and a depth of 2 mm, over a height of 8 mm, with a radius of 40 mm. So I expect around 4 full revolutions (height/pitch), while I get almost two full profile revolutions (you would almost be able to stack another equal object over to make another revolution).


 If I make height higher, let's do 20 mm, I get:



So one and a half revolutions (turns), and much more separations between turns. Willing to understand the function I went to the source code file
src/Mod/Part/App/TopoShape.cpp. There I found some code for making the thread based on elipses, which was totally unexpected for me.

I asked in the forum and the reply I got is "It tries to loft between 2 helical profiles to produce the thread, but how to set the parameters is not obvious. The thread doesn't match ISO or UN or anything else I recognize. Maybe a bottle top thread? It is an interesting solid though."

I was willing to see that a thread could be done using this function by stacking single "makeThread" objects (and cutting to the desired length). Well, maybe some reader knows how to handle this and can enlight us...

Swept Profile cutting tool

This solution you can find in many tutorials online. It basically cuts a cylinder with a cutting profile swept along an helix. The cutting profile is many times a trapezoid, though if you want to make an ISO profile you need another kind of profile (see Ulrich1a's Method' profile below).

Make sure you used a cylinder from Part workbench and not an extruded (padded) circular sketch, as the cut profile might not always work as expected. You can find more information in this forum.

This does indeed work with a cylinder and the result is very similar (if not identical to the Ulrich1a's Method below). I would have like to post an individual image, but Blogger can not cope with more images in this post for some reason.


Ulrich1a's Method

When I asked about the thread, ulrich1a gave me the recipe for an ISO thread. You can find it here.

The fully parametric ISO profile, that you can find in the forum looks like this:

 


In fact Ulrich's method is not short as it involves several steps, but is very smart in that it avoids cutting a cylinder with a profile swept along an helix, which sometimes might be problematic (specially with older versions of FreeCAD and/or cylinders created by padding a circular sketch). It creates a single profile face that is afterwards swept along an helix.

In his own words, the recipe is:

Here is a guide how to make a thread with the gui. It makes a thread with the z-axis as the thread-axis. The Thread_cut_profile makes a standard screw profile according to ISO.
1. make a cut profile as given in the attachment. Edit the sketch and set the pitch and the nominal diameter according to your needs. Filter the constraints to named, in order to see those constraints.
2. make a helix1 with height identical to the pitch and the pitch identical to the thread pitch and a helix radius of 0.42*nominal diameter of the thread.
3. Sweep the cut profile along the helix1. Set make solid and frenet to true.
4. Make a circle with nominal radius of the thread in the x-y-plane.
5. Make a face from the circle. (Part-workbench: advanced utility to create shapes)
6. cut the face with the sweep profile
7. make a clone from the cut (Draft workbench)
8. Downgrade the clone in order to get a wire. (Draft workbench)
9. Make a helix with radius of nominal radius of the thread and a pitch of the thread and the height of the needed thread.
10. Sweep the wire along the helix. Set solid and frenet to true.
You are done. The thread may not look good, so the tesselation parameter in the Preferences, Part design, Shape view may be set to 0.1%. The thread I made with this guide was valid in the geometry check.
The result looks great:



In fact the objects you see in the interface are those to create two (equal) threads, because I wanted to see if there were differences between using a circle created with the Part workbench and the Draft workbench (Circle and Circle001). In fact the one created with the Draft workbench renders better in my computer (but the one tested by ulrich1a is the one created with the Part workbench).

After finishing both, I tried to cut them (to see if they were equal or not), and after around 20 minutes of processing I got that red message "Cannot compose Inventor representation for the shape of Cut002". Well, I believe they are pretty similar...


Conclusion

Well that was my experience with creating threads. I hope it was useful and can save some time to others trying to walk the same path.

Please do not hesitate to leave your comments below, specially if I posted something inaccurate or wrong, or if you know better and can enlighten me.

 

No comments:

Post a Comment