diff --git a/readme.md b/readme.md index fd13886..cc71ad6 100644 --- a/readme.md +++ b/readme.md @@ -3887,6 +3887,7 @@ NEMA stepper motor model. | Function | Description | |:--- |:--- | | `NEMA_big_hole(type)` | Clearance hole for the big boss | +| `NEMA_connection_pos(type, jst_connector = false)` | Position of the wires or the connector | | `NEMA_holes(type)` | Screw positions for for loop | ### Modules diff --git a/tests/png/stepper_motors.png b/tests/png/stepper_motors.png index 5d1c944..9b9af10 100644 Binary files a/tests/png/stepper_motors.png and b/tests/png/stepper_motors.png differ diff --git a/tests/stepper_motors.scad b/tests/stepper_motors.scad index e92ce36..8b5b38d 100644 --- a/tests/stepper_motors.scad +++ b/tests/stepper_motors.scad @@ -16,18 +16,28 @@ // You should have received a copy of the GNU General Public License along with NopSCADlib. // If not, see . // +show_connection_pos = false; + +/* [Hidden] */ include <../core.scad> include <../vitamins/stepper_motors.scad> use <../utils/layout.scad> +has_connector = [NEMA17_27, NEMA17_40, NEMA17_40L280, NEMA8_30, NEMA8_30BH]; + module stepper_motors() layout([for(s = stepper_motors) NEMA_width(s)], 5, no_offset = false) let(m = stepper_motors[$i]) { - rotate(180) - NEMA(m, 0, in([NEMA17_27, NEMA17_40, NEMA17_40L280, NEMA8_30, NEMA8_30BH], m)); + rotate(180) { + NEMA(m, 0, in(has_connector, m) ? true : show_connection_pos ? undef : false); - translate_z(4) - NEMA_screws(m, M3_pan_screw, n = $i - 2, earth = $i > 6 ? undef : $i - 3); + if(show_connection_pos) + translate(NEMA_connection_pos(m, in(has_connector, m))) + sphere(); + + translate_z(4) + NEMA_screws(m, M3_pan_screw, n = $i - 2, earth = $i > 6 ? undef : $i - 3); + } } if($preview) diff --git a/vitamins/stepper_motor.scad b/vitamins/stepper_motor.scad index 08b45d6..57b6ad4 100644 --- a/vitamins/stepper_motor.scad +++ b/vitamins/stepper_motor.scad @@ -51,6 +51,18 @@ stepper_body_colour = grey(20); stepper_cap_colour = grey(50); stepper_machined_colour = grey(90); +function NEMA_connection_pos(type, jst_connector = false) = let( //! Position of the wires or the connector + side = NEMA_width(type), + length = NEMA_length(type), + cap = NEMA_cap_heights(type)[1], + hdr = NEMA_end_connector(type) ? jst_zh_header : jst_ph_header, + socket_size = hdr_box_size(hdr), + end_conn_inset = socket_size.y - 2 + ) + jst_connector ? NEMA_end_connector(type) ? [0, side / 2 + hdr_y_offset(hdr) + socket_size.y / 2 - end_conn_inset, -length] + : [0, side / 2 + socket_size.z, hdr_y_offset(hdr) - socket_size.y / 2 - length + cap] + : [0, side / 2, -length + cap / 2]; + module NEMA_outline(type) //! 2D outline intersection() { side = NEMA_width(type); @@ -185,14 +197,14 @@ module NEMA(type, shaft_angle = 0, jst_connector = false) { //! Draw specified N not_on_bom() leadscrew(shaft_rad * 2, shaft.x + length + shaft2, shaft.y, shaft.z, center = false); - if(!jst_connector) + if(jst_connector == false) translate([0, side / 2, -length + cap / 2]) rotate([90, 0, 0]) for(i = [0 : 3]) rotate(225 + i * 90) - color(["red", "blue","green","black"][i]) - translate([1, 0, 0]) - cylinder(r = 1.5 / 2, h = 12, center = true); + color(["red", "green", "black", "blue"][i]) + translate([1.48 / sqrt(2), 0, 0]) + cylinder(d = 1.48, h = 12, center = true); } module NEMA_screw_positions(type, n = 4) { //! Positions children at the screw holes