monorepo/bike-lights/case/battery_enclosure.scad

160 lines
4.9 KiB
OpenSCAD
Raw Normal View History

2024-09-14 00:29:10 +00:00
$fn = 50;
threshold = 0.1;
half_threshold = threshold / 2;
2024-09-14 03:20:43 +00:00
bevel = 0.5;
2024-09-14 00:29:10 +00:00
wire_radius = 1;
wall_thickness = 2;
cutout_threshold = 1;
battery_length = 71;
battery_width = 18.75;
cell_holder_length = battery_length + wall_thickness * 2;
cell_holder_width = battery_width + wall_thickness * 2;
cell_holder_height = battery_width + wall_thickness;
battery_contact_thickness = .6;
// battery_contact_thickness = 1;
battery_contact_width = 11;
battery_contact_length = 12.8;
battery_contact_spring_height = 10.5;
battery_contact_flange_height = 1.9;
converter_width = 11.25;
converter_length = 22.25;
converter_height = 4.25;
2024-09-14 03:20:43 +00:00
module pill(length, bevel) {
hull() {
translate([0, 0, (-length / 2) + bevel]) sphere(r = bevel);
translate([0, 0, (length / 2) - bevel]) sphere(r = bevel);
2024-09-14 00:29:10 +00:00
}
2024-09-14 03:20:43 +00:00
}
2024-09-14 00:29:10 +00:00
2024-09-14 03:20:43 +00:00
module box_face(length, width, wall_thickness, bevel) {
center_width = width - bevel * 2;
center_length = length - bevel * 2;
hull() {
translate([-center_width / 2, -center_length / 2, 0])
pill(wall_thickness, bevel);
translate([center_width / 2, -center_length / 2, 0])
pill(wall_thickness, bevel);
translate([center_width / 2, center_length / 2, 0])
pill(wall_thickness, bevel);
translate([-center_width / 2, center_length / 2, 0])
pill(wall_thickness, bevel);
2024-09-14 00:29:10 +00:00
}
}
2024-09-14 03:20:43 +00:00
module channel(length, width, height) {
2024-09-14 00:29:10 +00:00
union() {
2024-09-14 03:20:43 +00:00
translate([0, 0, -height / 2 + wall_thickness / 2])
box_face(length, width, wall_thickness, bevel);
translate([-width / 2 + wall_thickness / 2, 0, 0]) rotate([0, 90, 0])
box_face(length, height, wall_thickness, bevel);
translate([width / 2 - wall_thickness / 2, 0, 0]) rotate([0, 90, 0])
box_face(length, height, wall_thickness, bevel);
2024-09-14 00:29:10 +00:00
}
2024-09-14 03:20:43 +00:00
}
2024-09-14 00:29:10 +00:00
2024-09-14 03:20:43 +00:00
module box(length, width, height) {
union() {
channel(length, width, height);
translate([0, -length / 2 + wall_thickness / 2, 0]) rotate([90, 0, 0])
box_face(height, width, wall_thickness, bevel);
translate([0, length / 2 - wall_thickness / 2, 0]) rotate([90, 0, 0])
box_face(height, width, wall_thickness, bevel);
2024-09-14 00:29:10 +00:00
}
}
2024-09-14 03:20:43 +00:00
// box(20, 10, 10);
// color("blue", 0.5) cube([10, 20, 10], center = true);
module cell_cradle(width, height) {
difference() {
translate([0, 0, -height / 2]) cube([width,
2024-09-14 00:29:10 +00:00
wall_thickness,
2024-09-14 03:20:43 +00:00
height],
2024-09-14 00:29:10 +00:00
center = true);
2024-09-14 03:20:43 +00:00
color("red", 1) translate([0, 0, 0])
2024-09-14 00:29:10 +00:00
rotate([90, 0, 0])
cylinder(h = wall_thickness + cutout_threshold,
r = width / 2,
center = true);
}
}
module cell_box() {
union() {
2024-09-14 03:20:43 +00:00
channel(cell_holder_length, cell_holder_width, cell_holder_height);
translate([0, -battery_length / 6, wall_thickness]) cell_cradle(cell_holder_width, cell_holder_height / 2);
translate([0, battery_length / 6, wall_thickness]) cell_cradle(cell_holder_width, cell_holder_height / 2);
2024-09-14 00:29:10 +00:00
}
}
2024-09-14 03:20:43 +00:00
module contact_box() {
contact_thickness = battery_contact_flange_height * .75;
cutout_width = battery_contact_width * .8;
// box_thickness = contact_thickness_ + wall_thickness * 2;
// box_height = width + wall_thickness;
2024-09-14 00:29:10 +00:00
2024-09-14 03:20:43 +00:00
difference() {
box(wall_thickness * 2 + contact_thickness, cell_holder_width, cell_holder_height);
translate([0, contact_thickness, wall_thickness * 2])
cube([battery_contact_width,
wall_thickness * 2,
battery_contact_length + threshold],
2024-09-14 00:29:10 +00:00
center = true);
2024-09-14 03:20:43 +00:00
}
2024-09-14 00:29:10 +00:00
2024-09-14 03:20:43 +00:00
/*
union() {
2024-09-14 00:29:10 +00:00
translate([box_width / 2 - (contact_width * .8) / 2,
wall_thickness,
box_height - contact_height])
cube([contact_width * .8,
wall_thickness + contact_thickness_ + cutout_threshold,
contact_height + cutout_threshold]);
translate([width / 2 + wall_thickness,
0,
width + wire_radius * 2])
rotate([-90, 0, 0])
cylinder(h=wall_thickness * 4, r=wire_radius, center = true);
rotate([0, 180, 0])
translate([-cutout_threshold / 2,
box_thickness,
width + wire_radius * 2])
cylinder(h = width + wall_thickness * 2 + cutout_threshold, r = 1, center = true);
}
2024-09-14 03:20:43 +00:00
*/
2024-09-14 00:29:10 +00:00
}
2024-09-14 03:20:43 +00:00
module battery_slot() {
2024-09-14 00:29:10 +00:00
union() {
2024-09-14 03:20:43 +00:00
translate([0, -cell_holder_length / 2, 0]) contact_box();
2024-09-14 00:29:10 +00:00
translate([0, wall_thickness, 0]) cell_box();
2024-09-14 03:20:43 +00:00
translate([0, cell_holder_length / 2 + wall_thickness * 2, 0])
2024-09-14 00:29:10 +00:00
rotate([0, 0, 180])
2024-09-14 03:20:43 +00:00
contact_box();
2024-09-14 00:29:10 +00:00
}
}
module battery_case() {
union() {
2024-09-14 03:20:43 +00:00
translate([-cell_holder_width / 2, 0, 0]) battery_slot();
translate([cell_holder_width / 2 - wall_thickness, 0, 0]) battery_slot();
2024-09-14 00:29:10 +00:00
}
}
battery_case();