In this repo I am practicing KICAD. Created an ESP32 DevKit V1 module and a PCB footprint. I designed a circuit around this ESP32 consisting of six lamps, four switches, and two power jacks and added a voltage regulater to Vin to maintain a supply of +5V. (This project was originally made of two switches and 1 power jack and was named homeWork2.)
0
stars
2
forks
source link
Hardware - Enclosure for Homework2/PMD - OpenSCAD Modules use - Transfer of Krake issue #62 #71
I reviewed your enclosure OpenSCAD file from the Nagham's PMD repo and have moved it here. I introduced "modules". I would like you to make these updates. I am attaching the file here so that you will review and understand the changes. I suspect we may have to have a meeting about it.
There are other improvements which we can make together. You are doing an impressive job, but with a little but improvement in your use of the tools you will be more efficient and effective.
Please make these changes in this repo.
The file is included here:
// <EnclosureREVc.scad>
// Copyright (C) 204 Oyindamola Adeniran
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
x=54.9;//x +5PCB Width
y=26.9;//y +4PCB Height
z=0;//z
x1= 57.88;
y1= 30.685;
height_top = 3;
corner_radius=4.5;
corner_radiusb=4.5;
wall_thick =5;
hole_diameter = 3.5; // for screws
post_diameter = 10;
LED_diameter = 6.6; // for LED
lid_thickness = 2;
lid_lip = 2;
lid_tolerance =0.5;
extend = 30; //Show inside Enclosure [20 is closing enclosure number.]
power_surge_diameter =17;
power_surge_location =extend+5;
heightPCB = 113.0620;
widthPCB = 53.370;
heightPCBHole = 103.163;
widthPCBHole = 43.4340;
halfheightPCBHole = heightPCBHole/2;
halfwidthPCBHole = widthPCBHole/2;
//THE TOP
module topPlate() {
color("Yellow")
hull(){
translate ([x,y,z]){
cylinder (r=corner_radius, h=height_top);
}
translate ([-x,y,z]){
cylinder (r=corner_radius, h=height_top);
}
translate ([-x,-y,z]){
cylinder (r=corner_radius, h=height_top);
}
translate ([x,-y,z]){
cylinder (r=corner_radius, h=height_top);
}
}
}
module topPlateHoles() {
//ESP32 HOLE
translate([-15.195,-0.416,0])
cube([32,54,7],center=true);
//Top LED 1
translate([-36.83,21.685,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 2
translate([-36.83,14.3352,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 3
translate([-36.83,6.9854,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 4
translate([-36.83,-0.3644,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 5
translate([-36.83,-7.7142,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 6
translate([26.6618,20.0228,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 7
translate([26.6618,12.6568,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//Top LED 8
translate([51.8498,11.654,0])
cylinder(h=15,d1=LED_diameter,d2 = LED_diameter, center=true);
//PUSH_BUTN 1
translate([9.0333,21.685,0])
cube([9.1967,7.20,15], center=true);
//PUSH_BUTN 2
translate([9.0333,13.435,0])
cube([9.1967,7.20,15], center=true);
//PUSH_BUTN 3
translate([9.0333,5.185,0])
cube([9.1967,7.20,15], center=true);
//PUSH_BUTN 4
translate([9.0333,-3.065,0])
cube([9.1967,7.20,15],center=true);
//TRANSISTOR HOLE
translate([10.76,-13.41,00])
cube([10.5,4.641,15],center=true);
}
module caseShape() {
color("red")
hull(){
translate ([x1,y1,extend]){
cylinder (r=corner_radius, h=25);
}
translate ([-x1,y1,extend]){
cylinder (r=corner_radius, h=25);
}
translate ([-x1,-y1,extend]){
cylinder (r=corner_radius, h=25);
}
translate ([x1,-y1,extend]){
cylinder (r=corner_radius, h=25);
}
}
}
module A() {
difference(){
caseShape();
//INSIDE HOLLOW
color("blue")
hull(){
translate ([55.88,27.658,(extend+11.5)]){
cylinder (r=corner_radiusb, h=26.5, center=true);
}
translate ([-55.88,27.658,(extend+11.5)]){
cylinder (r=corner_radiusb, h=26.5, center=true);
}
translate ([-55.88,-27.658,(extend+11.5)]){
cylinder (r=corner_radiusb, h=26.5, center=true);
}
translate ([55.88,-27.658,(extend+11.5)]){
cylinder (r=corner_radiusb, h=26.5, center=true);
}
}
//Small Hole for Enclosure
translate([-halfheightPCBHole,halfwidthPCBHole,60])
cylinder(h=102,d1=hole_diameter,d2 = hole_diameter, center=true);
//Small Hole 2 for Enclosure
translate([halfheightPCBHole,halfwidthPCBHole,60])
cylinder(h=102,d1=hole_diameter,d2 = hole_diameter, center=true);
//Small Hole 3 for Enclosure
translate([halfheightPCBHole,-halfwidthPCBHole,60])
cylinder(h=102,d1=hole_diameter,d2 = hole_diameter, center=true);
//Hole 4 for Enclosure
translate([-halfheightPCBHole,-halfwidthPCBHole,60])
cylinder(h=102,d1=hole_diameter,d2 = hole_diameter, center=true);
//POWER SURGE
translate([x1,-6.049,(extend+15)])
rotate([0,90,0])
cylinder (h=12,d1=power_surge_diameter,d2=power_surge_diameter,center=true);
//The barrel jack is sticking out at 2.8mm
//ESP32 USB A-HOLE
translate([-18,-35,extend+10])
rotate([0,0,90])
cube([10,20,15],center=true);
}
}
module ScrewCylinders() {
$fn=50;
//THE 4 CYCLINDERS
difference(){
//Screw Cylinder 1
color("DarkGrey")
translate([-halfheightPCBHole,halfwidthPCBHole,13])
cylinder(h=19.5,d1=13,d2 =13, center=true);
//Small Hole 1
translate([-halfheightPCBHole,halfwidthPCBHole,12])
cylinder(h=25,d1=hole_diameter,d2 = hole_diameter, center=true);
}
difference (){
//Screw Cylinder 2
color("DarkGrey")
translate([halfheightPCBHole,halfwidthPCBHole,13])
cylinder(h=19.5,d1=13,d2 =13,center=true);
//Small Hole 2
translate([halfheightPCBHole,halfwidthPCBHole,12])
cylinder(h=25,d1=hole_diameter,d2 = hole_diameter, center=true);
}
difference(){
//Screw Cylinder 3
color("DarkGrey")
translate([halfheightPCBHole,-halfwidthPCBHole,13])
cylinder(h=19.5,d1=13,d2 =13, center=true);
//Small Hole 3
translate([halfheightPCBHole,-halfwidthPCBHole,12])
cylinder(h=25,d1=hole_diameter,d2 = hole_diameter, center=true);
}
difference(){
//Screw Cylinder 4
color("DarkGrey")
translate([-halfheightPCBHole,-halfwidthPCBHole,13])
cylinder(h=19.5,d1=13,d2 =13,center=true);
//Hole 4
translate([-halfheightPCBHole,-halfwidthPCBHole,12])
cylinder(h=25,d1=hole_diameter,d2 = hole_diameter, center=true);
}
// ISSUES
//The distance between the edge of board and LED is 0.4mm but might not be an issue.
//Elevate the PCB board 2mm
}
module top() {
difference(){
topPlate();
topPlateHoles();
}
color("blue")
ScrewCylinders();
}
module case() {
A();
}
top();
case();
Using modules in OpenSCAD provides several benefits that enhance code readability, reusability, and maintainability:
1. Code Reusability
Modules allow you to define a geometric structure or function once and reuse it multiple times throughout the design.
This reduces repetition, making the code more concise and easier to maintain.
2. Improved Readability
Modules break down complex designs into smaller, manageable, and self-explanatory units.
You can name modules descriptively, making it easier to understand the purpose of different parts of the design.
3. Easier Debugging
You can test modules individually to ensure they work correctly before integrating them into a larger design.
This modular approach helps isolate issues in the design.
4. Parameterization
Modules can accept parameters, enabling dynamic designs where dimensions or properties can easily be adjusted by changing inputs.
This flexibility is particularly useful in creating scalable or customizable models.
5. Encapsulation of Logic
By using modules, you can encapsulate design logic within a single module. This reduces the risk of accidental modifications to critical parts of the design.
6. Ease of Updates
When changes are needed, you can update a module once, and all instances of that module will automatically reflect the change.
7. Collaboration and Sharing
Modular designs make it easier to collaborate, as different team members can work on separate modules.
Modules can be shared across projects or with others, saving time and effort.
8. Hierarchy and Complexity Management
Using modules, you can create a hierarchical structure for the design, making it easier to manage complex assemblies.
Update OpenSCAD Enclosure file to use Modules
from https://github.com/PubInv/krake/issues/62 copying @RobertLRead Dear @samoyin,
I reviewed your enclosure OpenSCAD file from the Nagham's PMD repo and have moved it here. I introduced "modules". I would like you to make these updates. I am attaching the file here so that you will review and understand the changes. I suspect we may have to have a meeting about it.
There are other improvements which we can make together. You are doing an impressive job, but with a little but improvement in your use of the tools you will be more efficient and effective.
Please make these changes in this repo.
The file is included here: