Skip to content

Commit

Permalink
Update 3d design with new sensor PCB
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbez1 committed Jan 22, 2024
1 parent 31790bf commit bf70d42
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 598 deletions.
3 changes: 2 additions & 1 deletion 3d/28byj-48.scad
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
28byj48_mount_center_offset = 35/2;
28byj48_mount_bracket_height = 0.8;

28byj48_shaft_collar_radius = 9/2;
28byj48_shaft_collar_radius = 9.4/2;
28byj48_shaft_collar_height = 1.5;

28byj48_shaft_radius = 5/2;
Expand All @@ -37,6 +37,7 @@
// Exports for use in other files:
function 28byj48_mount_bracket_height() = 28byj48_mount_bracket_height;
function 28byj48_shaft_radius() = 28byj48_shaft_radius;
function 28byj48_shaft_collar_radius() = 28byj48_shaft_collar_radius;
function 28byj48_mount_center_offset() = 28byj48_mount_center_offset;
function 28byj48_chassis_radius() = 28byj48_chassis_radius;
function 28byj48_shaft_offset() = 28byj48_shaft_offset;
Expand Down
109 changes: 10 additions & 99 deletions 3d/pcb.scad
Original file line number Diff line number Diff line change
Expand Up @@ -17,148 +17,59 @@ include <m4_dimensions.scad>;
include <sensor_pcb_dimensions.scad>;


module pcb_outline_2d(hole=true) {
module pcb_outline_2d() {
difference() {
translate([-pcb_edge_to_hole_x, -pcb_height + pcb_edge_to_hole_y]) {
square([pcb_length, pcb_height]);
}
if(hole) {
circle(r=m4_hole_diameter/2, $fn=30);
circle(r=pcb_hole_radius, $fn=30);
translate([pcb_hole_to_bolt_hole_x, -pcb_hole_to_bolt_hole_y]) {
circle(r=pcb_bolt_hole_radius, $fn=30);
}
}
}

// 3D PCB module, origin at the center of the mounting hole on the bottom surface of the PCB
module pcb(pcb_to_spool, render_jig=false, jig_thickness=0) {
module pcb(pcb_to_spool) {
color([0, 0.5, 0]) {
linear_extrude(height=pcb_thickness) {
pcb_outline_2d();
}
}

mirror([0, 0, 1]) {
// Connector
color([0, 0, 0]) {
translate([pcb_hole_to_connector_pin_1_x - connector_pin_pitch - pcb_connector_width/2, -pcb_hole_to_connector_pin_1_y - pcb_connector_length, pcb_thickness]) {
translate([pcb_hole_to_connector_pin_2_x - pcb_connector_width/2, -pcb_hole_to_connector_pin_2_y - pcb_connector_length, 0]) {
cube([pcb_connector_width, pcb_connector_length, pcb_connector_height]);
}
}

// Connector pins
color([0.5, 0.5, 0.5]) {
translate([pcb_hole_to_connector_pin_1_x - pcb_connector_pin_width/2, -pcb_hole_to_connector_pin_1_y - pcb_connector_pin_width/2, -pcb_connector_pin_tail_length + pcb_thickness + 2.5/2]) {
translate([pcb_hole_to_connector_pin_2_x - pcb_connector_pin_width/2, -pcb_hole_to_connector_pin_2_y - pcb_connector_pin_width/2, -pcb_connector_pin_tail_length + 2.5/2]) {
cube([pcb_connector_pin_width, pcb_connector_pin_width, pcb_connector_pin_tail_length]);
translate([-connector_pin_pitch, 0, 0]) {
cube([pcb_connector_pin_width, pcb_connector_pin_width, pcb_connector_pin_tail_length]);
}
translate([-connector_pin_pitch * 2, 0, 0]) {
translate([connector_pin_pitch, 0, 0]) {
cube([pcb_connector_pin_width, pcb_connector_pin_width, pcb_connector_pin_tail_length]);
}
}
}

// Sensor pins
color([0.5, 0.5, 0.5]) {
pin_extra_length = 0.1; // pins excess sticking out from the back of the PCB
sensor_z_offset = pcb_to_spool - sensor_spool_distance - hall_effect_thickness/2 - 0.1;
sensor_pin_length = sensor_z_offset + pcb_thickness + pin_extra_length;
assert(sensor_pin_length < hall_effect_pin_length_max, "Warning: design is too thick to fit sensor");

translate([pcb_hole_to_sensor_pin_1_x - pcb_sensor_pin_width/2, pcb_hole_to_sensor_pin_1_y - pcb_sensor_pin_width/2, -sensor_z_offset]) {
cube([pcb_sensor_pin_width, pcb_sensor_pin_width, sensor_pin_length]);
translate([-sensor_pin_pitch, 0, 0]) {
cube([pcb_sensor_pin_width, pcb_sensor_pin_width, sensor_pin_length]);
}
translate([-sensor_pin_pitch * 2, 0, 0]) {
cube([pcb_sensor_pin_width, pcb_sensor_pin_width, sensor_pin_length]);
}
}
}

// Sensor body
color([0, 0, 0]) {
translate([pcb_hole_to_sensor_pin_1_x - sensor_pin_pitch - hall_effect_width/2, pcb_hole_to_sensor_pin_1_y, -pcb_to_spool + sensor_spool_distance]) {
translate([pcb_hole_to_sensor_x - hall_effect_width/2, pcb_hole_to_sensor_y - hall_effect_height/2, pcb_thickness]) {
cube([hall_effect_width, hall_effect_height, hall_effect_thickness]);
}
}

// Jig
if(render_jig) {
color([1, 1, 0])
translate([-pcb_edge_to_hole_x - pcb_jig_align_thickness - pcb_jig_align_clearance, pcb_hole_to_sensor_pin_1_y + pcb_sensor_pin_width/2 + thickness, -pcb_to_sensor(pcb_to_spool) + pcb_jig_depth_clearance])
rotate([90, 0, 0])
sensor_jig(pcb_to_spool, jig_thickness);
}
}

// 2D cutouts needed to mount the PCB module, origin at the center of the mounting hole
module pcb_cutouts(adjustment_range=pcb_adjustment_range) {
hull_slide(delta=adjustment_range) {
// Bolt slot
hull() {
circle(r=m4_hole_diameter/2, $fn=30);
translate([pcb_hole_to_sensor_pin_1_x + sensor_pin_pitch - m4_hole_diameter/2, 0, 0])
circle(r=m4_hole_diameter/2, $fn=30);
}
// Pin header slot
translate([pcb_hole_to_connector_pin_1_x - connector_pin_pitch, -pcb_hole_to_connector_pin_1_y]) {
hull() {
pin_slot_height = pcb_connector_pin_width + pcb_connector_pin_slop;
pin_slot_width = connector_pin_pitch * 4 - pin_slot_height;
translate([pin_slot_width/2, 0, 0])
circle(pin_slot_height/2, $fn=15);
translate([-pin_slot_width/2, 0, 0])
circle(pin_slot_height/2, $fn=15);
}
}
}
}

module hull_slide(delta) {
for (i = [0:$children - 1]) {
hull() {
translate([-delta, 0]) {
children(i);
}
translate([delta, 0]) {
children(i);
}
}
}
}

function pcb_to_sensor(pcb_to_spool) = pcb_to_spool - sensor_spool_distance - hall_effect_thickness; // using sensor rear face
function pcb_hole_to_sensor_x() = pcb_hole_to_sensor_x;
function pcb_hole_to_sensor_y() = pcb_hole_to_sensor_y;
function pcb_thickness() = pcb_thickness;
function sensor_jig_height(pcb_to_spool) = pcb_to_sensor(pcb_to_spool) - pcb_jig_depth_clearance + pcb_jig_align_length + pcb_thickness;
function sensor_jig_width(pcb_to_spool) = pcb_length + (pcb_jig_align_thickness + pcb_jig_align_clearance) * 2;

module sensor_jig(pcb_to_spool, thickness) {
module fillet() {
eps = 0.01;
difference() {
translate([-eps, -eps, 0])
square(pcb_jig_corner_fillet + eps);
translate([pcb_jig_corner_fillet, pcb_jig_corner_fillet, 0])
circle(r=pcb_jig_corner_fillet, $fn=20);
}
}

linear_extrude(thickness) {
difference() {
union() {
square([sensor_jig_width(pcb_to_spool), pcb_to_sensor(pcb_to_spool) - pcb_jig_depth_clearance]); // main body
square([pcb_jig_align_thickness, sensor_jig_height(pcb_to_spool)]); // alignment edge, left
translate([sensor_jig_width(pcb_to_spool) - pcb_jig_align_thickness, 0])
square([pcb_jig_align_thickness, sensor_jig_height(pcb_to_spool)]); // alignment edge, right
}
fillet();
mirror([1, 0, 0])
translate([-sensor_jig_width(pcb_to_spool), 0, 0])
fillet();
}
}
}

// Example usage:
pcb(10);
49 changes: 16 additions & 33 deletions 3d/sensor_pcb_dimensions.scad
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,28 @@

include <m4_dimensions.scad>;

pcb_thickness = 1.6;
sensor_spool_distance = 0.70; // distance from the sensor to the face of the spool
pcb_thickness = 0.8;

// From datasheet:
hall_effect_height = (2.8 + 3.2) / 2;
hall_effect_width = (3.9 + 4.3) / 2;
hall_effect_thickness = (1.40 + 1.60) / 2;
hall_effect_sensor_offset_y = hall_effect_height - 1.25;
hall_effect_pin_length_max = 14.5;
hall_effect_height = 1.7;
hall_effect_width = 3;
hall_effect_thickness = 1.22;

// From sensor.kicad_pcb:
pcb_height = 16.256;
pcb_length = 16.256;
pcb_hole_to_sensor_pin_1_x = 10.16;
pcb_hole_to_sensor_pin_1_y = 1.27;
sensor_pin_pitch = 2.54;
pcb_hole_to_connector_pin_1_x = 8.636;
pcb_hole_to_connector_pin_1_y = 8.636;
pcb_height = 20;
pcb_length = 40;
pcb_hole_to_sensor_x = 17.5 + 5;
pcb_hole_to_sensor_y = 0;
pcb_hole_to_connector_pin_2_x = 28;
pcb_hole_to_connector_pin_2_y = 10;
pcb_hole_to_bolt_hole_x = 17.5; // 28byj48_mount_center_offset
pcb_hole_to_bolt_hole_y = 8; // 28byj48_shaft_offset
connector_pin_pitch = 2.54;
pcb_edge_to_hole_x = 4.572;
pcb_edge_to_hole_y = 4.572;

pcb_adjustment_range = 4;
pcb_hole_radius = m4_hole_diameter/2;

// Jig dimensions
pcb_jig_corner_fillet = 2;
pcb_jig_align_thickness = 2;
pcb_jig_align_length = 0; // past the PCB thickness
pcb_jig_align_clearance = 0.25; // on x, around the PCB
pcb_jig_depth_clearance = 0.1; // on y, from sensor to jig


// Computed dimensions
pcb_hole_to_sensor_x = pcb_hole_to_sensor_pin_1_x - sensor_pin_pitch;
pcb_hole_to_sensor_y = pcb_hole_to_sensor_pin_1_y + hall_effect_sensor_offset_y;
pcb_edge_to_hole_x = 7;
pcb_edge_to_hole_y = 7;

pcb_hole_radius = 9.4/2; // 28byj48_shaft_collar_radius
pcb_bolt_hole_radius = 4.3/2; // M4

// Rough numbers for 3d rendering only (non-critical dimensions)
pcb_connector_height = 3.2;
Expand All @@ -61,5 +46,3 @@ pcb_connector_length = 18;
pcb_connector_pin_width = 0.64;
pcb_connector_pin_slop = 0.4;
pcb_connector_pin_tail_length = 3.05 + 2.5/2;

pcb_sensor_pin_width = 0.43;
48 changes: 18 additions & 30 deletions 3d/splitflap.scad
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ render_message = "Ag";
render_unit_separation = 0;
render_spool = true;
render_pcb = true;
render_sensor_jig = false;
render_bolts = true;
render_motor = true;

Expand Down Expand Up @@ -190,13 +189,14 @@ front_window_height = front_window_lower+front_window_upper;
front_window_width = spool_width_slop + spool_width_clearance;
front_window_right_inset = thickness;
enclosure_horizontal_inset = (enclosure_width - front_window_width)/2 - front_window_right_inset; // center the window in the front face (the inset is measured with respect to the *outside* of the wall, hence the "front_window_right_inset" correction)
enclosure_vertical_margin = 10; // gap between top/bottom of flaps and top/bottom of enclosure
enclosure_vertical_clearance_top = 5; // gap between top of flaps and top of enclosure
enclosure_vertical_clearance_bottom = 1; // gap between bottom of flaps and bottom of enclosure
enclosure_vertical_inset = max(thickness*1.5, m4_nut_width_corners_padded/2); // distance from top of sides to top of the top piece
enclosure_height_upper = exclusion_radius + enclosure_vertical_margin + thickness + enclosure_vertical_inset;
enclosure_height_lower = flap_pitch_radius + flap_height + enclosure_vertical_margin + thickness + enclosure_vertical_inset;
enclosure_height_upper = exclusion_radius + enclosure_vertical_clearance_top + thickness + enclosure_vertical_inset;
enclosure_height_lower = flap_pitch_radius + flap_height + enclosure_vertical_clearance_bottom + thickness + enclosure_vertical_inset;
enclosure_height = enclosure_height_upper + enclosure_height_lower;

enclosure_horizontal_rear_margin = thickness; // minumum distance between the farthest feature and the rear
enclosure_horizontal_rear_margin = 2; // minumum distance between the farthest feature and the rear

enclosure_length = front_forward_offset + 28byj48_mount_center_offset() + m4_hole_diameter/2 + enclosure_horizontal_rear_margin;

Expand All @@ -209,7 +209,7 @@ enclosure_tab_clearance = 0.10;
num_front_tabs = 2;
front_tab_width = (front_window_width) / (num_front_tabs*2 - 1);

enclosure_length_right = front_forward_offset + m4_hole_diameter/2 + 2;
enclosure_length_right = front_forward_offset + m4_hole_diameter/2 + enclosure_horizontal_rear_margin;

side_tab_width = 2.5;
side_tab_bolt_head_clearance = m4_button_head_diameter / 2 + 0.5;
Expand Down Expand Up @@ -312,7 +312,6 @@ echo(front_forward_offset=front_forward_offset);
echo(flap_exclusion_radius=exclusion_radius);
echo(flap_hole_radius=flap_hole_radius);
echo(flap_notch_height=flap_notch_height);
echo(pcb_to_sensor=pcb_to_sensor(pcb_to_spool));


module standard_m4_bolt(nut_distance=-1, bolt_length=10) {
Expand Down Expand Up @@ -597,17 +596,17 @@ module enclosure_front_etch() {

// holes for 28byj-48 motor, centered around motor shaft
module motor_mount() {
translate([-28byj48_mount_center_offset(), -28byj48_shaft_offset()]) {
translate([-28byj48_mount_center_offset(), 28byj48_shaft_offset()]) {
circle(r=motor_mount_hole_radius, $fn=30);
}
translate([28byj48_mount_center_offset(), -28byj48_shaft_offset()]) {
translate([28byj48_mount_center_offset(), 28byj48_shaft_offset()]) {
circle(r=motor_mount_hole_radius, $fn=30);
}

hull() {
x = -28byj48_chassis_radius() - motor_hole_slop/2 + motor_window_radius;
y = [-28byj48_shaft_offset() - motor_backpack_extent - motor_hole_slop/2 + motor_window_radius,
-28byj48_shaft_offset() + 28byj48_chassis_radius() + motor_hole_slop/2 - motor_window_radius];
y = [28byj48_shaft_offset() + motor_backpack_extent + motor_hole_slop/2 - motor_window_radius,
28byj48_shaft_offset() - 28byj48_chassis_radius() - motor_hole_slop/2 + motor_window_radius];

translate([ x, y[0], 0]) circle(r=motor_window_radius, $fn=40);
translate([-x, y[1], 0]) circle(r=motor_window_radius, $fn=40);
Expand Down Expand Up @@ -693,15 +692,6 @@ module enclosure_left() {
}


// PCB mounting holes
translate([enclosure_height_lower - magnet_hole_offset - pcb_hole_to_sensor_y(), enclosure_length - front_forward_offset - pcb_hole_to_sensor_x()]) {
rotate([180, 0, 0]) {
rotate([0, 0, -90]) {
pcb_cutouts();
}
}
}

if (zip_tie_mode == 1) {
// Zip tie holes, sensor (leading to bottom)
translate([enclosure_left_zip_bottom_inset, zip_tie_height/2 + enclosure_left_zip_side_inset, 0])
Expand Down Expand Up @@ -1131,13 +1121,10 @@ module split_flap_3d(front_flap_index, include_connector, include_front_panel=tr

positioned_enclosure();
if (render_pcb) {
translate([enclosure_wall_to_wall_width + eps, -pcb_hole_to_sensor_x(), -magnet_hole_offset - pcb_hole_to_sensor_y()]) {
rotate([0, 90, 0]) {
rotate([0, 0, 90]) {
pcb(pcb_to_spool, render_sensor_jig);
translate([0, 0, -thickness - 2 * eps]) {
standard_m4_bolt(nut_distance=thickness + pcb_thickness() + 4*eps);
}
translate([enclosure_wall_to_wall_width - thickness - 28byj48_mount_bracket_height() - eps, 0, 0]) {
rotate([0, -90, 0]) {
rotate([0, 0, -90]) {
pcb(pcb_to_spool);
}
}
}
Expand Down Expand Up @@ -1229,8 +1216,7 @@ module split_flap_3d(front_flap_index, include_connector, include_front_panel=tr
if (render_motor) {
translate([enclosure_wall_to_wall_width - thickness - 28byj48_mount_bracket_height(), 0, 0]) {

rotate([-90, 0, 0]) {

rotate([90, 0, 0]) {
rotate([0, -90, 0]) {
Stepper28BYJ48();
}
Expand All @@ -1245,7 +1231,9 @@ module split_flap_3d(front_flap_index, include_connector, include_front_panel=tr
translate([0, 0, 28byj48_mount_center_offset()]) {
rotate([0, 90, 0]) {
rotate([0, 0, 90]) {
standard_m4_bolt(nut_distance=thickness+28byj48_mount_bracket_height());
translate([0, 0, -pcb_thickness()]) { // One motor bolt is also used to clamp the sensor PCB
standard_m4_bolt(nut_distance=thickness+28byj48_mount_bracket_height() + pcb_thickness());
}
}
}
}
Expand Down
Loading

0 comments on commit bf70d42

Please sign in to comment.