Welcome! Log In Create A New Profile

Advanced

d-sub connector library?

Posted by dpeart 
d-sub connector library?
October 29, 2015 06:43AM
Does anyone know of a library to create d-sub connectors? I'm looking to make a panel to mount a db-15 connector and was wondering if someone has a library already done before I try to write create one myself.

thanks
david
Re: d-sub connector library?
October 29, 2015 07:27AM
There are some OpenSCAD libraries around but I couldn't locate one for rs232c (db-N) connectors.

OpenSCAD User Manual/Libraries
Libraries · openscad_openscad Wiki · GitHub

But then what do you really need?



You obviously want to make a cutout in a panel for a db-15 connector (a good starting place is HERE).

Using the above HERE link you can easily create a module to generate the needed form.

You could either use a RoundedBox with two cubes subtacted for the main portion and two cylinders for the holes or perhaps even easier a hull() { of four cylinders } plus two cylinders for the holes.
Using the table you could then generate your object to subtract from a panel for all defined types.


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: d-sub connector library?
October 29, 2015 09:38AM
I like the hull() { of four cylinders } idea, that should be straightforward.

thanks,
david
Re: d-sub connector library?
October 29, 2015 12:56PM
Well here is what I came up with:
//[www.te.com]

$fn=20;

function db_conn_table(idx) =
// b, d, f, k
idx == "db9F" ? [12.50,11.10,6.53,2.11] :
idx == "db9R" ? [12.50,11.10,5.72,3.35] :
idx == "db15F" ? [16.66,15.27,6.53,2.11] :
idx == "db15R" ? [16.66,15.27,5.72,3.35] :
idx == "db25F" ? [23.52,22.15,6.53,2.11] :
idx == "db25R" ? [23.52,21.39,5.72,3.35] :
idx == "db37F" ? [31.75,29.54,6.53,2.11] :
idx == "db37R" ? [31.75,29.54,5.72,3.35] :
idx == "db50F" ? [30.56,29.19,7.93,2.11] :
idx == "db50R" ? [30.56,28.17,7.06,3.35] :
"Error";

conn = "db25R";

conn_dimensions = db_conn_table(conn);
if(conn_dimensions == "Error") {
echo(str("connector not found"));
}

b = db_conn_table(conn)[0];
d = db_conn_table(conn)[1];
f = db_conn_table(conn)[2];
k = db_conn_table(conn)[3];

//b = 16.66;
//d = 14.40;
//f = 5.72;
//k = 3.35;

cut_angle = 10;
mounting_hole = 3.05;

hull(){
//Upper Left
translate([-(d-k),(f-k),0])
cylinder(1, d=k, center=false);
//Upper Right
translate([(d-k),(f-k),0])
cylinder(h=1, d=k);
//Lower Left
translate([-(d-k)+cos(cut_angle),-(f-k),0])
cylinder(h=1, d=k);
//Lower Right
translate([(d-k)-cos(cut_angle),-(f-k),0])
cylinder(h=1, d=k);
}

// Mounting Holes
translate([-b,0,0])
cylinder(h=1, d=mounting_hole);
translate([b,0,0])
cylinder(h=1, d=mounting_hole);
Re: d-sub connector library?
October 30, 2015 01:04AM
Yes, exactly in the direction I meant!

b = db_conn_table(conn)[0];
d = db_conn_table(conn)[1];
f = db_conn_table(conn)[2];
k = db_conn_table(conn)[3];

shouldn't this be instead

b = conn_dimensions[0];
d = conn_dimensions[1];
f = conn_dimensions[2];
k = conn_dimensions[3];

Since you already used:

conn_dimensions = db_conn_table(conn);

Also I would translate the whole thing down h/2 so it is also centered vertically.
I might have made it 10mm high but the USER can always use scale([1,1,factor]) to get the desired height when using 1mm.

Nice job! Quick and easy but does the job very nicely.

Edited 1 time(s). Last edit at 10/30/2015 02:11AM by rhmorrison.

Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: d-sub connector library?
October 30, 2015 01:23AM
I would make the following changes to be able to use properly it as a library:
// dsub.scad
//
// D-Sub connector library by 'dpeart'

function db_conn_table(idx) =
				  // [b,d,f,k]
	idx == "db9F"  ? [12.50,11.10,6.53,2.11] :
	idx == "db9R"  ? [12.50,11.10,5.72,3.35] :
	idx == "db15F" ? [16.66,15.27,6.53,2.11] :
	idx == "db15R" ? [16.66,15.27,5.72,3.35] :
	idx == "db25F" ? [23.52,22.15,6.53,2.11] :
	idx == "db25R" ? [23.52,21.39,5.72,3.35] :
	idx == "db37F" ? [31.75,29.54,6.53,2.11] :
	idx == "db37R" ? [31.75,29.54,5.72,3.35] :
	idx == "db50F" ? [30.56,29.19,7.93,2.11] :
	idx == "db50R" ? [30.56,28.17,7.06,3.35] :
	"Error";

//dsub("db25R");

module dsub(conn)
{
    conn_dimensions = db_conn_table(conn);
    if(conn_dimensions == "Error")
    {
        echo(str("ERROR: Connector '", conn, "' not found"));
        echo("ERROR: Allowed are db9F, db9R, db15F, db15R, db25F, db25R, db37F, db37R, db50F and db50R.");
		
        color("red")
        {
            for ( a = [-45,45])
                rotate([0,0,a])
                    cube([4,20,4], true);
        }
    }
    else
    {
        b = conn_dimensions[0];
        d = conn_dimensions[1];
        f = conn_dimensions[2];
        k = conn_dimensions[3];

        cut_angle = 10;
        mounting_hole = 3.05;
        sides = 20;

        translate([0,0,-0.5])
        {
            union()
            {
                hull()
                {
                    //Upper Left
                    translate([-(d-k),(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Upper Right
                    translate([(d-k),(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Lower Left
                    translate([-(d-k)+cos(cut_angle),-(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Lower Right
                    translate([(d-k)-cos(cut_angle),-(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                }

                // Mounting Holes
                translate([-b,0,0])
                    cylinder(h=1, d=mounting_hole, $fn=6);
                translate([b,0,0])
                    cylinder(h=1, d=mounting_hole, $fn=6);
            }
        }
    }
}

And then copy dsub.scad to your OpenSCAD\libraries directory and use as follows:
use <dsub.scad>

dsub("db25R");

Edited 5 time(s). Last edit at 10/30/2015 07:56AM by rhmorrison.

Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: d-sub connector library?
October 30, 2015 05:11AM
OK I wasn't sure how to make it a library. Thanks!
Re: d-sub connector library?
October 30, 2015 12:53PM
Good work. Might be an idea to include an optional "oversize" parameter to make the D cut-out and mounting hole diameters larger (in case you need a looser fit and/or to compensate for the printer making the holes smaller).

Dave
Re: d-sub connector library?
November 02, 2015 01:46AM
One last change needed:
// dsub.scad
//
// D-Sub connector library by 'dpeart'

function db_conn_table(idx) =
				  // [b,d,f,k]
	idx == "db9F"  ? [12.50,11.10,6.53,2.11] :
	idx == "db9R"  ? [12.50,11.10,5.72,3.35] :
	idx == "db15F" ? [16.66,15.27,6.53,2.11] :
	idx == "db15R" ? [16.66,15.27,5.72,3.35] :
	idx == "db25F" ? [23.52,22.15,6.53,2.11] :
	idx == "db25R" ? [23.52,21.39,5.72,3.35] :
	idx == "db37F" ? [31.75,29.54,6.53,2.11] :
	idx == "db37R" ? [31.75,29.54,5.72,3.35] :
	idx == "db50F" ? [30.56,29.19,7.93,2.11] :
	idx == "db50R" ? [30.56,28.17,7.06,3.35] :
	"Error";

//dsub("db25R");

module dsub(conn)
{
    sides = 20;
    
    conn_dimensions = db_conn_table(conn);
    if(conn_dimensions == "Error")
    {
        echo(str("ERROR: Connector '", conn, "' not found"));
        echo("ERROR: Allowed are db9F, db9R, db15F, db15R, db25F, db25R, db37F, db37R, db50F and db50R.");
		
        color("red")
        {
            for ( a = [-45,45])
                rotate([0,0,a])
                    cube([4,20,4], true);
        }
    }
    else
    {
        b = conn_dimensions[0];
        d = conn_dimensions[1];
        f = conn_dimensions[2];
        k = conn_dimensions[3];

        cut_angle = 10;
        mounting_hole = 3.05;
        o = 2*(f-k) * tan(cut_angle);

        translate([0,0,-0.5])
        {
            union()
            {
                hull()
                {
                    //Upper Left
                    translate([-(d-k),(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Upper Right
                    translate([(d-k),(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Lower Left
                    translate([-(d-k)+o,-(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Lower Right
                    translate([(d-k)-o,-(f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                }

                // Mounting Holes
                translate([-b,0,0])
                    cylinder(h=1, d=mounting_hole, $fn=6);
                translate([b,0,0])
                    cylinder(h=1, d=mounting_hole, $fn=6);
            }
        }
    }
}

Using cos(10) is incorrect!
2(f-k) tan(10) is the correct distance!



As the height of connector increases so must the offset used in order to maintain a 10° angle.

Edited 3 time(s). Last edit at 11/02/2015 07:59AM by rhmorrison.

Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: d-sub connector library?
November 03, 2015 03:18AM
And HERE a version with dmould's suggestion implemented (an optional gap):
// dsub.scad
//
// D-Sub connector library by 'dpeart'

function db_conn_table(idx) =
				  // [b,d,f,k]
	idx == "db9F"  ? [12.50,11.10,6.53,2.11] :
	idx == "db9R"  ? [12.50,11.10,5.72,3.35] :
	idx == "db15F" ? [16.66,15.27,6.53,2.11] :
	idx == "db15R" ? [16.66,15.27,5.72,3.35] :
	idx == "db25F" ? [23.52,22.15,6.53,2.11] :
	idx == "db25R" ? [23.52,21.39,5.72,3.35] :
	idx == "db37F" ? [31.75,29.54,6.53,2.11] :
	idx == "db37R" ? [31.75,29.54,5.72,3.35] :
	idx == "db50F" ? [30.56,29.19,7.93,2.11] :
	idx == "db50R" ? [30.56,28.17,7.06,3.35] :
	"Error";

//dsub("db9R");
//dsub("db25R",0.2);

module dsub(conn, g=0)
{
    sides = 20;
    
    conn_dimensions = db_conn_table(conn);
    if(conn_dimensions == "Error")
    {
        echo(str("ERROR: Connector '", conn, "' not found"));
        echo("ERROR: Allowed are db9F, db9R, db15F, db15R, db25F, db25R, db37F, db37R, db50F and db50R.");
		
        color("red")
        {
            for ( a = [-45,45])
                rotate([0,0,a])
                    cube([4,20,4], true);
        }
    }
    else
    {
        b = conn_dimensions[0];
        d = conn_dimensions[1];
        f = conn_dimensions[2];
        k = conn_dimensions[3];

        cut_angle = 10;
        mounting_hole = 3.05;
        o = 2*(g+f-k)*tan(cut_angle);

        translate([0,0,-0.5])
        {
            union()
            {
                hull()
                {
                    //Upper Left
                    translate([-(g+d-k),(g+f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Upper Right
                    translate([(g+d-k),(g+f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Lower Left
                    translate([-(g+d-k)+o,-(g+f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                    //Lower Right
                    translate([(g+d-k)-o,-(g+f-k),0])
                        cylinder(h=1, d=k, $fn=sides);
                }

                // Mounting Holes
                translate([-b,0,0])
                    cylinder(h=1, d=g+mounting_hole, $fn=6);
                translate([b,0,0])
                    cylinder(h=1, d=g+mounting_hole, $fn=6);
            }
        }
    }
}


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: d-sub connector library?
November 04, 2015 08:46AM
That's excellent work - something to add to my OpenScad libraries.
COS is often mistakenly used instead of TAN (and vice-versa), because their values are almost the same for small angles (because the hypotenuse is almost the same length as the adjacent side), so the mistake is often not obvious on the model.

Dave
Re: d-sub connector library?
November 04, 2015 01:27PM
No, it is the sin(x) that is very close to tan(x) where x is a small angle but he didn't multiply by the hypotenuse, he just used cos(x) which is a factor (adj/hyp) and not a length! Dividing mm by mm is unit less.

Edited 1 time(s). Last edit at 11/05/2015 12:32AM by rhmorrison.

Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: d-sub connector library?
November 04, 2015 01:31PM
I still need to change the diameter of the lower cylinders. If you look at the specifications k is the radius of the bottom curves but it was used as the diameter. Would have done it already but I currently don't have a working computer at home.

Edited 1 time(s). Last edit at 11/05/2015 12:33AM by rhmorrison.

Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Sorry, only registered users may post in this forum.

Click here to login