Flexing battery holders with integrated spring

by enif, published

Flexing battery holders with integrated spring by enif Sep 9, 2014

Featured Thing!

71 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps


Use This Project

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

165132Views 43120Downloads Found in Electronics


For my electronic projects I often need battery holders of various size and for different number of cells: single, multiple cells in parallel or in series, or serial lithium-ion type cells with connectors for balanced charging between the cells.

So the project here was to generate fully parametrized, printable battery holders for cylindrical cells of arbitrary size and number. The additional challenge for me was to have the battery sit firmly in the holder without the use of the metallic spring that is usually found at the minus pole. In this design the metallic spring is replaced by a flexible printed curled structure, which presses the contacts firmly to the battery. This plastic spring flexes about 1 - 2mm, which is just what's needed to comfortably insert and remove the cells.

The contacts for the plus and minus pole can easily be made by a few windings of the uninsulated ends of the connecting wires. Each battery compartment contains are several holes to the outside as well ad to the neighboring compartments, through which connecting wires can be passed for easy configuring of parallel, serial or balanced-serial battery packs. Also, on the bottom of the case, there are longitudinal and traversal wire channels, which can be used for assing wires outside the case.

Given that the printed plastic spring needs to be flexible, ABS is the material of choice here. Also, I use a some "ABS slur" (mixture of ABS and acetone) to cover and insulate the otherwise exposed outer part of the pole connectors.
In addition to the SCAD source file, I have added STL files for 1/2/3/4 cells of type AA, AAA, 18650(Li-Ion), as well as single cell versions for 18650P (protected Li-Ion), CR123A (aka 16340) and C (this one is untested yet, as I don't have any C-cell around here).

Of course, you can also just use these battery holders without any wiring to serve as battery cases, for carrying your spare batteries around. But for this, you should also have a look at my battery caps...

Update 2014-09-17: Upon request of user wohenzhuce I have also added STL files for 26650 type LiFePo Cells. These are still untested. They were produced in OpenScad with the call:

Update 2015-04-10: Upon request of user h4wk3y I have now uploaded extra long versions (70mm) needed for some protected 18650 cells, these are named flexbatter18700xN.stl._

Update 2015-07-25: I just published a new version of this project which supports multi-cell compartments housing 2 or 3 cells in a row.


I printed these battery holders on my DIY box-frame Prusa i3 using a 0.40mm nozzle with 0.25mm layer height and 0.56mm extrusion width.

By default, the thickness of the spring part is twice the extrusion width ew. If you have a significantly different extrusion width, for obtaining optimal spring strength, you might want to modify the eh and ew parameters in the SCAD file to fit your printer, and then rebuild all the STLs you need.

More from Electronics

view more

File Name



All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

would it be possible for you to make one for 5 AA batteries please?

It's already there: flexbatterAAx5.stl

loll Yes indeed t is ,I don't know how, I didn't see it the first time around lol , Maybe I should be printing reading glasses instead! hahaha.

What kind of metallic contacts do you use?.
I have a Problem to get a nice contact to the 18650

As explained in the description, I use directly the wire end by stripping from it about 10cm of the isolation and the winding the wire around the pole cylinders. For the small cells it's a bit tricky to get in the wire from the outside between the two halfs of the plastic string, but with some practice I got the hang of it. Also, once the wire is wound around the pole, I give it a quick dip with the soldering iron, to make the windings stick together so that they won't become loose.

Jan 13, 2017 - Modified Jan 13, 2017

I wish I had a 3D printer. I don't get why the negative looks so weird for no reason...

Great design! I printed in Hatchbox pla and it came out perfect. Is it possible that you could design one for dual extrusion using conducive filament?

Jan 3, 2017 - Modified Jan 3, 2017

Great design! I printed in Hatchbox pla and it came out perfect. Is it possible that you could design one for dual extrusion using conductive filament?

Jan 3, 2017 - Modified Jan 3, 2017

Great design! I printed in Hatchbox pla and it came out perfect. Is it possible that you could design one for dual extrusion using conducive filament?

I have no experience with dual extrusion and neither with conductive filament. But since you have the full OpenScad source, feel free to modify it and then post it as remix. (Personally I am afraid that the resistance of conductive filament isn't low enough for most practical applications.)

Your plastic springs are brilliant.

Thank you! :-)

Print it? Well, maybe once to see how it fits. I'm going to include it in other openscad designs. Thanks!

Print it? Well, maybe once to see how it fits. I'm going to include it in other openscad designs. Thanks!

Comments deleted.


Thanks, great design!
I need these for a project that's meant to last a bit longer. Does anyone have long term experience with the plastic springs? E. g. are the springs losing tension after a year or two/three?
How much force is left?

I'm planning on printing in PETG or PC.


Your question is a good one indeed.

I have started this project more than 2 years ago and have always been using only ABS. So far I have not noticed any weakening of the spring force, even on the oldest ones. But also, I use them mainly with rechargeable batteries, so there are much less taking out / putting in operations compared to disposable batteries.

Comments deleted.

is it possible for you to add a holder for 2/3AA Batteries?

diameter 14,2mm
lenght 30mm

Should be no problem. You just need to call module flexbatter(...) with the appropriate l= and d= parameters in the OpenScad source file. It's probably easiest to modify the call in flexbatterAA(), where you probably only need to change the l= parameter.

What version of OpenSCAD, and what slicer are you using?
Rendering to stl, then to gcode results in many unconnected points. My attempt to fix the stl found it needed to repair about 2000 faces ... and when sliced, leaves me with many missing parts and even whole layers. Viewing the exported stl file shows much transparency, missing walls and such. I'm using OpenSCAD version 2015.03-2 and am still examining what could cause this. Interesting is that OpenSCAD renders a correct view of the item, but seems to hickup exporting this to STL. Unfixed slicing to gcode results in a base layer which misses two springs (of 5, generating the 5x18650 case mentioned below)
I'm trying a different slicer now (skeinforge instead of slic3r) but my impression is that slicer doesn't cause the problem, instead it may hide or expose those to larger or lesser extent. (pre-slicer) admesh already reports problems with the STL.

Dec 7, 2016 - Modified Dec 7, 2016
Bushmills - in reply to Bushmills

I made some pictures of the resulting rendered files:

STL from OpenSCAD - already holes in it:

base layer unrepaired STL to gcode:

all layers unrepaired STL to gcode, showing the missing layers:

As the problem already starts showing in the STL file, slicer seems to merely aplify it. Therefore it appears to be an issue with OpenSCAD.

Currently I also use OpenScad 2015.3, but when I created the files it might have been an earlier version. I use Linux width SFACT/skeinforge as slicer and so far I have not had any problems. But as you can see in some of the comments further down, there are other people who had problems similar to yours, which they they could resolve using STL repair tools such as netfabb.

In addition to OpenScad, I also use meshlab to visualize my STLs - and so far I have not noted the "holes" which are shown in your pictures.

Dec 8, 2016 - Modified Dec 8, 2016
Bushmills - in reply to enif

So I compared rendering results against a few more similar items, and the next I tried showed almost exactly the same problem. I went on comparing, and found that those two are the only implementations manifesting that strange behaviour.
Code didn't look like they were related to each other, but it's a reference point for determining the cause. Conversion of resulting STL to gcode with sfact/skeinforge resulted in a broken gcode gfile (depending on gcode viewer, I got either "error in file", or a segfault ...). It is my current impression that something triggers an obscure bug in OpenSCAD which results in creation of an incorrect STL files, which then propagates the error through slicers into gcode files.

Reading through the comments below, as you mentioned others with similar problems, I noticed that it's the configuration for 5 cells which appears to be troublesome. Same as mine, and likely another clue.

I find it remarkably that we seem to use very similar environments (Linux, printrun for pronsole, sfact/skeinforge - though I'm mostly using slic3r), but this problem seems to show only in mine. Where environments are likely to differ is that mine runs on a 64 bit ARM based machine, yours may be x86 based.

Thank you - this appears to be exactly what I need, for a mobile solder iron, preferred operation voltages 16 to 24 V, from 5 18650 cells. Given that scad source has been published, addition of a cover/lid should be close to trivial, keeping batteries inside and fluff, debris and especially small metal objects which happen to live inside my pockets out. Commited item to printer right now.

exelente aporte. justo lo que nesecitaba

Excellent model, Thank you Sir!

Would it be possible to upload an stl of a 6 cell holder?

As you don't say what size of cells you need, it's difficult to help you...

But since you have the OpenScad source, you can easily generate any number of any type of cells yourself: at the end of the file, just call the appropriate module "flexbatterXXX(n=YYY)" where XXX is the cell type and YYY is the number of parallel cells in the block.

Thanks! Just printed the 1*AA holder on PLA and it works well even though PLA is not too flexible it still works. You spring design is excellent.

it woud be greade with a 9 volt battery model

These look great, I often need custom battery holders for projects. I do have a suggestion for contacts.
I use copper tape. The smug repellent tape. It's sticky backed and can be soldered onto. And it's really cheap if you go to garden centres or if there's one nearby I buy from B&M bargains.

I originally bought a tiny roll of tape from maplin which cost about £5!

do you think aluminum duct tape would work? I bought a large roll recently for some other project.. I am now wonering if it might be useful for conducting electricity. I am also wondering about using cnc or lasor cuttur for cutting design or etching into it.

Aluminum won't take solder.

Thanks for your suggestion - good idea! May be you could even take a photograph of how you attached the tape and post it here as a "Make" of this object, for us to see how it's done ... Thanks!

Hey could you please add 18450?


You have the OpenScad source, so you can easily create your own variants.

Hi. This was a great idea and they work great. One exception is the five battery aa holder. I'm not sophisticated enough to figure it out but at about 40 percent my printer starts filling in where the battery should go and stops building the divider walls like it somehow flips.It starts filling in the spring section as well. I don't have problems printing any of the other ones they all come out good but the 5 bay one I think there is a glitch somewhere. But the rest work great.

Strange... I have now uploaded a different version of the 5AA object, called flexbatterAAx5c.stl. Maybe that one works better for you?

Thanks for the upload but it still didn't work for me. Did the same thing. I will try to get someone local that knows more about the programing and if he figures it out I will let you know what I found. If it prints out for you and everyone else its probably some sort of issue on my end I'll have to figure it out. Thanks for the good design though I think as a temporary fix I will print out the 4 bay and a single bay and stick them together. They print out and work perfect. I will post pictures and stuffs when its all done.

They work great for me. The only thing I did different was use aluminum foil as contacts. I wrapped the wire through the holes to make contacts and twist the wires together. Then I use the aluminum foil instead of soldering. It worked great and I can reuse my prints over and over. Thanks!

please clarify how you got conducting contact from aluminum tape to the copper wires. I am thinking the side with adhesive won't be good at conducting electricity.

Not aluminum tape. Aluminum foil. I left the wires bare for the ends of the batteries and just used aluminum foil against the battery and foil. The battery contacts the foil not the wire. The aluminum foil contacts the wire.

If it conducts electricity then I guess it would work. I just used what I had on hand aluminum foil.

This is so cool =D

this is very something to think of and make!

I love the included springs. This makes battery boxes so easy to add to any project.

Hi I like the design and I have printed some 4x and 2x 18650 holders and I am wondering an easy method for implementing the terminals, what should be used?

As I described in the text, I directly use the stripped ends of the connecting wires as pole contacts, by winding them a few times around the pole cylinder. Optionally I then use the soldering iron to put some tin on the contacts to make the windings hold together - but don't use the soldering iron for too long, otherwise the plastic might melt...

Apr 7, 2016 - Modified Apr 7, 2016

I am new to this so sorry but has anyone tried printing this on a da vinci jr ... when I use their slicer it slices it really funny and messes up the spring part.

I don't know about the da vinci jr printer, but I remember that some users had similar problems (see comments further down) and there was even some forum discussion about it at https://forum.lulzbot.com/viewtopic.php?f=8&t=2695 . IIRC they used something like netfabb to postprocess the STL file. My STLs are generated directly by OpenScadn and I use Skeinforge for slicing, never had any problems so far...

Great design, thanks so much! Any chance you'd make the .scad file available, so I can generate my own models? I love OpenSCAD, btw!

How about just looking through the section "Thing Files" and downloading the file called "flexbatter.scad"???

BTW all my "things" always come with the full .scad source...

Thanks! I see it now! I promise I'd looked up and down the list twice, looking for it before asking. Great code, easy to read. Again thanks!

Apr 1, 2016 - Modified Apr 1, 2016

I've spent some time with your source for use with another project. It's a very elegant design and the comments in the source are pretty great. I've run into a bit of trouble with the flexbatter() module though. Can you help me understand what all the parameters are?

Thanks for your help and for sharing your work!

Maybe you can elaborate:

n: Number of cells
l: Length of single cell
d: Diameter of single cell
hf: something to do with the flanges along the top edge of the holder
shd: Screw Hole Diameter 
eps: something to do with the rails along the length of the channel 
xchan: the location of the wire routing channel with respect to the overall length 
el: Extra length - Not quite sure what this does, but it appears to effect the length of the spring

Check out the scad file of the multi-cell compartment version (http://www.thingiverse.com/thing:941081) which is a newer version containing still all the code of this "thing", but also has improved comments regarding the parameter meaning.

You are correct as to n,l,d,shd and xchan. As to the others:
hf: relative hight of cell case (1=full diameter)
eps: extra diameter space - added to "d" for the cylindric cutout in the middle.
el: extra spring length (needed for some small cells to accommodate the radii of the spring)

Flexing battery holders with 2- and 3-cell compartments
by enif

Thanks for the help. I'll check out the new version as well. You've been most helpful!

Comments deleted.

Don't know if this was already asked or mentioned and I missed it, but what gauge wire are you using for the power cables / windings?

That depends of course of the type of cell you are using and the current that will be flowing. But usually something in the neighborhood of 24AWG should just do fine.

Can you make one for D size batteries? Thank you!

Super cool. I printed off the 18650 last night for a project I am busy with. The Li-Ion - 5V charger is small enough to be hot-glued to the side of this making it a very compact solution for Li-Ion powered 5V project :)

Great project! I needed a holder for a CR12600 cell so I added another module statement with its dimensions.
But I know less than zero about SCAD. How do I get the script to run and do something? The SCAD website says "Press F6"
which, of course, does nothing in the SCAD editor window.
--Lost and confused....

Clever design !

Unfortunately the script produces a poor quality mesh, non manifold and with self intersecting surfaces.
Could not be sliced correctly with simplify3d and slic3r.

I had the same problem, but then I ran the STL file through this website that repairs STLs for free: https://netfabb.azurewebsites.net/

And then slic3r was able to slice it perfectly.

Thanks for sharing love this desing

How about a design for multiple cells alternating the position of the positive ends? This way it would be easier to series connect the cells without having to run a wire the length of the cell to the next one.

Alternating the position of the springs will result in a kind of zig-zag form which I didn't like too much, but since you have the source file, you can do it yourself if you like. Note also that you can leave all the springs on the same side and just insert the battery cells by alternating their direction, so the +/- poles are alternating between spring and no-spring position.

Also, if you use the multi-cell compartment remix, you need to do even less wiring, since you only need to wire the poles at the end of the cell chain...

Brilliant! You have figured out a way to make the most difficult part of a 3D printed battery holder 3D printable! Great work!

I will definitely use this idea next time I need a battery holder for a project!

Thanks for your kind words! :)

Nice design!
You should make it customizable.

Very well designed! Thank you.

What did you use for the metal end contacts?

As explained in the main text, the contacts are made by winding the stripped ends of the connecting wires around the contact bar.

What is with these cable jumper connector? Are they printable too?

No, these are standard crimp connectors - the white ones are JST-XH2.5 connectors and and the black ones are Dupont connectors.

Comments deleted.

Is there a 5 cell design of this? I have a TX that uses 4 AA Alkaline cells = 6V and when I use NiMH which are only 1.2 versus the 1.5 volts of the alkalines per cell I need to add another 1.2 cell to get a true 6 volts to the TX. Would be very helpful it's not too much trouble to upload a 5 cell version.


Great design by the way!

OK - done!

BTW the STL was generated simply by calling "flexbatterAA(n=5);" at the end of the SCAD file ...

I'm having a little issue. The 1-4 cell size AA files worked great. The 5 cell you recently added doesn't get converted correctly when sending to my printer. I don't see a way to add a picture in the comments that would explain easily. Did you get any errors with the 5 cell model?


What slicer are you using? I just ran the AAx5 STL file through the MatterControl/MatterSlice slicer and it slices perfectly. I know that some people have had problems using Slic3r (see some of the comments below) and had to "repair" the STL using "NetFabb" (which I have never used) in order for Slic3r to work correctly.


I have only worked exclusively in Sketchup, so wouldn't even know where to begin with working that out with SCAD file, so thanks again...

God, this will make my life so much easier! Thank you so much for these designs!

Thanks a lot for these things!
I'm just about to print the 18650x1 holder, but Repetier Host complains that the STL isn't manifold. No problems repairing with Netfabb, but perhaps you would like to check the file for future users?

Thanks for your comments! Strange, I generate all my STLs with OpenScad and never had it complaining about an object not being a valid manifold - in which case OpenScad actually refuses to save the STL. Also, I never had any problems when printing these STLs, but I don't use Repetier but Pronterface/SFACT.

I just have to ask, where is the 9Volt version ;)

It's for cylindrical cells only... But as you have the OpenScad source, feel free to modify as you like ;)

Thanks for this design! It's part of my first battery-powered project, now complete!

Keep up the good work!

great, awesome, easy, practical
Works great with PLA too

One of the best things here for electronic maker

Greetings from Munich

Danke, Michael! :)

Any chance you could add a AAAA? I'm currently designing a 3xAAAA case but I'd rather use yours because it is awesome.

You got the full source, so just download the SCAD file and call flexbatter with the corresponding dimensions. However, keep in mind that the AAAA cells are very narrow (only 8.3mm wide), so you would also need to reduce the spring wall thickness (ws) accordingly - but I am afraid that the resulting spring would not be strong enough... Anyway, why don't you try it and report back, best with a "Make" if you were successful :)



Very awesome! Thank you for sharing! =)

Thanks! :)

16340 which file is that/

It's the CR123A.

Very nice design. Printing as I speak, just needed this for a pencil sharpener of my daughter that works on other (bigger) batteries.
Thank you!

Oct 26, 2015 - Modified Oct 26, 2015

j'ai trouvé un truc pas mal pour faire les pattes de contacts électriques.
j'ai coupé des cosses et sa marche très bien :D
merci à l'auteur de l'objet ;)

photo: http://www.thingiverse.com/make:166803
video: https://youtu.be/D4oEZYRzkJM

Flexing battery holders with integrated spring
by gardien

exactement ce que je cherchais, merci :)

Sep 10, 2015 - Modified Sep 10, 2015

A very nice design indeed. I had trouble printing the AAA holder, though. My printer would only print the outer part of the plastic springs. The inner part, closest to the batteries, was too small, I suppose. My printer simply got ignored those inner parts of the spring. The printer just printed the first 180 degrees of the spiral arc. Any tips on that?

Strange... I doubt that this is a printer problem, I rather suspect it to be related to the slicer you are using. Have you verified if your slicer gave any error messages while processing the STL file? If the missing parts of the spring are not in the gcode file, it's not your printer's fault. Note that my STLs are optimized for 0.56mm extrusion width, if your extrusion width is much bigger, you might want to modify the "ew" parameter and regenerate the STL.

Cura does omit the parts in the gcode files. With a bit of tweaking most of the spring is printed. I wasn't able to print the holder so that the spring was attached to it. This was the best I could to tweaking Cura's settings: http://i.imgur.com/TV3veI1.png
I have no idea what the problem is. My printer is a Lulzbot Mini. The extrusion width shouldn't be too high.

I don't know Cura, so I have no clue what is going wrong here. But given that a lot of other people have successfully printed these battery holders (see the "Makes"), I think that my STL files should be okay.

I'm sure they're impeccable, just thought you might have an idea. I will post here if I figure something out with Cura. Maybe it gives me an excuse to try out Slic3r. What do you use?

I use Pronterface/SFACT.

In case you're interested, here is the thread about it on the Lulzbot forum: https://forum.lulzbot.com/viewtopic.php?f=8&t=2695

Brilliant design. I tried the CR123 and even in PLA it worked perfectly. Thank you.

How is this not a "featured design"? Brilliant .

Hello enif,
these are really perfect and smart holders for batteries.

But i have a batch of longer protected 18650 batteries and i dont know, how to work with openscad.
Please, can you make .stl files for 3pcs and 4pcs 18650 with dimension 70x18mm?

Thank you very much for that!

Ok - done! They are called flexbatter18700x{1,2,3,4}.stl .

Oh, man, thank you very very much!

Perfect work!

Great idea, was very keen to get it printed. Did it PLA and a spring cracked when i dropped it from 1.50m, and it didnt seem as convenient when held as something with a stronger spring. may have a go with ABS later out of curiosity. the stl and 3d design is very nice. just it feels totally impractical in PLA.

I am not surprised that PLA did not work, it's much to stiff and cracks too easily.

As I mentioned in my project description, this project really needs a material like ABS to achieve the required elasticity.

Mar 15, 2015 - Modified Mar 15, 2015


Thanks for a very nice design. This is the smartest battery holder available! clamps nicely and no special clips needed. I have printed the double AA version. I use 0.4mm solid wire for the contacts and a small strip of aluminium tape underneath the wire for an even contact surface. I have combined this design with the customizable box (http://www.thingiverse.com/thing:189264) and Adafruit powerboost (http://www.adafruit.com/products/2030) USB 5V supply to make a USB power supply. It's now powering my Raspberry Pi/Hifiberry.


Customizable Round Box with Lid
by Arvin
Feb 13, 2015 - Modified Feb 13, 2015

Very nice and clever work. Thanks for your effort! I tried printing several other people's battery holder designs and they didn't work out. Some were just too thin. Ones with "arms" to hold the battery in place didn't work because the arms are not very flexible and they break off when you try to remove the battery.

I'm using a Davinci printer. Initially, the 1 AAA holder I tried to print didn't print correctly - the "spring" end was completely missing. I then ran the STL file though a "cleaner" at this site: netfabb.azurewebsites.net. This is a free Microsoft site, but you do have to register. You upload a file, it crunches it, and you can download the "fixed" STL file. The holder now prints correctly. I've used this site before to successfully fix prints with missing features.

Also, I didn't have much luck winding the wire contacts. I was using 22ga solid wire. What I am using now is a thin, pure nickel, strip normally used to connect battery cells. These strips are typically spot welded to the battery terminals. I found these on ebay about a year ago and used them to rebuild a DeWalt battery pack. I just soldered the strips to the batteries since I don't have a spot welder. The strips are about 8 mm x 5 cm and very thin. They fit perfectly in the 1 AAA holder that I printed and would not pull out when I tugged on them. Although I haven't tried this yet, I plan to epoxy the strips in place and solder a wire to them.

I got my strips from "glad2bactive" on e-bay, purchasing a pack of 30 for about $6.50 plus a shipping charge. You can probably get them locally at a "Batteries Plus" store or other battery store that rebuilds battery packs.

Thanks for sharing your findings!

The AAA holder being the smallest is indeed also the most demanding in terms of printing quality and winding the contact wire at the minus pole. I also use solid wire there, because it is easier to insert (as the spring leaves only little space) and haven't had any problems yet.

just a question. But what are you using at the ends of the battery box to make contact with the battery itself ???

Thanks Steven

As is said in the text, I strip the insulation from the wire at the end and wind it around the "cylinders" at the + and - sides of the battery holder. I usually strip about 10cm and do 5-6 windings, then cut off the remaining bare wire. I then "tin" the windings at the battery side with a bit of solder to insure that they don't unwind - but be careful not to stay too long with the hot soldering iron, you don't want the plastic to melt ;)

BTW you can see how I do it on photos no. 7 and 12.

My compliments on your brilliant design and execution!

It is my desire to use your SCAD code as part of a current project where your battery holder is merged into the mounting frame to hold a number of PCBs.

With that in mind I would like to make a request. If you could pass the overall outside "cube" dimensions in a global variable that would help people like myself carve out and merge your design into our projects. And also the dimensions of the springs so we can be sure there is a proper opening around them. Thank you for considering adding this to your great source code!

Thanks for the compliments! :)

As for your idea about passing back the global dimensions (and position, I suppose), I could see the use of it and I am quite open to implement such a suggestion. However, I really don't know how to do this within the limitations of the OpenScad language (BTW nor how you would use these values after the object already having been constructed...). As far as I know, it's not possible in a module to assign values to global variables which are then passed back upwards to the calling module. So, could you please be more specific about the parameter passing mechanism you have in mind?

Jan 2, 2015 - Modified Jan 2, 2015
Charles_Christopher - in reply to enif

understood. let me explain the goal and recant my suggested implementation.

this project starts with a cube (sheet) that has 4 holes in the corners for mounting. everything else is union() with that sheet. i need the overall height to be as short as possible. your battery holder must now be part of that sheet, and the bottom surface is at the same elevation as the bottom surface of my sheet.

to accomplish that i must handle the interferences of your "part" and my "part". first i must cut a hole just smaller than the body of your holder so the union causes the two to properly merge and not fill in any of your object features. then there are the springs. the bottom of the springs need to touch the build plate AND i must cut a hole for them (in my part) to move freely.

hopefully you see what is going on. if i have the holder dimensions then i can code that into my code and even change the battery/configuration with the code handling the merging of the two. otherwise i have to author code in which i play around with numbers to make it work, and avoid making any changes after that.

another idea might be, and i do this on my modules so far in this project, is center the final object on the origin for each and every module() output. then we know where it is: [0,0,0]. next would be provide two functions for the "cut and paste" into a parent object with their RELATIVE coordinates also centers on [0,0,0]. thus, i use the same offset values with all three of your objects making coding easy, and i properly select the right ones for the difference() and union() parts of my object.

in effect i cut a "T" into my sheet. the top of the "T" is where you springs are, it is a big hole. the vertical of the "T" is just smaller that your holder and thus caused you holder and my sheet to completely union.

does that make sense?

thanks again for considering adding this to your work!

Ok, I do understand what you would like to do. What I still don't see is how exactly you propose that my OpenScad module should return position and the overall dimension... your reply doesn't say anything about this. As far as I know OpenScad does not allow to pass any variables upward to the calling module, and also global $variables wil only be passed to lower levels. The only (admittedly not so elegant) way I can see how to obtain the desired position/dimensions you need, would be to output them in my module with an "echo" statement, which you could then need to cut&paste into your code. If you have any concrete idea how to pass these values more directly within the OpenScad framework, please let me know.

in my last post i took back ("recanted") my original request.

at the end of the post i made a dfferent suggestion, seperate functions to return object of the necessary sizes and placed in space at the same location as the holder. thus offsets applied are the same for all and also apply to changes in the holder setup.


Do you mean that one should provide in addition to each module which generates an object also a corresponding function to return an array with the overall size and location? The problem I can see with this is that this function would not have access to the local variables of the corresponding module...

Why don't you explain your idea with a small OpenScad example that shows the mechanism you propose for a very simple case?

Sorry to be so slow on the uptake :)

Very nice... very creative... I am gonna make these for my 18650's !

Thank you! :)

Now that I look at the picture a bit closer, I see what you are doing with the wire end wrapped around the plastic (nice!) and I agree that is better. The problem with putting the battery in the other way is human error: I'm trained to put the negative end against the spring every time. Perhaps an alternating ring shield around the wire end to keep the flat (negative) end from making contact on the side that should be positive?

May I suggest an option to place the spring at the opposite end on alternate positions in order to make the wiring of series battery packs a bit easier? Especially if you add a slot between the walls so that a bit of metal sheet can be clipped and bent to fit between the negative end of one battery and the positive end of the next.

You can easily do the alternating orientations in the SCAD file by changing line 108 from




However, personally I don't like the look of the alternating springs and the gaps between. I see your idea with the metal sheets, but I think it will be difficult to make them hold firmly in position.

Also, you could leave the springs as they are and just insert the batteries with alternate orientations, so that the spring is alternately on the plus and the minus pole...

Nice work, perfect for what I was looking for....

idk why, but my slic3r hates this. it's just makeing stringy crappy slices

Strange! I use pronterface with SFACT and I have no problems - as you can see on my pictures...

enif, i like your design, it's really clever design, but is it possible to add a 2 x 26650 size battery holders to your list? i had problem with your scad file, i use catia, so...

Sep 17, 2014 - Modified Sep 17, 2014
enif - in reply to wohenzhuce

I have now added STL files for th 26650 type cells. As I don't have such cells here, I could not test them, but had to rely on the dimensions given in http://en.wikipedia.org/wiki/List_of_battery_sizes .

got it, thanks mate

Excellent design - Wish I'd thought of this before buying 60 sprung battery terminals!

This is one of the greatest things I've seen. And I've looked at nearly everything in the Thingiverse.
Also I was in need of a 3 battery holder, nicely timed too.
(Which also might be affecting my perception of "greatest" but I stand by my original statement :-D )

Thanks, Bill - I appreciate your kind words! :)