threadlib icon indicating copy to clipboard operation
threadlib copied to clipboard

Add threads for PG electrical thread

Open polyfloyd opened this issue 1 year ago • 10 comments

This patch adds support for PG-standard threads used in electrical boxes.

I based the specs on these images:

pg-electrical-thread-80-degree

pg

Tested with the internal thread of a PG16 socket as that is all I have

polyfloyd avatar Jul 26 '24 19:07 polyfloyd

Hi polyfloyd. Thanks for your contribution! It looks fairly complete. I am currently abroad without access to a computer having OpenSCAD until next week. I‘ll have a closer look at it when I‘m back.

adrianschlatter avatar Aug 10 '24 05:08 adrianschlatter

Ok, I did some tests today. Starting with tests/test.scad.

Rendering as is (type = "M12x0.5"), I get 3 volumes (the nut, the bolt, the surrounding space):

Screenshot 2024-08-19 at 14 48 36

Using type = "PG16" instead, we get 34 volumes. That does not sound right. Also, we get this "may need repair" warning. This could be related to an "inside is outside" problem because of the order the profile is designed. I'm sure this is fixable.

Screenshot 2024-08-19 at 14 50 03

I'm more worried about the missing gap between internal and external thread. Looking at the specs you posted above, I actually cannot see how large it is supposed to be. But without such a gap, the external- and internal threads will lock (except in lucky cases, where the external thread is a bit larger than it should and the internal one is a bit smaller).

Do you have more specs available than posted above? Usually, threads specify "classes" where they define those gaps (higher class => smaller production tolerances => smaller gaps).

adrianschlatter avatar Aug 19 '24 13:08 adrianschlatter

There is indeed an issue with the volumes. I tried to find out why this is but I could not :(

The issue seems to occur with outer thread when rendering a bolt. The commit I pushed seemed to at least render slightly better but it is still problematic.

I looked around and found another dimensions table that has this footer: image Those are probably the tolerances for the threads.

I am in doubt as to whether the inner thread is being produced correctly, as it now seems to overlap with the outer thread. Will look again when I have some more time...

polyfloyd avatar Aug 19 '24 21:08 polyfloyd

Volumes seem correct, now. PG16 bolt alone => 2 volumes. PG16 nut => 2 volumes. Nut + bolt, also 2 volumes. The last one is not what we want (3). But this is because of the missing gap. There is still the warning, though (in all three cases). I can't see why.

Regarding clearance drill: That's for a hole without threads where the bolt fits through.

adrianschlatter avatar Aug 21 '24 20:08 adrianschlatter

Alright! Not sure what went wrong the first time and how I ended up with working thread anyway.

I have started reasoning about the calculation from scratch and have it working now :) Inner and outer threads look like the schematic and there is a little gap in between the nut and bolt.

thread

polyfloyd avatar Aug 24 '24 21:08 polyfloyd

Picture looks correct, now, nice. How did you define the gap?

adrianschlatter avatar Aug 27 '24 10:08 adrianschlatter

The gap is based on the r parameter from the diagram. The internal and external threads both respectively add and substract r/2 from the diameter

polyfloyd avatar Aug 27 '24 11:08 polyfloyd

Hi @adrianschlatter, were you able to review my changes?

polyfloyd avatar Jan 17 '25 18:01 polyfloyd

Hi @polyfloyd.

Now, test.scad nut+bolt do not render at all. I get this: Screenshot 2025-01-18 at 11 22 38

I identified two problems:

  1. Overlap: For OpenSCAD to correctly combine two bodies ("union"), they need to have (a little) overlap. Just touching is not enough. When I increase the support diameter a little, the parts render.
  2. No overlap: Apparently, OpenSCAD is not too happy when subsequent windings of the thread overlap. In your definition, the pitch (1.411 mm) is less than the height of the thread cross section (2x0.7085 mm = 1.417 mm). This causes the parts to become non-simple and throws the warning "object may not be a valid two-manifold"

adrianschlatter avatar Jan 18 '25 11:01 adrianschlatter

Please check again. I added some margin on both the support diameters and the the thread extension. It now extends 0.7021mm so 0.7021*2=1.4042 < 1.411 mm. I still get the same error and am not sure where it is caused by now :S

polyfloyd avatar Jan 19 '25 12:01 polyfloyd

@adrianschlatter: Is there any news about this PR?

I created a model with a PG7 thread and was able to connect it to a purchased cable gland. Please add this great extension to this great library.

sebastian-toepfer avatar Jul 29 '25 22:07 sebastian-toepfer