mcopy/scad/projector_controller.scad

347 lines
10 KiB
OpenSCAD
Raw Normal View History

include <arduino.scad>;
2023-03-05 05:28:39 +00:00
include <common/common.scad>;
2023-03-05 05:28:39 +00:00
CaseX = 121;
CaseY = 172;
CaseZ = 56;
CaseInnerX = 112;
CaseInnerY = 162;
CaseInnerZ = 52;
CaseMountsX = 91.5;
CaseMountsY = 132;
2023-03-05 05:28:39 +00:00
CaseMountsH = 5;
CaseMountR = 9;
2023-03-05 05:28:39 +00:00
CaseSplitZ = 41;
RelayMountsX = 33.12;
RelayMountsY = 44;
2023-03-05 05:28:39 +00:00
CapacitorSize = [30.5, 37.2, 20];
ResistorSize = [16.25, 49.8, 15.5];
ArduinoPosition = [36, 78, 2];
RelayPosition = [25, -25, 1];
ResistorPosition = [-37, 18, 0];
CapacitorPosition = [-35, -40, 0];
ReinforcementBoltSpacingX = 65;
/**
* DEBUG MODULES
**/
module case_mount_debug (pos = [0, 0, 0]) {
2023-03-05 05:28:39 +00:00
$fn = 30;
translate([pos[0], pos[1], pos[2] - 0.1]) difference () {
2023-03-05 05:28:39 +00:00
cylinder(r = R(7), h = CaseMountsH, center = true);
cylinder(r = R(3.25), h = CaseMountsH + 1, center = true);
}
}
module case_mounts_debug () {
2023-03-05 22:14:01 +00:00
X = CaseMountsX/2;
Y = CaseMountsY/2;
Z = -(CaseInnerZ/2)+(CaseMountsH/2);
case_mount_debug([X, Y, Z]);
case_mount_debug([X, -Y, Z]);
case_mount_debug([-X, Y, Z]);
case_mount_debug([-X, -Y, Z]);
2023-03-05 05:28:39 +00:00
}
module case_debug () {
2023-03-05 05:28:39 +00:00
difference () {
cube([CaseX, CaseY, CaseZ], center = true);
cube([CaseInnerX, CaseInnerY, CaseInnerZ], center = true);
translate([0, 0, CaseSplitZ]) cube([CaseX + 1, CaseY + 1, CaseZ], center = true);
translate([0, 150, 0]) cube([CaseX + 1, CaseY, CaseZ + 1], center = true);
}
case_mounts_debug();
}
module relay_module_post_void (pos = [0, 0, 0], D, Z) {
translate(pos) cylinder(r = R(D), h = Z + 1, center = true);
2023-03-05 05:28:39 +00:00
}
module relay_module_debug (pos = [0, 0, 0], rot = [0, 0, 0]) {
X = 39;
Y = 50;
Z = 1.25;
D = 3;
RelayOffsetX = (15/2) + (1.75/2);
RelayOffsetY = -(Y/2) + (18.6/2) + 12.3;
TerminalOffsetY = -(Y/2) + (8/2) + 3.7;
$fn = 20;
translate(pos) rotate(rot) {
difference () {
rounded_cube([X, Y, Z], d = 5, center = true);
relay_module_post_void([RelayMountsX/2, RelayMountsY/2, 0], D, Z);
relay_module_post_void([RelayMountsX/2, -RelayMountsY/2, 0], D, Z);
relay_module_post_void([-RelayMountsX/2, RelayMountsY/2, 0], D, Z);
relay_module_post_void([-RelayMountsX/2, -RelayMountsY/2, 0], D, Z);
}
//relays
translate([RelayOffsetX, RelayOffsetY, 15/2]) cube([15, 18.6, 15], center = true);
translate([-RelayOffsetX, RelayOffsetY, 15/2]) cube([15, 18.6, 15], center = true);
//terminals
translate([0, TerminalOffsetY, 10.14/2]) cube([30.6, 8, 10.14], center = true);
}
}
2023-03-05 05:28:39 +00:00
module resistor_foot_debug (pos = [0, 0, 0]) {
$fn = 20;
translate(pos) difference () {
cube([6, 8.75, 2], center = true);
cylinder(r = R(3.5), h = 2 + 1, center = true);
}
2023-03-05 05:28:39 +00:00
}
module resistor_debug (pos = [0, 0, 0]) {
X = ResistorSize[0];
Y = ResistorSize[1];
Z = ResistorSize[2];
translate (pos) {
cube([X, Y, Z], center = true);
resistor_foot_debug([-(X/2)-(6/2), (Y/2)-(8.75/2), -(Z/2)+(2/2)]);
resistor_foot_debug([(X/2)+(6/2), -(Y/2)+(8.75/2), -(Z/2)+(2/2)]);
translate([0, (Y/2)+(11.5/2), 0]) rotate([90, 0, 0]) cylinder(r = R(2), h = 11.5, center = true);
translate([0, -(Y/2)-(11.5/2), 0]) rotate([90, 0, 0]) cylinder(r = R(2), h = 11.5, center = true);
}
}
module capacitor_debug (pos = [0, 0, 0]) {
translate(pos) {
cube(CapacitorSize, center = true);
//tab
translate([(CapacitorSize[0]/2) + (14/2) - 5, 0, -(CapacitorSize[2]/2) + (0.85/2)]) difference() {
rounded_cube([14+10, 10, .85], d = 10, center = true, $fn = 30);
translate([4, 0, 0]) cube([6.87, 4.75, 0.85 + 1], center = true);
}
}
2023-03-05 05:28:39 +00:00
}
/**
* CASE MODULES
**/
module m3_bolt (pos = [0, 0, 0], h = 10, pad = 0) {
translate(pos) cylinder(r = R(3.25 + pad), h = h, center = true, $fn = 30);
}
module arduino_bolts_voids (pos = [0, 0, 0], rot = [0, 0, 0], h = 10, pad = 0) {
translate(pos) rotate(rot) {
m3_bolt([-2.5, -15.25, 0], h, pad);
m3_bolt([-50.75, -14, 0], h, pad);
m3_bolt([-45.7, -66.75, 0], h, pad);
m3_bolt([-17.75, -66.75, 0], h, pad);
}
}
module arduino_mount_reinforcement () {
X = 57.25;
Y = 72;
Z = 5;
pos = [-(X/2)+1.5, -(Y/2)+1.5, -2];
translate(pos) difference () {
cube([X, Y, Z], center = true);
cube([X-13, Y-15, Z+1], center = true);
}
}
module case_mount (pos = [0, 0, 0]) {
$fn = 30;
translate(pos) difference () {
cylinder(r = R(CaseMountR), h = CaseMountsH, center = true);
cylinder(r = R(3.5), h = CaseMountsH + 1, center = true);
}
}
module case_mounts (pos = [0, 0, 0]) {
X = CaseMountsX/2;
Y = CaseMountsY/2;
Z = 0;
XBrace = CaseMountsX - (CaseMountR/2);
YBrace = CaseMountsY - (CaseMountR/2);
DiagBrace = sqrt(pow(XBrace, 2) + pow(YBrace, 2));
DiagAngle = 57;
translate(pos) {
case_mount([X, Y, Z]);
case_mount([X, -Y, Z]);
case_mount([-X, Y, Z]);
case_mount([-X, -Y, Z]);
}
//sides
translate([0, Y, 0]) cube([XBrace, 6, 5], center = true);
translate([0, -Y, 0]) cube([XBrace, 6, 5], center = true);
translate([X, 0, 0]) cube([6, YBrace, 5], center = true);
translate([-X, 0, 0]) cube([6, YBrace, 5], center = true);
//diagonal
rotate([0, 0, DiagAngle]) cube([DiagBrace, 6, 5], center = true);
rotate([0, 0, -DiagAngle]) cube([DiagBrace, 6, 5], center = true);
}
module relay_module_post (pos = [0, 0, 0]) {
$fn = 30;
translate(pos) {
cylinder(r = R(5), h = 4, center = true);
translate([0, 0, (4/2) + (2.9/2)]) cylinder(r = R(2.75), h = 3, center = true);
}
}
module relay_mount (pos = [0, 0, 0]) {
$fn = 30;
X = RelayMountsX/2;
Y = RelayMountsY/2;
PostZ = 3;
translate(pos) {
translate([0, 0, -1]) difference () {
rounded_cube([RelayMountsX + 5, RelayMountsY + 5, 5], d = 5, center = true);
rounded_cube([RelayMountsX - 5, RelayMountsY - 5, 5 + 1], d = 4, center = true);
}
relay_module_post([X, Y, PostZ]);
relay_module_post([X, -Y, PostZ]);
relay_module_post([-X, Y, PostZ]);
relay_module_post([-X, -Y, PostZ]);
}
}
module resistor_foot_mount (pos = [0, 0, 0]) {
$fn = 30;
translate(pos) {
cube([6, 8.75, 5], center = true);
translate([0, 0, (5/2) + (2/2)]) cylinder(r = R(6), h = 2, center = true);
translate([0, 0, (5/2) + (5/2)]) cylinder(r = R(3), h = 5, center = true);
}
}
module resistor_mount (pos = [0, 0, 0]) {
X = ResistorSize[0];
Y = ResistorSize[1];
Z = ResistorSize[2];
translate (pos) {
difference () {
cube([X, Y, 5], center = true);
cube([X - 10, Y - 10, 5 + 1], center = true);
}
resistor_foot_mount([-(X/2)-(6/2), (Y/2)-(8.75/2), 0]);
resistor_foot_mount([(X/2)+(6/2), -(Y/2)+(8.75/2), 0]);
}
}
module capacitor_mount (pos = [0, 0, 0]) {
translate(pos) {
difference () {
cube([CapacitorSize[0], CapacitorSize[1], 5], center = true);
cube([CapacitorSize[0] - 10, CapacitorSize[1] - 10, 5 + 1], center = true);
}
translate([(CapacitorSize[0]/2) + (14/2) - 5, 0, 0]){
cube([14+10, 10, 5], center = true);
translate([4, 0, 3]) cube([4.5, 4.5, 5], center = true);
}
}
}
module electronics_attachment_bolt_reinforcement (pos = [0, 0, 0]) {
translate(pos) translate([-28, -4, -2]) {
translate([ReinforcementBoltSpacingX / 2, -4, 0]) {
cylinder(r = R(12), h = 5, center = true, $fn = 30);
}
translate([-ReinforcementBoltSpacingX / 2, -4, 0]) {
cylinder(r = R(12), h = 5, center = true, $fn = 30);
}
}
}
module electronics_attachment_bolt_voids (pos = [0, 0, 0]) {
translate(pos) translate([-28, -4, 0]) {
translate([ReinforcementBoltSpacingX / 2, -4, 0]) {
cylinder(r = R(3.25), h = 20 + 1, center = true, $fn = 30);
translate([0, 0, -4]) m3_nut();
translate([5.1, -3.9, 0]) cylinder(r = R(3.25), h = 20 + 1, center = true, $fn = 30);
}
translate([-ReinforcementBoltSpacingX / 2, -4, 0]) {
cylinder(r = R(3.25), h = 20 + 1, center = true, $fn = 30);
translate([0, 0, -4]) m3_nut();
}
}
}
//BOM: 4, M3 hex cap bolt 8mm,N/A,Attach Arduino Uno
//BOM: 2, M3 hex nut, N/A, Attach electronics attachment
module electronics_mount () {
difference () {
union() {
case_mounts([0, 0, 0]);
translate(ArduinoPosition) {
rotate([0, 0, 180]) scale([1, 1.01, 1]) bumper();
arduino_mount_reinforcement();
}
relay_mount(RelayPosition);
resistor_mount(ResistorPosition);
capacitor_mount(CapacitorPosition);
electronics_attachment_bolt_reinforcement(ArduinoPosition);
}
arduino_bolts_voids(ArduinoPosition);
electronics_attachment_bolt_voids(ArduinoPosition);
}
//translate([35.1, 76.8, 4.5]) rotate([0, 0, 180]) arduino();
}
//BOM: 2, M3 hex cap bolt 12mm, N/A, Attach to electronics mount
module electronics_attachment () {
difference () {
cube([70, 16, 19.75], center = true);
translate([1/2, 0, -15.5]) cube([58, 20 + 1, 20], center = true);
translate([5.5, 0, -11.5]) cube([48, 20 + 1, 20], center = true);
translate([11.75, 0, -4.5]) cube([13, 20 + 1, 20], center = true);
translate([-18, 00, -5]) cube([10, 20 + 1, 20], center = true);
translate([ReinforcementBoltSpacingX / 2, 0, 0]) {
cylinder(r = R(3.25), h = 20 + 1, center = true, $fn = 30);
translate([0, 0, 10]) cylinder(r = R(6.5), h = 20 , center = true, $fn = 30);
}
translate([-ReinforcementBoltSpacingX / 2, 0, -2]) {
cylinder(r = R(3.25), h = 20 + 1, center = true, $fn = 30);
translate([0, 0, 10]) cylinder(r = R(6.5), h = 20 , center = true, $fn = 30);
}
arduino_bolts_voids([28, 6.5, 0], h = 20, pad = 5);
translate([35, 8, 0]) cylinder(r = R(10), h = 19.75 + 1, center = true, $fn = 40);
translate([-37, 0, 8]) rotate([90, 0, 0]) cylinder(r = R(20), h = 19.75 + 1, center = true, $fn = 40);
}
}
2023-04-11 01:04:01 +00:00
module usb_protector () {
H = 3;
difference () {
rounded_cube([IN, IN, H], d = 5, center = true, $fn = 40);
2023-07-19 03:13:20 +00:00
cube([12, 12, H + 1], center = true);
2023-04-11 01:04:01 +00:00
}
}
module debug () {
case_debug();
translate([0, 0, -CaseInnerZ/2+(CaseMountsH)]) electronics_mount();
relay_module_debug([RelayPosition[0], RelayPosition[1], RelayPosition[2]-15]);
resistor_debug([ResistorPosition[0], ResistorPosition[1], ResistorPosition[2] -8]);
capacitor_debug([CapacitorPosition[0], CapacitorPosition[1], CapacitorPosition[2] - 8]);
translate(ArduinoPosition) translate([-27.5, -8, -10]) electronics_attachment();
}
PART="electronics_attachment";
if (PART == "electronics_mount") {
electronics_mount();
} else if (PART == "electronics_attachment") {
electronics_attachment();
} else if (PART == "case_mounts") {
case_mounts();
2023-04-11 01:04:01 +00:00
} else if (PART == "usb_protector") {
usb_protector();
2023-03-05 05:28:39 +00:00
} else {
debug();
}