monorepo/bike-lights/case/battery_enclosure.scad

159 lines
5.9 KiB
OpenSCAD
Raw Permalink 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 = 5;
2024-09-14 00:29:10 +00:00
include <./common.scad>;
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 03:46:08 +00:00
color("red", 1) translate([0,
-(wall_thickness + contact_thickness + threshold) / 2,
cell_holder_height / 2])
cube([5, wall_thickness + threshold * 2, cell_holder_height], center = true);
2024-09-14 00:29:10 +00:00
2024-09-14 03:46:08 +00:00
translate([0,
-(wall_thickness + contact_thickness + threshold) / 2 - wire_radius,
0])
rotate([0, 90, 0])
cylinder(h = cell_holder_width, r = wire_radius, center = true);
color("green", 1) translate([-cell_holder_width / 2, 0, cell_holder_height / 2])
rotate([0, 90, 0])
cylinder(h = 5, r = contact_thickness / 2, center = true);
color("green", 1) translate([cell_holder_width / 2, 0, cell_holder_height / 2])
rotate([0, 90, 0])
cylinder(h = 5, r = contact_thickness / 2, center = true);
2024-09-14 00:29:10 +00:00
}
}
2024-09-14 03:20:43 +00:00
module battery_slot() {
2024-09-14 03:46:08 +00:00
difference() {
union() {
translate([0, -cell_holder_length / 2, 0]) contact_box();
translate([0, wall_thickness, 0]) cell_box();
translate([0, cell_holder_length / 2 + wall_thickness * 2, 0])
rotate([0, 0, 180])
contact_box();
}
translate([cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius, center = true);
translate([-cell_holder_width / 2, 1, 0]) rotate([90, 0, 0]) cylinder(h = cell_holder_length + wall_thickness * 4 + battery_contact_flange_height * 2, r = wire_radius, center = true);
}
}
module converter_box() {
box_length = wall_thickness * 2 + converter_height;
box_width = cell_holder_width * 2 - wall_thickness;
difference() {
box(box_length, box_width, cell_holder_height);
translate([cell_holder_width - wire_radius, 0, 0])
rotate([90, 0, 0])
cylinder(h = box_length, r = wire_radius, center = true);
translate([cell_holder_width - wire_radius * 2, 0, 0])
rotate([0, 90, 0])
cylinder(h = wall_thickness + threshold, r = wire_radius, center = true);
translate([-cell_holder_width + wire_radius, 0, 0])
rotate([90, 0, 0])
cylinder(h = box_length, r = wire_radius, center = true);
translate([-cell_holder_width + wire_radius * 2, 0, 0])
rotate([0, 90, 0])
cylinder(h = wall_thickness + threshold, r = wire_radius, center = true);
translate([0, -box_length / 2, 0])
rotate([0, 90, 0])
cylinder(h = cell_holder_width * 2 + wall_thickness, r = wire_radius, center = true);
translate([-cell_holder_width * .75, (-box_length + wall_thickness) / 2, 0])
rotate([90, 0, 0])
cylinder(h = wall_thickness * 2, r = wire_radius, center = true);
translate([cell_holder_width * .75, (-box_length + wall_thickness) / 2, 0])
rotate([90, 0, 0])
cylinder(h = wall_thickness * 2, r = wire_radius, center = true);
color("red", 1) translate([-box_width / 4, -(converter_height + wall_thickness) / 2, cell_holder_height / 2])
cube([5, wall_thickness + threshold * 2, cell_holder_height], center = true);
color("red", 1) translate([box_width / 4, -(converter_height + wall_thickness) / 2, cell_holder_height / 2])
cube([5, wall_thickness + threshold * 2, cell_holder_height], center = true);
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();
translate([-wall_thickness / 2,
cell_holder_length / 2 + wall_thickness * 2 + battery_contact_flange_height + wall_thickness * 2 + wall_thickness / 2,
0])
converter_box();
2024-09-14 00:29:10 +00:00
}
}
2024-09-14 00:29:10 +00:00
battery_case();