Calculate dimensions from PCB and margins

Add parameters for PCB size and margins on all sides.
Generate the box dimensions from these sizes.
Place the PCB appropriately based on the margins.

This has a change in definition, as the previous PCB size was the size
of the square made by the mounting holes. Now it is the size of the
actual PCB.

Holes are still mounted 5mm inside the edges. Hole positioning will come
soon.
This commit is contained in:
Joel Ebel 2018-05-07 01:31:15 -04:00
parent f5c3339696
commit e429ccf09a

View File

@ -26,18 +26,10 @@
////////// - Paramètres de la boite - Box parameters - /////////////
/* [Box dimensions] */
// - Longueur - Length
Length = 160;
// - Largeur - Width
Width = 170;
// - Hauteur - Height
Height = 100;
// - Epaisseur - Wall thickness
Thick = 2; //[2:5]
/* [Box options] */
// - Epaisseur - Wall thickness
Thick = 2; //[2:5]
// - Diamètre Coin arrondi - Filet diameter
Filet = 2; //[0.1:12]
// - lissage de l'arrondi - Filet smoothness
@ -51,17 +43,26 @@ Vent = 1; // [0:No, 1:Yes]
// - Decoration-Holes width (in mm)
Vent_width = 1.5;
/* [PCB options] */
// - Longueur PCB - PCB Length
PCBLength = 80;
// - Largeur PCB - PCB Width
PCBWidth = 60;
// You likely need to maintain |Thick| margin on the left and right for tabs
// and whatnot.
// - Margin between front panel and PCB
FrontEdgeMargin = 60;
// - Margin between back panel and PCB
BackEdgeMargin = 10;
// - Margin between left wall and PCB
LeftEdgeMargin = 11;
// - Margin between right wall and PCB
RightEdgeMargin = 95;
// - Margin between top of PCB foot and box top.
TopMargin = 86;
/* [PCB_Feet] */
//All dimensions are from the center foot axis
// - Coin bas gauche - Low left corner X position
PCBPosX = 7;
// - Coin bas gauche - Low left corner Y position
PCBPosY = 6;
// - Longueur PCB - PCB Length
PCBLength = 70;
// - Largeur PCB - PCB Width
PCBWidth = 50;
// - Heuteur pied - Feet height
FootHeight = 10;
// - Diamètre pied - Foot diameter
@ -94,6 +95,12 @@ Dec_Thick = Vent ? Thick*2 : Thick;
Dec_size = Vent ? Thick*2 : 0.8;
// Calculate box dimensions from PCB.
Length = PCBLength + FrontEdgeMargin + BackEdgeMargin + ((Thick*2 + m)*2);
Width = PCBWidth + LeftEdgeMargin + RightEdgeMargin + Thick*2;
Height = FootHeight + TopMargin + Thick*2;
echo("Box: ", Length=Length, Width=Width, Height=Height);
// Calculate panel dimensions from box dimensions.
PanelWidth = Width - (Thick*2) - m;
PanelHeight = Height - (Thick*2) - m;
@ -274,9 +281,10 @@ module foot(FootDia, FootHole, FootHeight) {
No arguments are used, but parameters provide the PCB and foot dimensions.
*/
module Feet() {
//////////////////// - PCB only visible in the preview mode - /////////////////////
translate([(3*Thick + 2), Thick + 5, (FootHeight + Thick/2 - 0.5)]) {
%square([PCBLength + 10, PCBWidth + 10]);
translate([BackEdgeMargin + Thick*2 + m, LeftEdgeMargin + Thick, 0]) {
//////////////////// - PCB only visible in the preview mode - /////////////////////
translate([0, 0, (FootHeight + Thick/2 - 0.5)]) {
%square([PCBLength, PCBWidth]);
translate([PCBLength/2, PCBWidth/2, 0.5]) {
color("Olive") {
%text("PCB", halign="center", valign="center", font="Arial black");
@ -284,20 +292,20 @@ module Feet() {
}
} // Fin PCB
////////////////////////////// - 4 Feet - //////////////////////////////////////////
translate([3*Thick + 7, Thick + 10, Thick/2]) {
////////////////////////////// - 4 Feet - //////////////////////////////////////////
translate([5, 5, Thick/2]) {
foot(FootDia, FootHole, FootHeight);
}
translate([(3*Thick + PCBLength + 7), Thick + 10, Thick/2]) {
translate([(PCBLength - 5), 5, Thick/2]) {
foot(FootDia, FootHole, FootHeight);
}
translate([3*Thick + PCBLength + 7, Thick + PCBWidth + 10, Thick/2]) {
translate([PCBLength - 5, PCBWidth - 5, Thick/2]) {
foot(FootDia, FootHole, FootHeight);
}
translate([3*Thick + 7, Thick + PCBWidth + 10, Thick/2]) {
translate([5, PCBWidth - 5, Thick/2]) {
foot(FootDia, FootHole, FootHeight);
}
} // End main translate
} // Fin du module Feet
@ -533,10 +541,7 @@ if (BShell == 1) {
// Pied support PCB - PCB feet
if (PCBFeet == 1) {
// Feet
translate([PCBPosX, PCBPosY, 0]) {
Feet();
}
}
// Panneau avant - Front panel