MakerBot Print is our newest print-prepration software, which supports native CAD files and STL assemblies,
allows you to interact with all your printers via the Cloud, and many other exciting new features.

Download Now


Flexing battery holders with 2- and 3-cell compartments

by enif Jul 25, 2015
Download All Files

Please Login to Comment

I'm printing one for a single 18650 now. Thanks for the files. You should enable "tips" on your account.

Does this version still use the depricated assign module? I'm not enough of an openscad expert to rewrite those 8 lines of code.
I love this battery holder and have used it in several projects, though none I have uploaded.

Oh. I think one would change



Yes, that's it. But you also need to add a semicolon, i.e.

Amazing idea !
Still I configured a 4 series AAA holder and it seems to be too long around 5 cm .

5cm is quite a bit - how did you do it?

I tweaked your design file (attached) to add the ability to alternate the way the cells go for making series battery paicks. Thanks a lot for this!

Just finished printing few battery cases but I have an issue with this design - it is really hard to thread wire trough holes to create metal contacts for batteries.

I just printed one other case and saw one design element that would maybe work better. Enif would you consider adding small columns instead of holes for winding wire for metal contacts. Please check out this video to see how this looks like - https://youtu.be/Shyr_Zp7OTQ

Or is it possible to create just bigger holes as a first fix?

Thanks for your remarks. Speaking for myself, except for the very small AAA type cells, I never had any problems winding the contact wires around the contact cylinders. I usually tin the first 2-3cm of the stripped contact wire so it gets stiff and can be used like a needle. The problem with the small cells is not the winding of the contact wire, but to get the wire between the two halves of the integrated spring. So I then use some sort of "spacer" to spread the spring halves apart to facilitate inserting the wire.

But if you want to make changes to the design, it's easy, as you have the full OpenScad source code. To increase the holes for the contact wires, just search for the comment "lower and upper holes for contacts" and modify the 2 lines below to your liking.

Awesome project! Is there a reason you didn't create 3S 18650 case version? Would it be possible to add, please?

Just stared at your Openscad code for 5 minutes and figured it out. Thanks a lot!

Good you figured it out - it's really not so difficult. :)

The reason I didn't include it is that the holder gets rather long and it needs to be rotated 45 degrees to fit on the usual 20x20cm print beds.

hello. i need 2x CR123A lineal battery holder. thanks

Just comment out the last line(2) in flexbatter.scad and add the line:

Great project! I am new to scad and I am having trouble trying to create an 18650 holder that is 3 long and 1 wide, 3 batteries stacked on top of each other. Any help would be appreciated.

Do you mean with "3 long and 1 wide, 3 batteries stacked on top of each other" that you want to integrate 9 batteries into a single compartment? For stacking batteries vertically you would need to modify the OpenScad source accordingly, but that not be so easy and I doubt if the result would be easy to operate, i.e. inserting and removing the cells.

In that case, why not simply have three 3-cell compartments side by side (m=3,n=3)?

No sorry, just meant 3 batteries stacked on top of each other. I actually figured it out shortly after writing you. Thanks again for a great file!

Awesome project. I wanted to print the flexbatter1x18650x4.stl but the file have missing parts. Is just me or the file is incomplete?

The STL files were all produced with OpenScad. They work fine with Skeinforge/SFACT which I use and they open well in Meshlab. But I had some people complaining about similar problems with other slicers (see the comment section of the original project), they needed to pass the STL file through some STL repair program like netfabb for their slicer to work correctly.

hey there just wondering what the best way to go about getting the CR123A's in multiple like this having two of them long ways like this would be great for some of my 5v - 6v projects that would drastically decrease the size of the batt compartment. Thanks so much for these BTW they work great so far :D

Essentially, it's just the parameter m which controlls the number of cells in one compartment, so if you use the same parameters to call flexbatter() as are in flexbatterCR123A(), but with m=2, you should get a battery holder for 2 CR123A in a row. You might then also add parameters such as "deepen=0.70,df=0.25,oh=0.4" to add grip deepenigs and overhang to keep cells from lifting in the middle.

thank you I haven't had a chance to print it out yet but I got to learn a new thing I had no idea about. never used scad before but was surprisingly easy to fallow what you said to generate the new STL from your work, very nice :D. I'll edit this to update on how the print worked out with the parameters you suggested thank you!

Edit: So i ended up having to adjust the length as there was too much slop between the batteries, to 34.1 instead of 35.1, I don't know if that's just my particular battery or not but other than that they fit nice and snug now!

I'm having trouble with the 1xAAxN modules. It looks like there should be a channel inside on both the - and + Y faces. On the 0th battery holder the channel is present on both the - and + Y faces. On the 1st-Nth battery compartment, the channel is missing.

I've been pouring over the code, but I can't find the problem. Can you see if you can figure out what's up? I've put an STL and PNG up on git hub that reflect the problem. Here's a link to the image: https://github.com/txoof/flexbatt/blob/71c29500051121df5528790aed6f7e4181fe0ac0/1xAAx3_problem.png

I'd like to use this as a library so I'm working on making a meta-module that makes calling the different battery sizes a bit easier. You can check that out by calling:

battery(type = AA, n = 1 m =3); 

GitHub Repo: https://github.com/txoof/flexbatt

To txoof and enif - This is a great project and I would really like to use it in OpenJSCAD (using txoof's changes). Any objections to me porting this and posting to to https://www.thingiverse.com/thing:2307544 ?

Port of OpenSCAD modules to OpenJSCAD

My projects are all under CC-BY-SA license (attribution share-alike), but your project is only CC-BY which has only "attribution" and not "share-alike", so unfortunately this is not conform to the license I use.

Enif: Thanks for pointing out the license incompatibility; I've updated my derivative to be +SA now.

By the way, do you know if it's possible to set the default license that Thingiverse applies? I feel like I set this ages ago somewhere, but I can't find it now. I'd like to update all of my future projects to be +SA.

Faithhack; if you update your project to be CCBYSA, I have no problems whatever. Everything I post is meant to be shared and remixed.

Yes, thanks for pointing that out. I changed the license on the project to the most restrictive, then added some language to the project description to clarify license issues. The projects I am porting have a mix of license requirements, so I have to pick something for the Thingiverse project itself, then inform people that the individual libraries may have different licenses depending on their original creators' desires. See it what I have now matches your desire for your respective works.

On another note, I'm a little stuck with the use of SCAD's 3d hull() hull function for chamfering the box and creating the contact bumps. Unfortunately, JSCAD doesn't have a 3d hull function (yet - there is a pull request in the works). So my final results may not be 100% faithful to your project. I can "fake" it but would like to wait until (or if) the quickhull code lands in openJSCAD's scad-api.

OpenJSCAD has improved quite a bit since the last time I took a look. I'll have to poke around some more.

Does it support OOP-like methods? That would almost be reason enough for me to move completely over.

You can do OOP, but there is also an scad-api that, for the most part, clones OpenSCAD functions to make the transition easier. Most of the ports I am doing are following SCAD's procedural style, just because it is faster to get usable code, but there is OO code out there as examples.
I am primarily using Atom and atom-jscad for my development, but you can use the web interface or the command-line compiler.

Hi Aaron!

You are right, there is indeed a little glitch in the code related to the "eps" extra diameter we talked about yesterday. The problem is the superposition of the walls of adjacent cells, which "hide" the corresponding groove of the previous cell. One could solve it by adding eps to the displacement of the cells in the m-for loop. But I think that it is cleaner to substract second cylinder from the outside wall for all cells but the last one, by adding the line
just after the line carving out the main cylinder (the one with "r=d/2+eps").

That works great! Thanks for the solution! I think it probably adds some overhead to to the generation as it's doing the same subtraction several times.

I've learned a ton from reading your code; I never knew you could use the transform functions in combination with for loops the way you do. It opens up all sorts of interesting possibilities. I do find it a bit cryptic to unwind though. I'll have to spend a lot more time fiddling to figure out exactly what's going on.

I was trying to figure out if there was an easy way to flip/flop every other module so the batteries in larger packs were arranged as such:

I rather like this configuration as it follows the industry norm for this type of battery box.

This is trivial to do with the following line, but needs some further translation and I can't quite work that out. I used -25.3 by trial and error for AA cells. This obviously won't work for other sizes.
for(i=[0:n-1])translate([-25.3*pow(-1,i),i*(d+2*w-ws),0])rotate([0, 0, 180*i])

Can you help me figure out what parameters I should use to calculate this out properly?

Images and sample code at github

I implemented the eps solution you suggested, cleaned up the deprecated assign() calls and wrote a meta-module that makes it a bit easier to use your design as a library.

Battery holders of any configuration can be made by calling battery(type = <AAA, AA, C, D, CR123A, Li18650, Li18650P>, n = <integer for number in a row>, m = <integer for number in a column>);

I also chucked together a version that can be used with the customizer: http://www.thingiverse.com/thing:1460370

If you're interested in collaborating, I'd like to do some more stuff with your great model. PM me if you're into it.

The latest greatest version can be found over at git hub: https://github.com/txoof/flexbatt

Flexing Battery Holders - Customizable
by txoof

Sorry, I have to run off - will be back tomorrow. Since you are interested in my OpenScad source code, you might also want to have a look at my Treble Clef and my Magnetic letters "things", which are (in that order) continuing developments of my "snakeline" approach, which I first used in flexbatter()...

Thanks. I am interested in this. I'm about to run off too.

Hi all,

I have some trouble in re-creating the battery holder: the spring in the positive pole (+) is not present.
I uncommented the line for the 18650 battery and, after compilation, the rendered figure is without positive pole spring.
What is wrong in my config?


Actually, the spring is meant to be at the negative pole. But that's probably not the problem you are referring to. In the comments of the original single cell compartment version ( http://www.thingiverse.com/thing:456900 ) there was some mention that some slicer omitted the spring and they linked to the discussion at: https://forum.lulzbot.com/viewtopic.php?f=8&t=2695
May be this is the problem you refer to?

Flexing battery holders with integrated spring
by enif

Yes, it seems the same problem.
How can I solve it? What is wrong in the scad file?

Nothing wrong in the scad file, but it seems that the STL generated by OpenScad is not well digested by all slicers. I use Skeinforge and never had any problems. But from what I read, you can use netfabb to read and rewrite the STL file, so that it should then work with all slicers.

hey, thought id let ya know that i nicked ya design n used it on another project lol hope ya dont mind http://www.thingiverse.com/thing:979789

Adafruit BTTF Time Circuit Case
by stefi01

i put a link directly to yours on mine yesturday and also added to comments about your box and thanks :)

Hi Stefanie! Of course, I don't mind you using my battery holder in your design. However, you should play fair and also link to it in the "Sources" section of your thing, so that my battery holders will appear in your "Remixed from" section. Thank you!