Skip to content

Instantly share code, notes, and snippets.

@ednisley
Created April 15, 2017 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ednisley/ab1497b1f1e487e432f45d87613e7a29 to your computer and use it in GitHub Desktop.
Save ednisley/ab1497b1f1e487e432f45d87613e7a29 to your computer and use it in GitHub Desktop.
OpenSCAD source code: Cylindrical cell adapters
// Cylindrical cell adapters
// Ed Nisley KE4ZNU April 2017
//- Extrusion parameters must match reality!
ThreadThick = 0.25;
ThreadWidth = 0.40;
HoleWindage = 0.2;
Protrusion = 0.1; // make holes end cleanly
inch = 25.4;
function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
//----------------------
// Dimensions
OutCell = "AA"; // cell sizes
InCell = "AAA";
BottomClear = 3*ThreadThick; // shorten outer shell to allow base protrusion
Terminal = [3.0,4.0,2.0]; // terminal: OD = nub dia, length = nub thickness
NAME = 0;
ID = 0; // for non-cell cylinders
OD = 1;
LENGTH = 2;
Cells = [
["AAAA",8.3,42.5],
["AAA",10.5,44.5],
["AA",14.5,50.5],
["C",26.2,50],
["D",34.2,61.5],
["A23",10.3,28.5],
["CR123",17.0,34.5],
["18650",18.6,65.2]
];
Outer = search([OutCell],Cells,1,0)[0];
Inner = search([InCell],Cells,1,0)[0];
echo(str("Outer cell: ",Cells[Outer][NAME]));
echo(str("Inner cell: ",Cells[Inner][NAME]));
echo(str("Wall: ",Cells[Outer][OD] - (Cells[Inner][OD]/cos(180/NumSides) + 2*ThreadWidth)));
Delta = Cells[Outer][LENGTH] - Cells[Inner][LENGTH];
echo(str("Terminal OAL: ",Delta));
echo(str(" ... head: ",Terminal[LENGTH]));
echo(str(" ... shaft: ",Delta - Terminal[LENGTH]));
NumSides = 3*4;
//----------------------
// Useful routines
module PolyCyl(Dia,Height,ForceSides=0) { // based on nophead's polyholes
Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
FixDia = Dia / cos(180/Sides);
cylinder(r=(FixDia + HoleWindage)/2,h=Height,$fn=Sides);
}
//----------------------
// Construct adapter
module Adapter() {
difference() {
cylinder(d=Cells[Outer][OD],
h=Cells[Outer][LENGTH] - BottomClear - Terminal[LENGTH],
$fn=NumSides);
translate([0,0,Delta - Terminal[LENGTH]])
PolyCyl(Cells[Inner][OD] + 2*ThreadWidth,
Cells[Inner][LENGTH] + Protrusion,
NumSides);
translate([0,0,-Protrusion])
PolyCyl(Terminal[ID],
2*Cells[Outer][LENGTH],
6);
}
}
//----------------------
// Build it
Adapter();
@ednisley
Copy link
Author

More details on my blog at http://wp.me/poZKh-6GE

@scruss
Copy link

scruss commented Dec 16, 2018

The D cell outer diameter is just a hair heavy for MagLites. They'll go in, but I'll likely never get anything other than AA cells in that particular torch again …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment