123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812 |
- /*
- * Resources used:
- * https://www.thingiverse.com/thing:16627
- * https://www.chiefdelphi.com/t/timing-pulley-design-tutorial/383204
- *
- * Hardware required:
- * https://www.banggood.com/15pcs-Transparent-Pulley-Wheel-with-625zz-Double-Bearing-for-V-slot-3D-Printer-p-1575067.html?cur_warehouse=CN&rmmds=search
- * 2x NEMA17 stepper
- * 2040 extrusions, lengths see console output
- * 2020 extrusions, lengths see console output
- * GT2 belt, lengths see console output
- */
-
- include <config.scad>;
- use <gt2_pulley.scad>;
- use <common.scad>;
-
- $fn = 42;
-
- /***********************************
- ********** Printed Parts **********
- ***********************************/
-
- module belt_pulley(tc, dia, for_motor = 1) {
- difference() {
- union() {
- cylinder(d = dia + belt_pulley_rim * 2, h = (belt_pulley_width - belt_pulley_tooth_width) / 2);
-
- translate([0, 0, (belt_pulley_width - belt_pulley_tooth_width) / 2])
- gt2_2mm_pulley(tc, belt_pulley_tooth_width);
- cylinder(d = dia, h = (belt_pulley_width - belt_pulley_tooth_width) / 2);
-
- translate([0, 0, (belt_pulley_width - belt_pulley_tooth_width) / 2 + belt_pulley_tooth_width])
- cylinder(d = dia + belt_pulley_rim * 2, h = (belt_pulley_width - belt_pulley_tooth_width) / 2);
- }
-
- if (for_motor) {
- // motor shaft hole
- translate([0, 0, -1])
- cylinder(d = belt_pulley_axis_hole, h = belt_pulley_width + 2);
-
- // grub screw
- for (i = [0, 90])
- translate([0, 0, belt_pulley_width / 2])
- rotate([90, 0, i])
- cylinder(d = belt_pulley_fix_dia, h = dia / 2 + 1);
- } else {
- // bearing hole
- translate([0, 0, -1])
- cylinder(d = bearing_outer, h = belt_pulley_width + 2);
-
- // grub screw
- for (i = [0, 90, 180, 270])
- translate([0, 0, (i > 90 ? 1 : -1) * 2])
- translate([0, 0, belt_pulley_width / 2])
- rotate([90, 0, i])
- cylinder(d = belt_pulley_fix_dia, h = dia / 2 + 1);
- }
- }
- }
-
- module belt_tensioner_diff() {
- translate([-50, -belt_tensioner_diff_len, -belt_tensioner_diff_height / 2])
- cube([100, belt_tensioner_diff_len, belt_tensioner_diff_height]);
-
- translate([-belt_tensioner_diff_width / 2, -belt_tensioner_diff_len, -50])
- cube([belt_tensioner_diff_width, belt_tensioner_diff_len, 100]);
- }
-
- module belt_tensioner_mount_rail(height) {
- echo("belt tensioner", "t-nut", str(height * 2, "x"), str(motor_mount_hole_size_nominal, "mm"));
-
- difference() {
- if (height == 1) {
- for (i = [ 10, -10 - belt_tensioner_wall ])
- translate([i, 0, 0])
- cube([belt_tensioner_wall, belt_tensioner_mount_depth, 20 + belt_tensioner_wall]);
- } else {
- for (i = [ 10, -10 - belt_tensioner_wall ])
- translate([i, 0, -20])
- cube([belt_tensioner_wall, belt_tensioner_mount_depth, 40 + belt_tensioner_wall]);
- }
-
- for (i = [ 10, -10 ])
- translate([-10 - belt_tensioner_wall - 1, belt_tensioner_mount_depth / 2, i])
- rotate([0, 90, 0])
- cylinder(d = motor_mount_hole_size, h = 20 + 2 * belt_tensioner_wall + 2);
- }
- }
-
- module belt_tensioner_mount(height) {
- echo("belt tensioner", "screw", "1x", str("M", belt_tensioner_screw), str(">", belt_tensioner_diff_len + belt_tensioner_wall + 5 - real_belt_pulley_dia, "mm"));
-
- echo("belt tensioner", "nut", "1x", str("M", belt_tensioner_screw));
-
- belt_tensioner_mount_rail(height);
-
- difference() {
- hull() {
- if (height == 1) {
- for (i = [ 10, -10 - belt_tensioner_wall ])
- translate([i, 0, 0])
- cube([belt_tensioner_wall, 1, 20 + belt_tensioner_wall]);
- } else {
- for (i = [ 10, -10 - belt_tensioner_wall ])
- translate([i, 0, -20])
- cube([belt_tensioner_wall, 1, 40 + belt_tensioner_wall]);
- }
-
- translate([-10, -belt_tensioner_diff_len - belt_tensioner_wall - 5, 25 - 21])
- cube([20, belt_tensioner_wall, 20 + 1]);
- }
-
- translate([-10 - belt_tensioner_wall - 1, 0, -22])
- cube([20 + 2 * belt_tensioner_wall + 2, 50, 50]);
-
- translate([-10, 0, -22])
- cube([20, 50, 50]);
-
- translate([0, 0, 10 + belt_pulley_off])
- belt_tensioner_diff();
-
- translate([0, -belt_tensioner_diff_len - belt_tensioner_wall - 5 + 30 - 1, real_belt_pulley_dia / 2 + 0.175])
- rotate([90, 0, 0])
- cylinder(d = belt_tensioner_screw_hole, h = 30);
- }
- }
-
- module belt_tensioner_moving() {
- %color("red")
- translate([-belt_pulley_width / 2, 0, 0])
- rotate([0, 90, 0])
- rotate([0, 0, -acos(anim_pos_x * -2 + 1)])
- belt_pulley(teethcount, real_belt_pulley_dia, 0);
-
- color("cyan")
- difference() {
- for (i = [-1, 1])
- scale([i, 1, 1])
- translate([belt_pulley_width / 2 + belt_tensioner_moving_gap, belt_tensioner_moving_overlap - belt_tensioner_moving_len, -belt_tensioner_moving_height / 2])
- cube([belt_tensioner_wall, belt_tensioner_moving_len, belt_tensioner_moving_height]);
-
- translate([-belt_pulley_width / 2 - belt_tensioner_wall - belt_tensioner_moving_gap - 1, 0, 0])
- rotate([0, 90, 0])
- cylinder(d = axis_hole_diameter, h = belt_pulley_width + 2 * (belt_tensioner_wall + belt_tensioner_moving_gap) + 2);
- }
-
- color("cyan")
- translate([-belt_pulley_width / 2 - belt_tensioner_moving_gap, -belt_tensioner_moving_len + belt_tensioner_moving_overlap, -belt_tensioner_moving_height / 2])
- difference() {
- cube([belt_pulley_width + 2 * belt_tensioner_moving_gap, belt_tensioner_wall, belt_tensioner_moving_height]);
-
- translate([belt_pulley_width / 2 + belt_tensioner_moving_gap, belt_tensioner_wall + 1, belt_tensioner_moving_height / 2])
- rotate([90, 0, 0])
- cylinder(d = belt_tensioner_screw_hole, h = belt_tensioner_wall + 2);
- }
- }
-
- module belt_tensioner(height, length = 100, visual = 1) {
- if (visual)
- %translate([-10, 0, 0])
- if (length > 0) {
- if (height == 1) {
- rail_2020_y(length, "only for visualization");
- } else {
- rail_2040_y(length, "only for visualization");
- }
- }
-
- translate([0, -belt_tensioner_travel * $t, 0])
- translate([0, -real_belt_pulley_dia / 2, 10 + belt_pulley_off])
- belt_tensioner_moving();
-
- color("orange")
- belt_tensioner_mount(height);
-
- %color("yellow")
- translate([-belt_width / 2, -real_belt_pulley_dia / 2, 10 + real_belt_pulley_dia / 2 + belt_pulley_off - belt_thickness / 2])
- cube([belt_width, length + real_belt_pulley_dia / 2 + nema17_size / 2, belt_thickness]);
-
- %color("yellow")
- translate([-belt_width / 2, -real_belt_pulley_dia / 2, 10 - real_belt_pulley_dia / 2 - belt_thickness / 2 + belt_pulley_off])
- cube([belt_width, length + real_belt_pulley_dia / 2 + nema17_size / 2, belt_thickness]);
- }
-
- module motor_mount(height) {
- echo("motor mount", "t-nut", str(height * 2, "x"), str(motor_mount_hole_size_nominal, "mm"));
-
- echo("motor mount", "screw", "4x", str("M", nema17_hole_size), str(motor_mount_height + 2, "-", motor_mount_height + 4, "mm"));
-
- %color("yellow")
- translate([-nema17_len, 0, nema17_size - belt_pulley_off])
- rotate([0, 90, 0])
- nema17(nema17_len);
-
- %color("red")
- translate([motor_mount_height - belt_pulley_width / 2 + 10, nema17_size / 2, nema17_size / 2 - belt_pulley_off])
- rotate([0, 90, 0])
- rotate([0, 0, -acos(anim_pos_x * -2 + 1)])
- belt_pulley(teethcount, real_belt_pulley_dia, 1);
-
- color("cyan")
- difference() {
- hull() {
- translate([0, 0, -belt_pulley_off])
- cube([motor_mount_height, nema17_size, nema17_size]);
-
- translate([0, nema17_size, (nema17_size - 20) / 2])
- cube([motor_mount_height, motor_mount_length, height * 20]);
- }
-
- translate([0, 0, -belt_pulley_off])
- translate([-nema17_len, 0, nema17_size])
- rotate([0, 90, 0]) {
- nema17_holes_face(nema17_len, motor_mount_height + 5, nema17_hole_size + screw_gap);
-
- translate([nema17_size / 2, nema17_size / 2, nema17_len - 1])
- cylinder(d = nema17_center_size + 2, h = motor_mount_height + 2);
- }
-
- for (i = [0, motor_mount_hole_off])
- for (j = [0, 20 * (height - 1)])
- translate([0, i, j])
- translate([-1, nema17_size - motor_mount_hole_off / 2 + motor_mount_length / 2, nema17_size / 2])
- rotate([0, 90, 0]) {
- cylinder(d = motor_mount_hole_size, h = motor_mount_height + 2);
- }
- }
- }
-
- /***********************************
- ************** Plate **************
- ***********************************/
-
- module plate_holes(h) {
- for (i = [-1, 1])
- for (j = [-1, 1])
- translate([i * plate_mount_screws_distance_x / 2, j * plate_mount_screws_distance_y / 2, -1])
- cylinder(d = plate_mount_screw_hole, h = h + 2);
- }
-
- module plate() {
- echo("alu plate", "bed", plate_x, plate_y, "holes", plate_mount_screws_distance_x, plate_mount_screws_distance_y);
-
- difference() {
- cube([plate_x, plate_y, plate_z]);
-
- translate([plate_x / 2, plate_y / 2, 0])
- plate_holes(plate_z);
- }
- }
-
- /************************************
- ************** Y-Axis **************
- ************************************/
-
- module belt_mount(h) {
- difference() {
- hull() {
- translate([-belt_mount_width / 2, -belt_mount_depth / 2, 0])
- cube([belt_mount_width, belt_mount_depth, h]);
-
- translate([-belt_mount_full_width / 2, belt_mount_depth / 2, 0])
- cube([belt_mount_full_width, 1, h]);
- }
-
- translate([-belt_slot_width / 2, -belt_slot_depth / 2, -1])
- cube([belt_slot_width, belt_slot_depth, h + 2]);
-
- translate([-belt_mount_full_width / 2, -belt_mount_depth / 2 - 0.1, h / 2])
- rotate([-90, 0, 0])
- prism(belt_mount_full_width, h / 2 + 0.1, belt_mount_depth + 0.1);
- }
- }
-
- module eccentric() {
- translate([0, 0, eccentric_height_add]) {
- cylinder(d = eccentric_dia_main, h = eccentric_height_main);
-
- translate([0, 0, -eccentric_height_inset])
- cylinder(d = eccentric_dia_inset, h = eccentric_height_inset);
- }
- }
-
- module y_carriage_post() {
- rotate([0, 0, 90])
- difference() {
- cylinder(d = y_carriage_post_dia, h = y_carriage_post_len, $fn = 6);
-
- translate([0, 0, -1])
- cylinder(d = y_carriage_post_screw_hole, h = (y_carriage_post_len - y_carriage_post_center) / 2 + 1);
-
- translate([y_carriage_post_hole_off, 0, (y_carriage_post_len + y_carriage_post_center) / 2])
- cylinder(d = y_carriage_post_screw_hole, h = (y_carriage_post_len - y_carriage_post_center) / 2 + 1);
- }
- }
-
- module y_carriage_posts() {
- for (i = [-1, 1])
- for (j = [-1, 1])
- translate([i * y_carriage_wheel_x_dist / 2, j * y_carriage_wheel_y_dist / 2, 0]) {
- if (use_custom_eccentric) {
- color("yellow")
- eccentric();
-
- %color("yellow")
- translate([0, eccentric_hole_off, y_carriage_pulley_off])
- rail_wheel();
- } else {
- color("blue")
- y_carriage_post();
-
- %color("yellow")
- translate([0, y_carriage_post_hole_off, y_carriage_pulley_off])
- rail_wheel();
- }
- }
- }
-
- module carriage_spacer() {
- difference() {
- cube([y_carriage_x, y_carriage_y, carriage_spacer_height]);
-
- translate([y_carriage_x / 2, y_carriage_y / 2, 0])
- plate_holes(carriage_spacer_height);
-
- translate([carriage_spacer_cut_x / 2 * sqrt(2) + y_carriage_x / 2, -1, -1])
- rotate([0, -90, 45])
- prism(carriage_spacer_height + 2, carriage_spacer_cut_x, carriage_spacer_cut_x);
-
- translate([-carriage_spacer_cut_x / 2 * sqrt(2) + y_carriage_x / 2, y_carriage_y + 1, -1])
- rotate([0, -90, 225])
- prism(carriage_spacer_height + 2, carriage_spacer_cut_x, carriage_spacer_cut_x);
-
- translate([-1, y_carriage_y / 2 - carriage_spacer_cut_y / 2 * sqrt(2), -1])
- rotate([0, -90, -45])
- prism(carriage_spacer_height + 2, carriage_spacer_cut_y, carriage_spacer_cut_y);
-
- translate([y_carriage_x + 1, y_carriage_y / 2 + carriage_spacer_cut_y / 2 * sqrt(2), -1])
- rotate([0, -90, -225])
- prism(carriage_spacer_height + 2, carriage_spacer_cut_y, carriage_spacer_cut_y);
- }
- }
-
- // also used as base for x-carriage
- // axis = 0 --> all holes, usable for both
- // axis = 1 --> holes for x-carriage
- // axis = 2 --> holes for y-carriage
- module y_carriage(axis = 0) {
- if (axis == 1) {
- echo("t-nut", "x-carriage", "2");
- }
-
- if (use_custom_eccentric) {
- echo("eccentric", "carriage", "4");
- echo("screw", "carriage", "M5x30", "4");
- echo("nut", "carriage", "M5", "4");
- }
-
- color("green")
- difference() {
- union() {
- cube([y_carriage_x, y_carriage_y, y_carriage_h]);
-
- translate([y_carriage_x / 2, y_carriage_y / 2, 0])
- for (i = [-1, 1])
- translate([0, i * (y_carriage_y + belt_mount_depth) / 2, 0])
- scale([1, -i, 1])
- belt_mount(y_carriage_h);
-
- // additional "meat" for eccentric inset
- translate([y_carriage_x / 2, y_carriage_y / 2, y_carriage_h])
- for (i = [-1, 1])
- for (j = [-1, 1])
- translate([i * y_carriage_wheel_x_dist / 2, j * y_carriage_wheel_y_dist / 2, 0])
- if (use_custom_eccentric)
- cylinder(d = eccentric_inset_wall, h = eccentric_height_add);
- }
-
- translate([y_carriage_x / 2, y_carriage_y / 2, 0])
- plate_holes(y_carriage_h);
-
- // holes to mount y-axis to x-carriage
- if ((axis == 0) || (axis == 1)) {
- translate([(y_carriage_x - plate_mount_screws_distance_x) / 2, 0, 0])
- for (i = [0, 1])
- translate([i * plate_mount_screws_distance_x, y_carriage_y / 2, -1])
- cylinder(d = y_carriage_post_screw_hole, h = y_carriage_h + 2);
-
- for (i = [x_carriage_holder_l - x_carriage_holder_hole_off, y_carriage_y - x_carriage_holder_l + x_carriage_holder_hole_off])
- translate([y_carriage_x / 2, i, -1])
- cylinder(d = y_carriage_post_screw_hole, h = y_carriage_h + 2);
- }
-
- // holes for wheel posts
- translate([y_carriage_x / 2, y_carriage_y / 2, 0])
- for (i = [-1, 1])
- for (j = [-1, 1])
- translate([i * y_carriage_wheel_x_dist / 2, j * y_carriage_wheel_y_dist / 2, -1])
- if (use_custom_eccentric) {
- cylinder(d = eccentric_screw_hole, h = y_carriage_h + 2);
-
- translate([0, 0, y_carriage_h + eccentric_height_add + 1 - eccentric_inset_hole])
- cylinder(d = eccentric_dia_inset, h = eccentric_inset_hole + 1);
-
- cylinder(d = eccentric_screw_hole_dia, h = eccentric_screw_hole_h + 1);
- } else {
- cylinder(d = y_carriage_post_screw_hole, h = y_carriage_h + 2);
- }
- }
-
- %translate([y_carriage_x / 2, y_carriage_y / 2, y_carriage_h])
- y_carriage_posts();
- }
-
- module y_axis() {
- translate([y_carriage_x / 2, y_axis_animation_position, 20 + y_carriage_h + y_carriage_rail_dist])
- rotate([0, 180, 0]) {
- y_carriage(2);
-
- color("cyan")
- translate([0, 0, -carriage_spacer_height - 0.01])
- carriage_spacer();
- }
-
- color("grey")
- translate([-10, 0, 0])
- rail_2040_y(y_axis_rail_len, "y-axis");
-
- translate([- motor_mount_height - 10, y_axis_rail_len + nema17_size, nema17_size / 2 + 10])
- rotate([180, 0, 0])
- motor_mount(2);
-
- translate([10 + endstop_mount_depth, y_axis_rail_len - endstop_mount_width, -20])
- rotate([0, 0, 90])
- endstop_mount();
-
- belt_tensioner(2, y_axis_rail_len, 0);
- }
-
- /************************************
- ************** X-Axis **************
- ************************************/
-
- module x_carriage_holder() {
- echo("t-nut", "x-carriage-holder", "2");
-
- difference() {
- union() {
- cube([x_carriage_holder_l, x_carriage_holder_w, x_carriage_holder_h]);
- cube([x_carriage_holder_h, x_carriage_holder_w, 20]);
- }
-
- translate([0, (x_carriage_holder_w - x_carriage_holder_rail_hole_dist) / 2, 0])
- for (i = [0, x_carriage_holder_rail_hole_dist])
- translate([-1, i, 10])
- rotate([0, 90, 0])
- cylinder(d = y_carriage_post_screw_hole, h = x_carriage_holder_h + 2);
-
- translate([-(y_carriage_y - plate_mount_screws_distance_y) / 2, y_carriage_x / 2, 0])
- rotate([0, 0, 90])
- plate_holes(x_carriage_holder_h);
-
- translate([x_carriage_holder_hole_off, x_carriage_holder_w / 2, -1])
- cylinder(d = y_carriage_post_screw_hole, h = x_carriage_holder_h + 2);
- }
- }
-
- module x_carriage() {
- translate([0, -y_carriage_x / 2, y_carriage_h + y_carriage_rail_dist + 20])
- rotate([0, 180, -90])
- y_carriage(1);
-
- /*
- color("purple")
- for (i = [-1, 1])
- translate([y_carriage_y / 2, 0, 0])
- scale([i, 1, 1])
- translate([y_carriage_y / 2 - x_carriage_holder_l, 0, 0])
- translate([0, -x_carriage_holder_w / 2, 20 + y_carriage_h + y_carriage_rail_dist])
- x_carriage_holder();
- */
- }
-
- module x_axis() {
- translate([x_axis_animation_position + 10, 0, 0])
- x_carriage();
-
- color("grey")
- translate([0, -10, 0])
- rail_2040_x(x_axis_rail_len, "x-axis");
-
- translate([x_axis_rail_len + nema17_size, motor_mount_height + 10, nema17_size / 2 + 10])
- rotate([0, 180, 90])
- motor_mount(2);
-
- translate([x_axis_rail_len - endstop_mount_width, -10 - endstop_mount_depth, -20])
- endstop_mount();
-
- rotate([0, 0, -90])
- belt_tensioner(2, x_axis_rail_len, 0);
- }
-
- /*************************************
- *************** Stuff ***************
- *************************************/
-
- psu_width = 98.0;
- psu_height = 43.0;
- psu_length = 160;
- psu_cut_gap = 1.0;
- psu_cut_w = psu_width + psu_cut_gap;
- psu_cut_h = psu_height + psu_cut_gap;
- psu_wall = 4;
- psu_mount_len = 40 + psu_wall;
- psu_mount_w = psu_cut_w + 2 * psu_wall;
- psu_mount_h = psu_cut_h + 2 * psu_wall;
- psu_mount_hole_off = 10;
- psu_mount_tri = 3;
- psu_mount_del = psu_mount_tri;
- psu_assembly_mount_off_y = 25;
- psu_assembly_mount_off_z = 6;
- psu_hole_dia = 4.2;
- psu_back_hole_x = 9.5;
- psu_back_hole_y = 18.0;
- psu_cable_hole = 8.0;
- psu_cable_hole_off = 13.0;
- //psu_side_hole_y = 26.0;
- //psu_side_Hole_z = 20.0;
-
- power_socket_width = 48.0;
- power_socket_height = 28.0;
- power_socket_depth = 30;
- power_socket_hole = 2.7;
- power_socket_hole_off = 11.0 - 2.8 - 1.6;
- power_socket_rim = 11;
- power_socket_wr = power_socket_width + 2 * power_socket_rim;
- power_socket_hr = power_socket_height + 2 * power_socket_rim;
-
- power_box_width = 70;
- power_box_height = psu_mount_h;
- power_box_depth = 50;
-
- module power_socket() {
- translate([-power_socket_width / 2, -power_socket_height / 2, -power_socket_depth])
- cube([power_socket_width, power_socket_height, power_socket_depth]);
-
- difference() {
- translate([-power_socket_wr / 2, -power_socket_hr / 2, 0])
- cube([power_socket_wr, power_socket_hr, 2.0]);
-
- for (i = [-1, 1])
- translate([0, i * (power_socket_height / 2 + power_socket_hole_off), -1])
- cylinder(d = power_socket_hole, h = 4.0);
- }
- }
-
- module power_box() {
- %color("yellow")
- translate([power_box_width / 2, power_box_depth, power_box_height / 2])
- rotate([-90, 0, 0])
- power_socket();
-
- color("cyan")
- difference() {
- translate([0, power_box_depth - psu_wall, 0])
- cube([power_box_width, psu_wall, power_box_height]);
-
- translate([(power_box_width - power_socket_width) / 2, power_box_depth - 9, (power_box_height - power_socket_height) / 2])
- cube([power_socket_width, 10, power_socket_height]);
-
- for (i = [1, -1])
- translate([power_box_width / 2, power_box_depth + 1, (power_box_height - i * power_socket_height) / 2 - power_socket_hole_off * i])
- rotate([90, 0, 0])
- cylinder(d = power_socket_hole, h = psu_wall + 15);
- }
- }
-
- module psu_holder_tab() {
- difference() {
- translate([psu_mount_del, 0, 0])
- cube([20 - psu_mount_del, psu_wall, psu_mount_len]);
-
- for (i = [psu_mount_hole_off, psu_mount_len - psu_mount_hole_off])
- translate([10, -1, i])
- rotate([-90, 0, 0])
- cylinder(d = motor_mount_hole_size, h = psu_wall + 2);
- }
- }
-
- module psu_holder_box(remove_back = 0) {
- if (!remove_back)
- translate([-psu_mount_w / 2, -psu_mount_h / 2 - psu_assembly_mount_off_z, 0])
- cube([psu_mount_w, psu_mount_h, psu_wall]);
-
- for (i = [-psu_mount_h / 2, psu_mount_h / 2 - psu_wall])
- translate([-psu_mount_w / 2, i - psu_assembly_mount_off_z, 0])
- cube([psu_mount_w, psu_wall, psu_mount_len]);
-
- for (i = [-psu_mount_w / 2, psu_mount_w / 2 - psu_wall])
- translate([i, -psu_mount_h / 2 - psu_assembly_mount_off_z, 0])
- cube([psu_wall, psu_mount_h, psu_mount_len]);
-
- for (i = [/* psu_mount_w / 2, */ -psu_mount_w / 2 - 20])
- for (j = [10, -10 - psu_wall])
- translate([i, j, 0])
- psu_holder_tab();
-
- for (i = [0, 1])
- translate([-psu_mount_w / 2 - i * psu_mount_tri, -psu_mount_tri - 10 - psu_wall + i * (psu_mount_tri + 20 + psu_wall * 2), 0])
- rotate([0, -90, i * -90])
- prism(psu_mount_len, psu_mount_tri, psu_mount_tri);
- }
-
- module psu_holder(part) {
- // 0 is "back side" of psu
- // 1 is "front" / cable side of psu
-
- difference() {
- union() {
- color("cyan")
- translate([0, 0, part * psu_mount_len])
- scale([1, 1, 1 + part * -2])
- psu_holder_box(part);
-
- if (part == 1) {
- color("cyan")
- translate([0, -psu_mount_h / 2 - psu_assembly_mount_off_z, psu_mount_len])
- hull() {
- translate([-power_box_width / 2, 0, power_box_depth - psu_wall - 1])
- cube([power_box_width, power_box_height, 1]);
-
- translate([-psu_mount_w / 2, 0, 0])
- cube([psu_mount_w, psu_mount_h, 1]);
- }
-
- translate([-power_box_width / 2, psu_mount_h / 2 - psu_assembly_mount_off_z, psu_mount_len])
- rotate([90, 0, 0])
- power_box();
- }
- }
- if (part == 0) {
- translate([-psu_mount_w / 2 + psu_back_hole_x + psu_wall, psu_mount_h / 2 - psu_assembly_mount_off_z + 1, psu_back_hole_y + psu_wall])
- rotate([90, 0, 0])
- cylinder(d = psu_hole_dia, h = psu_wall + 2);
- } else {
- translate([0, -psu_mount_h / 2 - psu_assembly_mount_off_z, psu_mount_len])
- hull() {
- translate([-power_socket_width / 2, power_socket_height / 2 - psu_wall / 2, power_box_depth - psu_wall])
- cube([power_socket_width, power_socket_height, 1]);
-
- translate([-psu_mount_w / 2 + psu_wall, psu_wall, -1])
- cube([psu_mount_w - 2 * psu_wall, psu_mount_h - 2 * psu_wall, 1]);
- }
-
- for (i = [-1, 0, 1])
- translate([i * psu_cable_hole_off, 0, 0])
- translate([0, -psu_mount_h / 2 + 5, psu_mount_len + power_box_depth / 4])
- rotate([90, 0, 0])
- cylinder(d = psu_cable_hole, h = psu_wall + 10);
- }
- }
- }
-
- module psu_holder_assembly() {
- color("yellow")
- translate([-psu_width / 2, psu_wall, -psu_height / 2 + psu_assembly_mount_off_z])
- cube([psu_width, psu_length, psu_height]);
-
- for (i = [0, 1])
- translate([0, i * (psu_length - psu_mount_len + 2 * psu_wall), 0])
- rotate([-90, 0, 0])
- psu_holder(i);
- }
-
- module rail_foot() {
- difference() {
- union() {
- sphere(d = foot_dia);
-
- translate([0, 0, foot_dia / 2])
- sphere(d = foot_nut_base_dia);
- }
-
- translate([-foot_dia / 2 - 1, -foot_dia / 2 - 1, -foot_dia / 2 - 1])
- cube([foot_dia + 2, foot_dia + 2, foot_dia / 2 + 1]);
-
- translate([-foot_nut_base_dia / 2 - 1, -foot_nut_base_dia / 2 - 1, foot_dia / 2])
- cube([foot_nut_base_dia + 2, foot_nut_base_dia + 2, foot_nut_base_dia / 2 + 1]);
-
- translate([0, 0, -1])
- cylinder(d = foot_screw_dia, h = foot_dia / 2 + 2);
-
- translate([0, 0, -1])
- cylinder(d = foot_screw_head_dia, h = foot_screw_head_height + 1);
- }
- }
-
- /************************************
- ************* Assembly *************
- ************************************/
-
- module assembly_y_axis_plate() {
- translate([0, -y_carriage_y / 2 - y_axis_animation_position, 0])
- y_axis();
-
- %translate([-plate_x / 2, -plate_y / 2, 20 + y_carriage_h + y_carriage_rail_dist + carriage_spacer_height])
- plate();
- }
-
- module assembly_x_axis() {
- x_axis();
-
- translate([x_axis_animation_position + y_carriage_y / 2, -y_axis_rail_len / 2, 20 + y_carriage_h + y_carriage_rail_dist])
- translate([10, y_axis_animation_position + y_carriage_y / 2, 20])
- assembly_y_axis_plate();
- }
-
- module assembly() {
- translate([-x_axis_rail_len / 2, 0, 20]) {
- assembly_x_axis();
-
- if (use_double_supports) {
- color("grey")
- for (i = [1, -1])
- scale([1, i, 1])
- translate([left_support_off, -left_support_len - 10, -20])
- rail_2020_y(left_support_len, "left support");
-
- color("grey")
- for (i = [1, -1])
- scale([1, i, 1])
- translate([x_axis_rail_len - 20 - right_support_off, -right_support_len - 10, -20])
- rail_2020_y(right_support_len, "right support");
-
- for (i = [0, 1])
- for (j = [1, -1])
- translate([i * x_axis_rail_len - (i * 2 - 1) * (right_support_off + 10), j * (right_support_len - 10), -40 - 0]) {
- %color("grey")
- cylinder(d = 5.0, h = 25);
-
- %color("green")
- rail_foot();
- }
-
- // TODO psu
- } else {
- color("grey")
- translate([x_axis_rail_len / 2, 0, -40])
- for (i = [1, -1])
- scale([i, 1, 1])
- translate([x_axis_rail_len / 2 - bottom_support_off, -bottom_support_len / 2, 0])
- rail_2020_y(bottom_support_len, "bottom supports");
-
- for (i = [0, 1])
- for (j = [1, -1])
- translate([i * x_axis_rail_len - (i * 2 - 1) * (bottom_support_off - 10), j * (bottom_support_len / 2 - 40), -40 - 20]) {
- %color("grey")
- cylinder(d = 5.0, h = 25);
-
- %color("green")
- rail_foot();
- }
- }
-
- translate([bottom_support_off + psu_mount_w / 2, 10 + psu_assembly_mount_off_y, 10 - 40])
- psu_holder_assembly();
- }
- }
-
- module xy_table() {
- translate([-point_that_reaches_everywhere_x, -point_that_reaches_everywhere_y, -40 + -40 + (y_carriage_rail_dist + y_carriage_h) * -2 + -plate_z - carriage_spacer_height])
- assembly();
- }
-
- /***********************************
- ************ Rendering ************
- ***********************************/
-
- //dispenser();
- //rail_2020_x(100);
- //rail_wheel();
- //rail_foot();
- //psu_holder(0);
- //psu_holder(1);
- //psu_holder_assembly();
-
- //motor_mount(1);
- //motor_mount(2);
- //belt_pulley(teethcount, real_belt_pulley_dia, 1);
-
- //belt_tensioner_mount(2);
- //belt_tensioner_moving();
- //belt_tensioner(1);
- //belt_tensioner(2);
- //belt_pulley(teethcount, real_belt_pulley_dia, 0);
-
- //y_carriage_post();
- //x_carriage_holder();
-
- //translate([0, -50, 0])
- //y_carriage(0);
- //y_carriage(1);
- //y_carriage(2);
- //x_carriage();
- //carriage_spacer();
-
- //y_axis();
- //x_axis();
-
- //assembly();
- xy_table();
|