module hole_oblong( length, width, z ) { l2 = length/2; w2 = width/2; lw2 = l2 - w2; translate( [ -lw2, -w2, 0 ] ) cube( [ length-width, width, z ] ); translate( [ lw2, 0, 0 ] ) cylinder( z, d=width ); translate( [ -lw2, 0, 0 ] ) cylinder( z, d=width ); } module hat_rail( length ) { color( "#b0c0e0" ) difference() { rotate( [ 90, 0, 90 ] ) linear_extrude( length, convexity=2 ) polygon( [ [ -18, 6 ], [ -13, 6 ], [ -13, 1 ], [ -12, 0 ], [ 12, 0 ], [ 13, 1 ], [ 13, 6 ], [ 18, 6 ], [ 18, 7 ], [ 13, 7 ], [ 12, 6 ], [ 12, 1 ], [ -12, 1 ], [ -12, 6 ], [ -13, 7 ], [ -18, 7 ] ] ); for( x = [ 0 : 25 : length ] ) { translate( [ x + 12, 0, -0.5 ] ) hole_oblong( 18, 6, 2 ); } } } module channel( length, width, height, hole_spacing, hole_width, hole_z, rounding_center, rounding_dia, lid_height, thickness ) { x = [ width/2, width/2 - thickness, width/2 - thickness, width/2 - thickness - thickness ]; y = [ 0, thickness, height - lid_height - thickness * 3, height - lid_height - thickness * 2, height - lid_height - thickness, height - lid_height, height - lid_height + thickness, height - thickness, height ]; points = [ // body [ x[0], y[0] ], [ x[0], y[3] ], [ x[2], y[5] ], [ x[0], y[5] ], [ x[0], y[8] ], [ -x[0], y[8] ], [ -x[0], y[5] ], [ -x[2], y[5] ], [ -x[0], y[3] ], [ -x[0], y[0] ], // hole [ x[1], y[1] ], [ x[1], y[2] ], [ x[3], y[4] ], [ x[3], y[6] ], [ x[1], y[6] ], [ x[1], y[7] ], [ -x[1], y[7] ], [ -x[1], y[6] ], [ -x[3], y[6] ], [ -x[3], y[4] ], [ -x[1], y[2] ], [ -x[1], y[1] ] ]; indices = [ [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 ] ]; color( "#8080a0" ) difference() { rotate( [ 90, 0, 90 ] ) linear_extrude( length, convexity=2 ) polygon( points, indices ); for( x = [ 0 : hole_spacing : length+hole_width/2 ] ) { translate( [ x, width/2+1, hole_z ] ) rotate( [ 90, 0, 0 ] ) difference() { h = height - hole_z - lid_height; translate( [ -hole_width/2, 0, 0 ] ) cube( [ hole_width, h, width+2 ] ); translate( [ rounding_center, h - rounding_dia/2, -1 ] ) cylinder( width+4, d=rounding_dia ); translate( [ -rounding_center, h - rounding_dia/2, -1 ] ) cylinder( width+4, d=rounding_dia ); } /* this is transformed wrong in scad2step, i guess it's the square problem translate( [ x, width/2+1, hole_z ] ) rotate( [ 90, 0, 0 ] ) linear_extrude( width+2, convexity=2 ) difference() { h = height - hole_z - lid_height; translate( [ -hole_width/2, 0, 0 ] ) square( [ hole_width, h ] ); translate( [ rounding_center, h - rounding_dia/2, 0 ] ) circle( d=rounding_dia ); translate( [ -rounding_center, h - rounding_dia/2, 0 ] ) circle( d=rounding_dia ); } */ } for( x = [ 0 : 50 : length ] ) { translate( [ x+12, 0, -thickness/2 ] ) hole_oblong( 13.5, 6.5, thickness*2 ); translate( [ x+12+25, 0, -thickness/2 ] ) // 7,4 makes scad2step crash. why??? // hole_oblong( 7, 4, thickness*2 ); hole_oblong( 8, 4, thickness*2 ); } } } module channel_27x45( length ) { channel( length, 27, 45, 12.5, 5, 12, 4.2, 6, 7, 1.5 ); } // chamfers y and z directions module chamfer_tool_square_x( width, ly, lz ) { ly2 = ly * sqrt(.5); lz2 = lz * sqrt(.5); intersection() { cube( [ width, ly, lz ], center=true ); rotate( [ 0, 45, 0 ] ) cube( [ lz2, ly*5, lz2 ], center=true ); rotate( [ 0, 0, 45 ] ) cube( [ ly2, ly2, lz*5 ], center=true ); } } // cylindrical screw head with a slit module screw_head_slit( dia, h ) { color( "#b0c0e0" ) difference() { cylinder( h, d=dia ); translate( [ 0, 0, h ] ) rotate( [ 0, 0, rands( 0, 360, 1 )[0] ] ) cube( [ dia+2, dia/5, dia/2.5], center=true ); } } module isolator_red( h, d, screw ) { screw_dia = screw[0]; screw_depth = screw[1]; inset_dia = screw_dia * 1.4; inset_depth = screw_depth + 0.5; color( "#800000" ) { difference() { union() { cylinder( h[0], d=d[0] ); translate( [ 0, 0, h[0] ] ) cylinder( h[1]-h[0], d1=d[0], d2=d[1] ); translate( [ 0, 0, h[1] ] ) cylinder( h[2]-h[1], d1=d[1], d2=d[2] ); } translate( [ 0, 0, -0.5 ] ) cylinder( inset_depth+0.5, d=inset_dia ); translate( [ 0, 0, h[2]-inset_depth ] ) cylinder( inset_depth+0.5, d=inset_dia ); } } color( "#B59441" ) { difference() { cylinder( inset_depth, d=inset_dia ); cylinder( screw_depth, d=screw_dia ); } difference() { translate( [ 0, 0, h[2]-inset_depth ] ) cylinder( inset_depth, d=inset_dia ); translate( [ 0, 0, h[2]-screw_depth ] ) cylinder( inset_depth, d=screw_dia ); } } } module isolator_red_31mm() { isolator_red( [ 6, 7, 31 ], [ 30, 26, 24 ], [ 6, 8 ] ); } module isolator_red_40mm() { isolator_red( [ 4, 7, 40 ], [ 40, 34, 32 ], [ 6, 8 ] ); } module shunt_block( xyz, hole1, hole2, trans_x ) { translate( [ trans_x, 0, 0 ] ) difference() { translate( [ 0, -xyz[1]/2, 0 ] ) cube( xyz ); translate( [ hole1[0], 0, -1 ] ) cylinder( xyz[2]+2, d=hole1[1] ); translate( [ hole2[0], 0, xyz[2]/2 ] ) cylinder( xyz[2]/2+1, d=hole2[1] ); } } module shunt_100mm() { /* copper "#B87333" brass "#B59441" */ color( "#B59441" ) { shunt_block( [ 30, 20, 8 ], [ 10, 8 ], [ 25, 4 ], -60 ); rotate( [ 0, 0, 180 ] ) shunt_block( [ 30, 20, 8 ], [ 10, 8 ], [ 25, 4 ], -60 ); translate( [ -(60+2)/2, 0, 8/2 ] ) rotate( [ 0, 90, 0 ] ) cylinder( 60+2, d=4 ); } } module shunt_100mm_on_isolator() { translate( [ 0, 0, 31 ] ) shunt_100mm(); translate( [ 50, 0, 0 ] ) isolator_red_31mm(); translate( [ -50, 0, 0 ] ) isolator_red_31mm(); } module heatsink_fins( length, width, height, cut_count, cut_start_z, cut_pitch, cut_width, cut_offset_x ) { color( "#202020" ) difference() { cube( [ width, length, height ] ); for( i = [ 0 : cut_count-.1 ] ) { x = i * cut_pitch + cut_offset_x; translate( [ x, -1, cut_start_z ] ) cube( [ cut_width, length+2, height ] ); } } } module heatsink_197( length ) { heatsink_fins( length, 197, 33, 20, 7, 10.05, 6.5, 4 ); } /* create an MCB N: number of units height: vector of 4 height values width; vector of 2 width values rail_offset: offset of the DIN rail unit_length: length of one unit holes: [ hole_dia, hole_z, hole_x_off, hole_d ] */ module mcb( N, height, width, rail_offset, unit_length, holes ) { hole_dia = holes[0]; hole_z = holes[1]; hole_x_off = holes[2]; hole_d = holes[3]; body_cyl_r = 8; body_cyl_z = 56; body_cyl_y = -9 + rail_offset; screw_dia = 7; screw_d = 6; screw_y = (width[0] + width[1]) / 4; rail_width = 36; handle_y = -16 + rail_offset; handle_z = 64; handle_dia = 5; handle_holder_ratio = 2.5; base_shape = [ [ -rail_width/2, height[0] ], [ -rail_width/2, height[1] ], [ rail_width/2, height[1] ], [ rail_width/2, height[1]-1 ], [ rail_width/2-2, height[1]-3 ], [ rail_width/2-2, height[0] ], [ width[0]/2 + rail_offset, height[0] ], [ width[0]/2 + rail_offset, height[2] ], [ width[1]/2 + rail_offset, height[2] ], [ width[1]/2 + rail_offset, height[3] ], [ -width[1]/2 + rail_offset, height[3] ], [ -width[1]/2 + rail_offset, height[2] ], [ -width[0]/2 + rail_offset, height[2] ], [ -width[0]/2 + rail_offset, height[0] ] ]; union() { color( "#E0E0E0" ) { difference() { rotate( [ 90, 0, 90 ] ) { linear_extrude( N*unit_length, convexity=2 ) { polygon( base_shape ); translate( [ body_cyl_y, body_cyl_z, 0 ] ) circle( body_cyl_r ); } } for( i = [ 0 : N-.1 ] ) { x0 = i * unit_length; xm = x0 + unit_length / 2; wh = unit_length / handle_holder_ratio; // holes for connections translate( [ xm+hole_x_off, width[0]/2+rail_offset+0.5, hole_z ] ) rotate( [ 90, 0, 0 ] ) cylinder( hole_d, d=hole_dia ); translate( [ xm+hole_x_off, -width[0]/2+rail_offset-0.5+hole_d, hole_z ] ) rotate( [ 90, 0, 0 ] ) cylinder( hole_d, d=hole_dia ); // holes for screws translate( [ xm+hole_x_off, screw_y+rail_offset, height[2] - screw_d + 1 ] ) cylinder( screw_d, d=screw_dia ); translate( [ xm+hole_x_off, -screw_y+rail_offset, height[2] - screw_d + 1 ] ) cylinder( screw_d, d=screw_dia ); // cuts into body cylinder dh = sqrt( body_cyl_r^2 - (height[3]-body_cyl_z)^2 ); translate( [ xm-wh/2, body_cyl_y, height[3]-dh ] ) rotate( [ 45, 0, 0 ] ) cube( [ wh, body_cyl_r*2, body_cyl_r*2] ); } // chamfer c = sqrt( 0.5 ); for( x = [ 0 : N*unit_length : N*unit_length*1.1 ] ) { // bottom translate( [ x, 0, height[0] ] ) rotate( [ 0, 45, 0 ] ) cube( [ c, width[0]*2, c ], center=true ); // top translate( [ x, 0, height[3] ] ) rotate( [ 0, 45, 0 ] ) cube( [ c, width[0]*2, c ], center=true ); { yd = (width[0] - width[1]) / 2 + 2; zd = height[3] - height[2] + 2; // middle front translate( [ x, -width[1]/2 + rail_offset - yd/2 /*+ 0.5*/, height[2] + zd - 0.5 ] ) chamfer_tool_square_x( 1, yd, zd*2 ); // middle back translate( [ x, width[1]/2 + rail_offset + yd/2 /*- 0.5*/, height[2] + zd - 0.5 ] ) chamfer_tool_square_x( 1, yd, zd*2 ); } // front translate( [ x, -width[0]/2+rail_offset, 0 ] ) rotate( [ 0, 0, 45 ] ) cube( [ c, c, height[3]*2 ], center=true ); // back translate( [ x, width[0]/2+rail_offset, 0 ] ) rotate( [ 0, 0, 45 ] ) cube( [ c, c, height[3]*2 ], center=true ); // cylinder translate( [ x-0.5, -50, height[3] ] ) cube( [ 1, 100, 20 ] ); } } } // handle translate( [ 0.5, handle_y, handle_z ] ) rotate( [ 0, 90, 0 ] ) color( "#101010" ) cylinder( N*unit_length-1, d=handle_dia ); // inner cylinder translate( [ 1, body_cyl_y, body_cyl_z ] ) rotate( [ 0, 90, 0 ] ) color( "#101010" ) cylinder( N*unit_length-2, d=body_cyl_r ); // additional decoration for( i = [ 0 : N-.1 ] ) { x0 = i * unit_length; xm = x0 + unit_length / 2; wh = unit_length / handle_holder_ratio; // connection to handle lh = sqrt( (handle_y-body_cyl_y)^2 + (64-body_cyl_z)^2 ); angle = -atan2( handle_y-body_cyl_y, handle_z-body_cyl_z ); translate( [ xm-wh/2, body_cyl_y-handle_dia/5, body_cyl_z ] ) rotate( [ angle, 0, 0 ] ) color( "#101010" ) cube( [ wh, handle_dia/2.5, lh ] ); // screws translate( [ xm+hole_x_off, screw_y+rail_offset, height[2] - screw_d + 1 ] ) screw_head_slit( screw_dia, screw_dia/2 ); translate( [ xm+hole_x_off, -screw_y+rail_offset, height[2] - screw_d + 1 ] ) screw_head_slit( screw_dia*0.9, screw_dia/2 ); } } } module mcb_schneider_small( N ) { height = [ -5, 0, 44, 60 ]; width = [ 80, 46 ]; rail_offset = 2.5; unit_length = 18; holes = [ 8, 16, 0, 10 ]; mcb( N, height, width, rail_offset, unit_length, holes ); } module mcb_schneider_medium( N ) { height = [ -5, 0, 44, 60 ]; width = [ 80, 46 ]; rail_offset = 2.5; unit_length = 27; // holes: dia, z, x_off, depth holes = [ 10, 16, 6, 10 ]; mcb( N, height, width, rail_offset, unit_length, holes ); } module screw_head_philips_hex( d, h ) { r = d/2; r2 = r/2; rs = r * 0.86; color( "#A0A0B0" ) { difference() { linear_extrude( h ) polygon( [ [ r, 0 ], [ r2, rs ], [ -r2, rs ], [ -r, 0 ], [ -r2, -rs ], [ r2, -rs ] ] ); translate( [ 0, 0, h-0.25 ] ) cylinder( 1, d=d*0.8 ); w = d/8; t = d/3; difference() { union() { translate( [ -w/2, 0, h-t] ) rotate( [ 45, 0, 0 ] ) cube( [ w, d, d ] ); translate( [ 0, -w/2, h-t] ) rotate( [ 0, -45, 0 ] ) cube( [ d, w, d ] ); } translate( [ -d/2, -d/2, 0 ] ) cube( [ d, d, h-t*0.7 ] ); } } } } module power_module_nzz106( gate1, gate2 ) { base_x = 20; base_y = 92; base_h_al = 0.5; base_h_pl = 28; base_h_pl_1 = 10; base_h_pl_2 = 22; base_h_pl_gr = 26; base_h_pl_gt = 22; screw_cutout_x = 17; screw_cutout_y = 12; screw_cutout_z = 6; pin_pitch = 20; pin_y_1 = screw_cutout_y + 9.5; pin_y_2 = pin_y_1 + pin_pitch; pin_y_3 = pin_y_2 + pin_pitch; pin_h = 1.5; pin_w = 12; pin_l = 10; pin_z = base_h_al + base_h_pl; groove = [ screw_cutout_y + 18, screw_cutout_y + 18.5, screw_cutout_y + 20.5, screw_cutout_y + 21, screw_cutout_y + 38, screw_cutout_y + 38.5, screw_cutout_y + 40.5, screw_cutout_y + 41, screw_cutout_y + 60, screw_cutout_y + 61 ]; // aluminium plate color( "#A0A0B0" ) { difference() { cube( [ base_x, base_y, base_h_al ] ); // screw holes translate( [ base_x/2, base_y-screw_cutout_y/2, -1 ] ) cylinder( 10, d=6.5 ); translate( [ base_x/2, screw_cutout_y/2, -1 ] ) cylinder( 10, d=6.5 ); } } // plastic body color( "#F0F0F0" ) { translate( [ 0, 0, base_h_al ] ) difference() { //cube( [ base_x, base_y, base_h_pl ] ); rotate( [ 0, 90, 0 ] ) linear_extrude( base_x, convexity=2 ) polygon( [ [ 0, 0 ], [ 0, base_y ], [ -base_h_pl_1, base_y ], [ -base_h_pl_2, base_y - screw_cutout_y ], [ -base_h_pl_gr, base_y - screw_cutout_y ], [ -base_h_pl_gr, groove[9] ], [ -base_h_pl+1, groove[9] ], [ -base_h_pl, groove[8] ], [ -base_h_pl, groove[7] ], [ -base_h_pl_gr, groove[6] ], [ -base_h_pl_gr, groove[5] ], [ -base_h_pl, groove[4] ], [ -base_h_pl, groove[3] ], [ -base_h_pl_gr, groove[2] ], [ -base_h_pl_gr, groove[1] ], [ -base_h_pl, groove[0] ], [ -base_h_pl, screw_cutout_y + 1 ], [ -base_h_pl + 1, screw_cutout_y ], [ -base_h_pl_2, screw_cutout_y ], [ -base_h_pl_1, 0 ] ] ); // base for the screws translate( [ (base_x-screw_cutout_x)/2, -1, screw_cutout_z ] ) cube( [ screw_cutout_x, screw_cutout_y+1, base_h_pl ] ); translate( [ (base_x-screw_cutout_x)/2, base_y-screw_cutout_y+1, screw_cutout_z ] ) cube( [ screw_cutout_x, screw_cutout_y+1, base_h_pl ] ); // screw holes translate( [ base_x/2, base_y-screw_cutout_y/2, -1 ] ) cylinder( 10, d=6.5 ); translate( [ base_x/2, screw_cutout_y/2, -1 ] ) cylinder( 10, d=6.5 ); // gate cutouts translate( [ 1, groove[9], base_h_pl_gt ] ) cube( [ 8, 6, 5 ] ); translate( [ 11, groove[9], base_h_pl_gt ] ) cube( [ 8, 6, 5 ] ); } } color( "#8080A0" ) { // contacts translate( [ base_x/2-pin_w/2, pin_y_1-pin_l/2, pin_z ] ) cube( [ pin_w, pin_l, pin_h ] ); translate( [ base_x/2-pin_w/2, pin_y_2-pin_l/2, pin_z ] ) cube( [ pin_w, pin_l, pin_h ] ); translate( [ base_x/2-pin_w/2, pin_y_3-pin_l/2, pin_z ] ) cube( [ pin_w, pin_l, pin_h ] ); // gates if( gate1 ) { translate( [ 12, groove[9]+1.5, base_h_pl_gt-1 ] ) cube( [ 1, 3, 7 ] ); translate( [ 16, groove[9]+1.5, base_h_pl_gt-1 ] ) cube( [ 1, 3, 7 ] ); } if( gate2 ) { translate( [ 2, groove[9]+1.5, base_h_pl_gt-1 ] ) cube( [ 1, 3, 7 ] ); translate( [ 6, groove[9]+1.5, base_h_pl_gt-1 ] ) cube( [ 1, 3, 7 ] ); } } // screws translate( [ base_x/2, pin_y_1, pin_z+pin_h ] ) screw_head_philips_hex( 9, 3 ); translate( [ base_x/2, pin_y_2, pin_z+pin_h ] ) screw_head_philips_hex( 9, 3 ); translate( [ base_x/2, pin_y_3, pin_z+pin_h ] ) screw_head_philips_hex( 9, 3 ); } module power_module_ndd106() { power_module_nzz106( false, false ); } module power_module_ntd106() { power_module_nzz106( true, false ); } module power_module_ntt106() { power_module_nzz106( true, true ); } module barrier_terminal( N, pitch, length ) { wall = pitch * 0.15; wall_h = pitch * 0.6; w = pitch * N + wall; l = length; h_base = pitch * 0.3; screw_d = pitch * 0.6; screw_h = screw_d * 0.4; // plastic color( "#202020" ) { translate( [ -w/2, -l/2, 0 ] ) cube( [ w, l, h_base ] ); for( x = [ -N*pitch/2-wall/2 : pitch : N*pitch/2 ] ) { translate( [ x, -l/2, h_base ] ) cube( [ wall, l, wall_h ] ); } } // contacts color( "#B59441" ) { for( x = [ -N*pitch/2+wall/2 : pitch : N*pitch/2 ] ) { translate( [ x, -l/2+0.1*l, h_base ] ) cube( [ pitch-wall, l*0.8, 1 ] ); } } // screws for( x = [ (1-N)*pitch/2 : pitch : N*pitch/2 ] ) { translate( [ x, 0, h_base ] ) screw_head_slit( screw_d, screw_h ); } } module dcdc_converter_110v_24v_2a() { w = 110; l = 60; h = 25; t = 1; // cutout for terminals ctw = 12; ctl = 44; // holes hole_dia = 5; hole_pitch = 6.8; // pcb pcb_z = 5; pcb_h = 2; // parameters for the holes hlxp = hole_pitch * 1.732; hlxs = -2.75* hlxp; hlxe = -hlxs; hlyp = hole_pitch; hlys = -7.5 * hole_pitch / 2; hlye = -hlys; hld = 5; color( "#C0C0D0" ) { difference() { // main block translate( [ -w/2, -l/2, 0 ] ) cube( [ w, l, h ] ); // hollow it out translate( [ -w/2-1, -l/2+t, t ] ) cube( [ w+2, l-2*t, h-2*t ] ); // cutout for terminals translate( [ -w/2-1, -ctl/2, h-2*t ] ) cube( [ ctw+1, ctl, 3*t ] ); translate( [ w/2-ctw, -ctl/2, h-2*t ] ) cube( [ ctw+1, ctl, 3*t ] ); // holes on top for( x = [ hlxs : hlxp : hlxe ] ) { for( y = [ hlys : hlyp : hlye ] ) { translate( [ x, -y, h-2*t ] ) cylinder( 3*t, d=hld ); translate( [ x+hlxp/2, y, h-2*t ] ) cylinder( 3*t, d=hld ); } } } } // pcb color( "#007000" ) { translate( [ -w/2, -l/2+t, pcb_z ] ) cube( [ w, l-2*t, pcb_h ] ); } // terminals translate( [ -w/2 + 8, 0, pcb_z + pcb_h ] ) rotate( [ 0, 0, 90 ] ) barrier_terminal( 2, 10, 14 ); translate( [ w/2 - 8, 0, pcb_z + pcb_h ] ) rotate( [ 0, 0, -90 ] ) barrier_terminal( 3, 10, 14 ); } translate( [ -50, 0, 0 ] ) hat_rail( 250 ); translate( [ 0, 0, 7 ] ) mcb_schneider_small( 3 ); translate( [ 54, 0, 7 ] ) mcb_schneider_small( 2 ); translate( [ 90, 0, 7 ] ) mcb_schneider_medium( 2 ); translate( [ 0, 100, 0 ] ) channel_27x45( 200 ); translate( [ 0, -100, 0 ] ) channel_27x45( 200 ); translate( [ 0, 300, 33 ] ) rotate( [ 180, 0, 0 ] ) translate( [ 0, -400, 0 ] ) heatsink_197( 400 ); translate( [ 30, 360, 33 ] ) power_module_ntt106(); translate( [ 70, 360, 33 ] ) power_module_ntt106(); translate( [ 110, 360, 33 ] ) power_module_ntt106(); translate( [ 150, 360, 33 ] ) power_module_ndd106(); translate( [ 300, 60, 0 ] ) dcdc_converter_110v_24v_2a(); translate( [ -60, 500, 0 ] ) rotate( [ 0, 0, 90 ] ) shunt_100mm_on_isolator();