//
// file: sampleC_parameters.txt
// Split airflow case with fan mount outside fan
// Replicates hominoid default case except for 20mm fan thickness used here
//
//////////////// PARAMETERS  ///////////////////////////////////////////////////
// All dimensions are millimeter 
// Parameters are grouped by physical component dimensions, case options, design parameters, hardware sizing,
//   followed by non-tailorable parameters and calculated parameters
// In openSCAD, all parameters are constants.  There are no true variables.  
//   UPPERCASE labels are arbitrarily used here to generally identify hardcoded constants.  
//   Lowercase labels are arbitrarily used here to generally identify something calculated.
// ERRATA: Not all parameters are used in the four basic case types, but most cannot be ignored/deleted
//   since they are still used in initial calculations and parameter limit checking.  
//
// **COMPONENT REFERENCE DIMENSION PARAMETERS**
// This section contains dimensions from component measurements or data sheets
//
// XU4 board and heatsink assembly
//   See file Odroid_XU4_Parameters.txt file for other key XU4 dimension parameters that may be used here
//   The following parameters define specifics for THIS utilization of the XU4
//   Any other parameters prefixed with XU4_ used in this file are defined in the Odroid_XU4_Parameters.txt file
// XU4_HS_TYPE: 0=no heatsink, 1=stock without fan, 2=stock with fan, 3=passive blue 40x40x25mm,
//              4=gdstime gold w/gds hardware, 5=gdstime gold w/custom adapters, 6=flat 40mm plate
XU4_HS_TYPE = 5;        // see the above comment
XU4_EMMC_TYPE = 1;      // 0=no emmc module, 1=yes show emmc module present
XU4_USD_TYPE = 1;       // 0=no microSD card, 1=yes show microSD card present
XU4_PERCH_T = 3.18;     // 0=no perch, >0=raise the heatsink up that amount in XU4 model
XU4_HS_ADAPT_TYPE = 1;  // 0=M3 clearance hole, 1=M3 nut trap (applies to gold heatsink adapters) 
//
// Case mounted fan - generic 40mm fan
EXT_FAN_SIZE = 40;      // nominal size 40mm x 40mm (use CASE_FAN_FIT to adjust fit clearance, not this)
EXT_FAN_HID = 4.0;      // fan corner mounting hole inside diameter (use case parameters to set hole size, not this)
EXT_FAN_MHO = 4.0;      // corner mounting hole offsets from fan edges
EXT_FAN_WALL = 1.0;     // amount of frame left at thin sides of fan body
// EXT_FAN_T: include any isolation shims, finger guards used, etc. that would also need to fit in fan cutout, if used  
EXT_FAN_T = 20;         // nominal thickness like 7mm, 10mm or 20mm (use CASE_FAN_FIT to adjust fit clearance, not this)
EXT_FAN_CSCREW_OD = 5;  // Fan Case Screw OD, should case screws be used with outside fan mount (sizes vary; measure YOURS)

// **CASE CONFIGURATION OPTIONS PARAMETERS** //
// Case top-level configuration options
// CASE_FMOUNT_TYPE: Selects the four fundamental case configurations
//   0=no case fan; case height driven by CASE_NOFAN_HEIGHT
//   1=fan mount on case top; case height driven by CASE_NOFAN_HEIGHT
//   2=fan mount outside of fan on case end; case height is derived from EXT_FAN_SIZE
//   3=fan mount inside of fan on case end; case ehight is derived from EXT_FAN_SIZE
CASE_FMOUNT_TYPE = 2;    // see the above comment
CASE_FMOUNT_HOLE_TYPE=0; // fan mount hole: 0=iso pin clearance, 1=case screw clear, 2=M3 screw clear, 3=for threading M3
CASE_FAN_HW_SHOW = 1;    // 0=show no hardware, 1=show iso pins, 2=show Keystone 720 bumper, 3=show printed foot
//CASE_DUCT_TYPE: this parameter is ignored if CASE_FMOUNT_TYPE doesn't involve a fan mount on case end
CASE_DUCT_TYPE = 1;      // 0=no ducting, 1=include ducting on case top and bottom
CASE_WCHAN_TYPE = 1;     // 0=no wire channel, 1=wire channel under USB3.0 side, 2=wire channel under RJ45 side
// CASE_BFOOT_TYPE: still needs to be set to 2 or 3 to force accessory print even if foot will actually be used on fan instead
CASE_BFOOT_TYPE = 0;     // bottom feet: 0=none, 1=Keystone 720, 2=printed accessory (clear hole), 3=printed accessory (nut trap)
CASE_MTAB_TYPE = 0;      // 0=no case mounting tabs, 1=mounting tabs on case bottom
CASE_BSO_TYPE = 1;       // 0=provide no case bottom standoffs, 1=integrated into case, 2=printed accessory only
CASE_EMMC_CUTOUT = 1;    // 0=no cutout, 1=finger access in case bottom
CASE_HS_MOUNT_TYPE = 1;  // 0=no case HS mount (PCB spring clip), 1=thru-case w/stanchion only, 2=thru-case with standoff
//CASE_HS_CUTOUT_TYPE: This parameter is ignored if CASE_FMOUNT_TYPE specifies fan mounted on case top
CASE_HS_CUTOUT_TYPE = 1; // 0=no cutout, 1=provide cutout sized to CASE_HS_CUTOUT_SIZE, 2=grid pattern
//CASE_XU4_THOLE_TYPE, CASE_XU4_BHOLE_TYPE and CASE_HS_HOLE_TYPE:
//  These specify the type of hole and screw head provision for 
//  case top XU4 holes, case bottom XU4 holes, and case bottom heatsink mounting holes respectively
//    0=clear hole w/no head provision
//    1=clear w/flat head countersink
//    2=clear w/full head recess
//    3=clear hole w/nut trap
//    4=thread thru-hole
//    5=thread hole to a specified depth
CASE_XU4_THOLE_TYPE = 0; // see the above comment; if set to 5 parameter CASE_XU4_THOLE_TD sets thread depth
CASE_XU4_BHOLE_TYPE = 0; // see the above comment; if set to 5 parameter CASE_XUF_BHOLE_TD sets thread depth
CASE_HS_HOLE_TYPE = 0;   // see the above comment' if set to 5 parameter CASE_HS_HOLE_TD sets thread depth
CASE_UHOLDER_TYPE = 1;   // 0=no UART holder, 1=UART on RJ45 side, 2=UART on USB3 side, 3=printed accessory only
CASE_BHOLDER_TYPE = 2;   // 0=no RTC battery holder, 1=holder on RJ45 side, 2=holder on USB3 side, 3=printed accessory only
CASE_TSO_TYPE = 1;       // 0=provide no case top standoffs, 1=integrated into case, 2=printed accessory only
CASE_TSO_USER_H = 24;    // 0=no user-installed standoffs involved, >0=assume user will install this height standoff
CASE_TSO_USER_TYPE = 1;  // top side user installed standoffs: 0=user provided, 1=printed accessory
//
// **TAILORABLE DESIGN PARAMETERS**
// These define details associated with the higher level configuration options defined above
// Case sizing
CASE_XU4_INSET = 2;      // amount of inset from case edge to xu4 edge (i.e., case oversize from PCB)
CASE_BH = 8;             // Overall case bottom height, including standoffs. Affects airflow split above/below XU4 PCB
CASE_FAN_ADJ = 1;        // additional spacing to be provided between XU4 and fan, i.e., for boot switch clearance
CASE_NOFAN_HEIGHT = 42;  // case overall height for no fan or fan mounted on case top plate set to clear passive HS on XU4
//
// Parameters common to both case bottom and case top
CASE_FMOUNT_THICK = 4;   // thickness of the case fan mount; 4 works for (most?) iso pins and for threading into 
CASE_FAN_FIT = 0.3;      // fit tolerance to be added around all faces of the fan
CASE_XU4_HFN = 18;       // $fn to be applied to XU4 mounting/case assembly screw holes
//
// Other Case bottom parameters
// CASE_FAN_BRECESS: 0=fan fits within case bottom, +value recesses fan into a cutout, -value raises fan mount up
//CASE_FAN_BRECESS = 0;   // fan body is flush with case bottom plate; no fan cutout necessary for outside mount
CASE_FAN_BRECESS = EXT_FAN_WALL;  // recess fan mount so inside of fan side wall lines up with case bottom plate
CASE_BSO_RISER_HEIGHT = 2; // height of the riser shoulders applied at base of standoffs on case bottom
CASE_BSO_OD = 7.0;       // outer diameter of the case bottom standoffs, if integrated into the case bottom
CASE_BSO_FN = 6;         // $fn value to be applied to printed case bottom standoffs:  6=hex, 24+=round
CASE_XU4_BHOLE_TD = 6;   // case bottom XU4 mounting hole limited depth for threading when specified by CASE_XU4_BHOLE_TYPE
CASE_HS_HFN = 18;        // $fn to be applied to through-case heatsink mounting screws
CASE_HS_STANCHION_H = 3; // height of the support stanchions around heatsink holes, if present
CASE_HS_HOLE_TD = 6;     // case bottom heatsink mounting hole limited depth for threading when specified by CASE_HS_HOLE_TYPE 
CASE_MTAB_HID = 4.4;     // hole ID on case mounting tabs set for about #4 wood screw clearance
CASE_MTAB_WIDTH = 8;     // mounting tab width set to a bit larger than head on #4 wood screw
//
// Other Case top parameters
// CASE_FAN_TRECESS: 0=fan fits within case top, +value recesses fan into a cutout, -value increases XU4/heatsink clearance
//CASE_FAN_TRECESS = 0;      // fan body is flush with case top plate; no fan cutout necessary for outside mount 
CASE_FAN_TRECESS=EXT_FAN_WALL; // recess fan mount so inside of fan side wall lines up with case top plate 
//CASE_FAN_TRECESS = -1;     // example value for increasing case height to provide more passive heatsink clearance
//CASE_FAN_TRECESS = -8;     // example value for increasing case height to provide gold heatsink clearance under top plate
// CASE_HS_CUTOUT_SIZE: More than 44 will cause one of the case top riser shoulders to protrude into cutout
CASE_HS_CUTOUT_SIZE = 44;  // xy size of case top cutout above XU4 heatsink
CASE_TSO_RISER_HEIGHT = 2; // height of the riser shoulders applied at base of standoffs on case top
CASE_TSO_OD = 7.0;         // outer diameter of the case top standoffs, if integrated into the case top
CASE_TSO_FN = 6;           // $fn value to be applied to printed case top standoffs:  6=hex, 24+=round
CASE_XU4_THOLE_TD = 6;     // case top XU4 mounting hole limited depth for threading, when selected by CASE_XU4_THOLE_TYPE
//
// User-installed top standoff parameters, used for showing case in preview and preparing as printed accessory
TSO_USER_OD = CASE_TSO_OD; // outer diameter of the user installed top standoffs set here to match rest of top standoffs
TSO_USER_FN = 6;        // $fn value to be applied to user installed case top standoffs:  6=hex, 24+=round
TSO_USER_HOLE_TYPE = 2; // user standoff: 0=clear thru-hole, 1=thread thru-hole, 2=limited depth hole for threading each end
TSO_USER_HOLE_TD = 6;   // user standoff: thread to this depth each end when specified by TSO_USER_HOLE_TYPE
//
// User-installed heatsink spacer for XU4 
HS_SPACER_TYPE = 1;     // 0=no spacer, 1=print spacer as accessory
HS_SPACER_SIZE = 8;     // width and depth of the spacer 
HS_SPACER_HEIGHT = XU4_PERCH_T+IC_SOC_H;   // height of the spacer set here to SOC chip height and any perch used
HS_SPACER_WT = 1.5;     // wall thickness of the spacer
//
// UART holder parameters (global since they are shared between uart_holder and uart_strap modules)
UHOLDER_POST_HSP=21;    // UART holder mounting post hole spacing, center to center
UHOLDER_POST_OD=6;      // UART holder mounting post outer diameter
//
// User-installed foot, used for showing case in preview and preparing as printed accessory
FOOT_H = 8;             // foot height
FOOT_OD2 = 9;           // foot outside diameter at narrow end of cone forming foot
//    
// **HARDWARE/FASTENER SIZING PARAMETERS**
/*==================================================== 
The following table provides standard hardware dimension reference data
These are a reference point only; adjustment may be necessary due to nozzle size, etc.
Also note that MCAD polyhole does better at actual diameters than circle/cylinder

SIZE         THREAD  CLEAR   NUT AFD  NUT OD   NUT     HEAD     HEAD    WASHER  FLAT    
             HOLE    HOLE    WRENCH   @fn=6    HEIGHT  OD       HEIGHT  HEIGHT  OD      
-----------  ------  ------  -------  -------  ------  ------   ------  ------  ----- 
M2 x 0.4     1.75mm  2.20mm  4.0mm    4.62mm   1.6mm   4.0mm    2.0mm   0.3mm   5.5mm
M2.5 x 0.45  2.20mm  2.75mm  5.0mm    5.77mm   2.0mm   5.0mm    2.5mm   0.3mm   6.0mm
M3 x 0.5     2.70mm  3.30mm  5.5mm    6.35mm   2.4mm   6.0mm    3.0mm   0.5mm   7.0mm 
M4 x 0.7     3.50mm  4.40mm  7.0mm    8.08mm   3.2mm   8.0mm    4.0mm   0.8mm   9.0mm
M5 x 0.8     4.50mm  5.50mm  8.0mm    9.24mm   4.7mm   10.0mm   5.0mm   1.0mm   10.0mm
M6 x 1.0     5.50mm  6.60mm  10.0mm   11.55mm  5.2mm   12.0mm   6.0mm   1.6mm   12.0mm
M8 x 1.25    7.20mm  8.80mm  13.0mm   15.01mm  6.8mm   16.0mm   8.0mm   2.0mm   17.0mm
#2-56        1.85mm  2.44mm  4.76mm   5.50mm   1.59mm  4.60mm   2.18mm  0.91mm  6.35mm
#3-56        2.26mm  2.79mm  4.76mm   5.50mm   1.59mm  5.28mm   2.51mm  0.91mm  7.94mm
#4-40        2.44mm  3.26mm  6.35mm   7.33mm   2.38mm  5.97mm   2.85mm  1.14mm  9.53mm
#6-32        2.95mm  3.80mm  7.94mm   9.17mm   2.78mm  7.37mm   3.51mm  1.14mm  11.11mm
#8-32        3.66mm  4.50mm  8.73mm   10.08mm  3.18mm  8.74mm   4.17mm  1.14mm  12.7mm
#10-24       4.09mm  5.11mm  9.53mm   11.00mm  3.18mm  10.13mm  4.83mm  1.14mm  14.29mm
#10-32       4.31mm  5.11mm  9.53mm   11.00mm  3.18mm  10.13mm  4.83mm  1.14mm  14.29mm
1/4-20       5.56MM  6.76MM  11.11mm  12.83mm  4.76mm  13.03mm  6.35mm  1.80mm  18.65
Notes:       1,2     2,3     4        5        6       7,8      8,9     8,10    8,11
----------------------------------------------------------------------------------------
Note  1: Thread hole is for tap or self thread of machine screw in soft material
Note  2: Hole dimensions are from littlemachineshop.com Tap Drill - 50% Thread column data
Note  3: Clearance hole data is littlemachineshop.com Clearance Drill - Standard Fit column data
Note  4: Nut Across Flat Diameter (AFD) metric data is ISO, inch is boltdepot.com US Nut Size table
Note  5: Nut round OD is the openSCAD circle diameter required to achieve a nut size at $fn=6 
         Nut OD is calculated as = (NUT AFD)/cos(30)
Note  6: Nut height is for standard hex nut; jam nuts are less, lock nuts are more
         Metric data is ISO 4032, SAE data from boltdepot.com US Nut Size tables
Note  7: Head diameter varies with the head style; value shown is max across all except truss head
Note  8: Data from http://www.numberfactory.com/nf_metric.html or http://www.numberfactory.com/nf_inch.html 
Note  9: Head height varies with head style; value shown is max across all styles
Note 10: Standard washer height or thickness
Note 11: Flat washer outer diameter
====================================================*/
// Tailor fastener sizing and fit adjustments here
// MCAD library polyhole will be used for screw thread holes - more accurate small diameter than hole by cylinder method
// Printer variables include PLA vs. ABS, extrusion calibration, inside vs. outside perimeters printed first, etc. 
// Values provided were tested with Simplify3D as slicer, PLA on Prusa i3 type printer
// First define values standardized for your setup based on printing the available test plate
// ERRATA: changes to M3_HID_CLEAR, M3_NUT_AFD_CLEAR, and M3_NUT_RD require replication in model file heatsink_adapter_gold()
M3_HID_THREADED = 2.7 + 0.2;   // Hole inside diameter for M3 threading without tapping (polyhole method used)
M3_HID_CLEAR = 3.3 + 0.3;      // Hole inside diameter for M3 clearance (cylinder method used)
M3_HEAD_OD_CLEAR = 6.0 + 0.2;  // Hole outside diameter for worst case M3 head recess
M3_HEAD_RD = 3.0;              // Recess depth for worst case M3 head
M3_NUT_AFD_CLEAR = 5.5 + 0.3;  // Across-Flats-Diameter to be used for M3 nut traps
M3_NUT_RD = 2.4 + 0.2;         // Recess depth to be used for M3 nut traps
//
// Most holes throughout the case will leverage those parameters directly 
// Apply these standardized values to some holes that might warrant hole-specific user adjustment
BHOLDER_MTAB_HID = M3_HID_THREADED;      // battery holder mounting tab hole inside diameter set to threading M3 (polyhole used)
USTRAP_HID = M3_HID_CLEAR;               // UART strap hole inside diameter set to M3 clearance hole (cylinder used)
UHOLDER_POST_HID = M3_HID_THREADED;      // UART strap mounting post inside diameter set for threading M3 (polyhole used)
UHOLDER_MTAB_HID = M3_HID_THREADED;      // UART holder mounting tab hole inside diameter set to threading M3 (polyhole used)
// Other fastener details
CASE_FMOUNT_ISO_HID_CLEAR = 4.0+0.4;     // Fan mount clearance hole ID for use with iso pins
CASE_FMOUNT_CSCREW_HID_CLEAR = EXT_FAN_CSCREW_OD + 0.4; // Fan mount clearance hole ID for use with fan case screws
// end user-tailorable parameters
