Design cases for the bike lighting project #250

Merged
savanni merged 7 commits from bike-lights__case into main 2024-09-27 02:18:10 +00:00
1 changed files with 229 additions and 0 deletions
Showing only changes of commit d794b4872f - Show all commits

View File

@ -0,0 +1,229 @@
$fn = 50;
threshold = 0.1;
half_threshold = threshold / 2;
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;
module box(length, width, height, wall_thickness) {
center_width = width - wall_thickness;
center_height = height - wall_thickness;
center_length = length - wall_thickness;
union() {
hull() {
translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness);
}
hull() {
translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness);
}
hull() {
translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness);
}
hull() {
translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness);
}
hull() {
translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
}
}
/*
difference() {
cube([width,
length,
height],
center = true);
translate([0, 0, wall_thickness])
cube([width - wall_thickness * 2,
length - wall_thickness * 2,
height + threshold],
center = true);
}
*/
}
module channel(length, width, height, wall_thickness) {
center_width = width - wall_thickness;
center_height = height - wall_thickness;
center_length = length - wall_thickness;
union() {
hull() {
translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness);
}
hull() {
translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, -center_length / 2, center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, center_height / 2]) sphere(r = wall_thickness);
}
hull() {
translate([-center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([-center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, -center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
translate([center_width / 2, center_length / 2, -center_height / 2]) sphere(r = wall_thickness);
}
}
/*
difference() {
cube([width,
length,
height],
center = true);
translate([0, 0, wall_thickness])
cube([width - wall_thickness * 2,
length + threshold,
height + threshold],
center = true);
}
*/
}
module cell_cradle(length, width) {
translate([0, 0, -width / 4]) difference() {
cube([width + wall_thickness * 2,
wall_thickness,
width / 2],
center = true);
translate([0, 0, width / 2])
rotate([90, 0, 0])
cylinder(h = wall_thickness + cutout_threshold,
r = width / 2,
center = true);
}
}
module cell_box() {
union() {
channel(cell_holder_length, cell_holder_width, cell_holder_height, wall_thickness);
translate([0, -battery_length / 6, 0]) cell_cradle(cell_holder_length, battery_width);
translate([0, battery_length / 6, 0]) cell_cradle(cell_holder_length, battery_width);
}
}
module contact_box(width, contact_width, contact_height, contact_thickness) {
contact_thickness_ = contact_thickness * .75;
cutout_width = contact_width * .8;
box_width = width + wall_thickness * 2;
box_thickness = contact_thickness_ + wall_thickness * 2;
box_height = width + wall_thickness;
union() {
color("red", 1) cube([box_width,
box_thickness,
width + wall_thickness],
center = true);
translate([0,
0,
wall_thickness * 2])
cube([contact_width,
contact_thickness_,
contact_height + cutout_threshold],
center = true);
/*
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);
*/
}
}
module battery_slot(length, width) {
union() {
translate([width + wall_thickness * 2, wall_thickness, 0])
contact_box(battery_width,
battery_contact_width,
battery_contact_length,
battery_contact_flange_height);
translate([0, wall_thickness, 0]) cell_box();
translate([0, wall_thickness + length, 0])
rotate([0, 0, 180])
contact_box(battery_width,
battery_contact_width,
battery_contact_length,
battery_contact_flange_height);
}
}
module battery_case() {
union() {
battery_slot(battery_length, battery_width);
translate([battery_width + wall_thickness, 0, 0]) battery_slot(battery_length, battery_width);
}
}
battery_case();
translate([-50, 0, 0])
contact_box(battery_width,
battery_contact_width,
battery_contact_length,
battery_contact_flange_height);
/*
rotate([0, 90, 0])
translate([0, 5, 0])
cylinder(h=battery_width + wall_thickness * 2 + cutout_threshold, r=1, center = true);
translate([0, -5, 0])
rotate([0, 90, 0])
cylinder(h=battery_width + wall_thickness * 2 + cutout_threshold, r=1, center = true);
*/