// Body of encoder encoder_dia1 = 38.5; encoder_height1 = 35.5; // Narrow part of encoder encoder_dia2 = 20.5; encoder_height2 = 4.7; // Encoder shaft - round part near base shaft_round_dia = 6.4; shaft_round_length = 2; // Encoder shaft - D shaped part shaft_d_dia = 5.8; shaft_d_length = 10; // Gap on all sides of wheel wheel_margin = 1; // Washer to reduce friction with base wheel_washer_thickness = 2; wheel_washer_dia = shaft_round_dia + 1; // Main part of wheel wheel_main_thickness = shaft_d_length; wheel_outer_dia = encoder_dia1 - wheel_margin; wheel_inner_dia = wheel_outer_dia - wheel_main_thickness; // Minimum thickness of walls of base wall_thickness = 2.4; encoder_housing_size_z_pct = 0.5; wheel_housing_size_z_pct = 0.5; filament_hole_dia = 4; // Negative offset increases friction with wheel filament_y_offset = -0.5; $fn = 180; object = "base+wheel"; module d_shaft(length, dia_rnd, dia_d) { difference() { color([1, 0, 0]) cylinder(h = length, d = dia_rnd); translate([0, dia_rnd - (dia_rnd - dia_d), length / 2]) cube([dia_rnd, dia_rnd, length + 1], center = true); } } module encoder() { rotate([0, 90, 0]) { translate([0, 0, -0.05]) d_shaft(shaft_d_length + 0.05, shaft_round_dia, shaft_d_dia); translate([0, 0, -shaft_round_length]) { color([0, 0.5, 1]) translate([0, 0, -0.05]) cylinder(h = shaft_round_length + 0.05, d = shaft_round_dia); translate([0, 0, -encoder_height2]) { color([0, 1, 1]) translate([0, 0, -0.05]) cylinder(h = encoder_height2 + 0.05, d = encoder_dia2); color([0, 1, 0]) translate([0, 0, -encoder_height1]) cylinder(h = encoder_height1, d = encoder_dia1); } } } } module base() { // This part holds the encoder encoder_housing_size_x = encoder_height1 + 2 * wall_thickness; encoder_housing_size_y = encoder_dia1 + wall_thickness * 2; encoder_housing_size_z = encoder_dia1 * encoder_housing_size_z_pct + wall_thickness; encoder_housing_pos_x = - (shaft_round_length + encoder_height2 - wall_thickness); floor_z = -encoder_dia1 / 2 - wall_thickness; difference() { translate([-encoder_housing_size_x + encoder_housing_pos_x, -encoder_housing_size_y / 2, floor_z]) cube([encoder_housing_size_x, encoder_housing_size_y, encoder_housing_size_z]); encoder(); } // Wheel housing wheel_housing_size_x = wheel_washer_thickness + wheel_main_thickness + wheel_margin + wall_thickness - encoder_housing_pos_x; wheel_housing_size_y = encoder_housing_size_y; wheel_housing_size_z = wall_thickness + encoder_dia1 * wheel_housing_size_z_pct; difference() { translate([wheel_housing_size_x / 2 + encoder_housing_pos_x, 0, floor_z + wheel_housing_size_z / 2]) cube([wheel_housing_size_x, wheel_housing_size_y, wheel_housing_size_z], center = true); // Hollow out wheel translate([wheel_housing_size_x / 2 + encoder_housing_pos_x - wall_thickness, 0, 0]) rotate([0, 90, 0]) cylinder(h = wheel_housing_size_x, d = wheel_outer_dia + wheel_margin, center = true); // Filament slot hull() { for (y_mul = [-1, 1]) { translate([wheel_main_thickness / 2, y_mul * (wheel_inner_dia / 2 + filament_y_offset), floor_z + wheel_housing_size_z / 2]) cylinder(h = wheel_housing_size_z + 1, d = filament_hole_dia, center = true); } } } } module wheel() { difference() { rotate([0, 90, 0]) union() { // First half of main part color([0.5, 0.5, 1]) cylinder(h = wheel_main_thickness / 2, d1 = wheel_outer_dia, d2 = wheel_inner_dia); // Second half of main part color([0.5, 0.5, 1]) translate([0, 0, wheel_main_thickness / 2]) cylinder(h = wheel_main_thickness / 2, d2 = wheel_outer_dia, d1 = wheel_inner_dia); color([0, 1, 1]) translate([0, 0, wheel_main_thickness]) difference() { cylinder(h = wheel_washer_thickness, d = wheel_washer_dia); cylinder(h = wheel_washer_thickness, d = shaft_round_dia); } } // Shaft translate([-0.5, 0, 0]) rotate([0, 90, 0]) d_shaft(wheel_main_thickness + wheel_washer_thickness + 1, shaft_round_dia, shaft_d_dia); // Holes in wheel for (angle = [0, 60, 120, 180, 240, 300]) { rotate([angle, 0, 0]) translate([-0.5, 0, wheel_inner_dia / 3.3]) rotate([0, 90, 0]) cylinder(h = wheel_main_thickness + 1, d = wheel_inner_dia / 4); } } } if (object == "base") { base(); } if (object == "base+wheel") { base(); wheel(); } if (object == "base+wheel+encoder") { base(); wheel(); encoder(); } if (object == "wheel") { rotate([0, -90, 0]) wheel(); }