adrianschlatter / threadlib

thread library for OpenSCAD
BSD 3-Clause "New" or "Revised" License
351 stars 34 forks source link

Add threads for PG electrical thread #90

Open polyfloyd opened 1 month ago

polyfloyd commented 1 month ago

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

adrianschlatter commented 1 month ago

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 commented 3 weeks ago

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).

polyfloyd commented 3 weeks ago

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...

adrianschlatter commented 3 weeks ago

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.

polyfloyd commented 3 weeks ago

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

adrianschlatter commented 2 weeks ago

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

polyfloyd commented 2 weeks ago

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