3D FreeCAD Toroidal Transformer Winding Project

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
daddyzaur
Posts: 16
Joined: Thu Jun 04, 2020 6:21 pm

3D FreeCAD Toroidal Transformer Winding Project

Post by daddyzaur »

Thank you for taking the time to check this post. In a previous post I had to deal mostly with learning. Now I do have a functional project and I need help with three problems. The main project file and a few test files (sorry, only ZIP format allowed for upload) are here: http://www.daddyzaur.com/?p=231

OS: Manjaro Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16158 (Git)
Build type: Release
Branch: makepkg
Hash: 783e1346c7a078f5265c3f0c6a927d09a8c1fe70
Python version: 3.8.3
Qt version: 5.14.2
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
Torus_004.png
Torus_004.png (702.88 KiB) Viewed 2263 times
The first problem: how to correct the 3D model and make it precise?
What is the issue? FreeCAD can easily create a Helix, but only if the Helix is progressing in a linear direction. Unfortunately, in order to place a Helical winding on a Torus you have to bend the Helix progression in a revolving way along the Torus. That, right there, is breaking the FreeCAD camel's back: bending the Helix will dramatically increase the size of the FreeCAD project file, and the resulting shapes are kind of useless. Any attempt to further process those resulting shapes will crash the program after a looooong waiting time. And yes, poor FreeCAD will successfully check the geometry and it will report that everything is just peachy.
The second problem: how to validate my assumption this is a FreeCAD bug?
If I am using FreeCAD the wrong way, maybe somebody can point to a working solution to get a "perfect" Toroid project, regardless of the extreme shape ratio. Yes, we can have common/differential mode transformers with only 4 turns, dual wire; or some special Toroid shape that doesn't look good with a fake 3D base. And that looks really ugly, never-mind wrong for real applications.
It is possible to develop a macro-type application to automate the Toroid design?
Assuming this project can be fixed to provide a true and accurate 3D model, it is there somebody who can help to put it in a macro type add-on? I do not have the skills required for this part, but I would like very much to have an easy to use design tool for electronic projects.
And finally, here are some good-ish and bad results, generated automatically
One can easily play around with the numbers in the spreadsheet and generate thousand of projects, with any dimension ratio. It will become obvious very soon, using a fake 3D linear progressing Helix chunk to stitch it in an array and to approximate a real winding is kind of limited: garbage-in, garbage-out.
.
Torus_005.png
Torus_005.png (667.29 KiB) Viewed 2263 times
.
Torus_006.png
Torus_006.png (327.56 KiB) Viewed 2263 times
.
Torus_008.png
Torus_008.png (223.85 KiB) Viewed 2263 times
.
Attachments
Torus_001.png
Torus_001.png (945.88 KiB) Viewed 2263 times
Last edited by daddyzaur on Wed Jun 10, 2020 2:51 am, edited 1 time in total.
drmacro
Veteran
Posts: 8984
Joined: Sun Mar 02, 2014 4:35 pm

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by drmacro »

daddyzaur wrote: Tue Jun 09, 2020 8:30 am The first problem: how to correct the 3D model and make it precise?
Dealing with a Toroidal Helix winding is not easy in FreeCAD, or at least not in a very precise way. You have to kind of fake it, stiching together some linear progressing Helix chunks, compromising the integrity of the winding and of the 3D model. What is the issue? FreeCAD can easily create a Helix, but only if the Helix is progressing in a linear direction. Unfortunately, in order to place a Helical winding on a Torus you have to bend the Helix progression in a revolving way along the Torus. That, right there, is breaking the FreeCAD camel’s back: bending the Helix will dramatically increase the size of the FreeCAD project file, and the resulting shapes are kind of useless. Any attempt to further process those resulting shapes will crash the program after a looooong waiting time. And yes, poor FreeCAD will successfully check the geometry and it will report that everything is just peachy.
The second problem: how to validate my assumption this is a FreeCAD bug?
Is it easy in any 3D modeling tool? And "easy" is a relative term. What's easy for others may be very difficult for novice users.

What size would you expect the file to be? Complex curves take a lot of data to define.
"and the resulting shapes are kind of useless" What is you use case for the model? Visualization of the inductor? FEM analysis of the electrical field? Length of wire required for winding? Something else?


Unless I am still in the VERY early learning stage and VERY wrong in my assumptions, here is the deal: I suspect FreeCAD is not really a full-fledged, true 3D tool at this point. It is moving the needle only up to 2.75D or so. If I am using FreeCAD the wrong way, maybe somebody can point to a working solution to get a "perfect" Toroid project, regardless of the extreme shape ratio. Yes, we can have common/differential mode transformers with only 4 turns, dual wire; or some special Toroid shape that doesn't look good with a fake 3D base. And that looks really ugly, never-mind wrong for real applications.
It is possible to develop a macro-type application to automate the Toroid design?
"I am still in the VERY early learning stage and VERY wrong in my assumptions" seems like a correct statement to me. 8-)

"I suspect FreeCAD is not really a full-fledged, true 3D tool at this point." Considering FC is used around the world to do real 3D modeling in industrial, institutional, and hobby setting this would seem to be an inaccurate statement.

"never-mind wrong for real applications." What would you consider a "real" application? :?:


Assuming this project can be fixed to provide a true and accurate 3D model, it is there somebody who can help to put it in a macro type add-on? I do not have the skills required for this part, but I would like very much to have an easy to use design tool for electronic projects.
And finally, here are some good-ish and bad results, generated automatically
One can easily play around with the numbers in the spreadsheet and generate thousand of projects, with any dimension ratio. It will become obvious very soon, using a fake 3D linear progressing Helix chunk to stitch it in an array and to approximate a real winding is kind of limited: garbage-in, garbage-out.
"provide a true and accurate 3D model" Again, what do you define as inaccurate? Have you used the model in a FEM analysis and determined it's geometry is non-manifold, not correct size, etc.? Or is it that what ever your graphics card is rendering is just bad?

"who can help to put it in a macro type add-on?" Yes this can be done. <sarcasm mode on> ;) We'll get the room full of idle (volunteer) programmers we have right on that.<sarcasm mode off> But, of course it is possible for individuals to sponsor specific additions if you can find a programmer who's interested in the project and with spare time.


Oh, and upgrade to 0.19, you'll be glad you did. Not that I think it will fix anything you seem to have issues with, it's just had tons of fixes and is known to be stable.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
daddyzaur
Posts: 16
Joined: Thu Jun 04, 2020 6:21 pm

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by daddyzaur »

Hello drmacro, thanks for answering.
.
I have to assume you do not deal with wingdings or transformers on a regular basis. Yes, out there are commercial programs and web based design interfaces that can create a 3D model of Toroidal winding in real-time and with live, instant visualization of the results. Maybe a lot of data, but processed in milliseconds. I tried to put together my own and general model in FreeCAD, to ad a different number of turns, multiple layers, etc. A more general 3D model for common electronic components.
.
How precise you asked? Precise enough to be realistic. A designer needs to know if the fill-factor of the transformer leaves enough room for the winding head. Does your transformer can accommodate the turns needed to pass trough? How is the project impacted by the change in isolation thickens? Can you afford to ad an isolation layer? How thick can you wire be? What is the maximum number of turns that can fit in? Yes, you can calculate on paper, build a prototype, measure the darn thing, rinse and repeat. Having a realistic 3D model can show if your wingdings can fit in, but only if you can count on a relative accurate model. Let's say maybe no more than 5% error, or better. If I add a few winding layers, is the model showing the right fill factor? If the wires are scrambled inside, the model will be badly skewed overall.
.
You can be sarcastic all you want. I do not demand help, I asked for help. It is not this the "Help on using FreeCAD" forum?
All The Best.
drmacro
Veteran
Posts: 8984
Joined: Sun Mar 02, 2014 4:35 pm

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by drmacro »

daddyzaur wrote: Tue Jun 09, 2020 4:29 pm Hello drmacro, thanks for answering.
.
I have to assume you do not deal with wingdings or transformers on a regular basis.
You would then, assume wrong.
Yes, out there are commercial programs and web based design interfaces that can create a 3D model of Toroidal winding in real-time and with live, instant visualization of the results. Maybe a lot of data, but processed in milliseconds. I tried to put together my own and general model in FreeCAD, to ad a different number of turns, multiple layers, etc. A more general 3D model for common electronic components.
"out there are commercial programs and web interfaces that can create a 3D model of Toroidal winding in real-time and with live, instant visualization of the results."

Indeed, a custom application, tools, custom designed for the job, optimized in both the user interface and the back end speed, for a limited, possibly single purpose, by a room full of paid engineers and software types; performs better than a free, general purpose 3D design tool that is developed and maintained by a hand full of volunteers.

Seems, there is a hands down winner.
.
How precise you asked? Precise enough to be realistic. A designer needs to know if the fill-factor of the transformer leaves enough room for the winding head. Does your transformer can accommodate the turns needed to pass trough? How is the project impacted by the change in isolation thickens? Can you afford to ad an isolation layer? How thick can you wire be? What is the maximum number of turns that can fit in? Yes, you can calculate on paper, build a prototype, measure the darn thing, rinse and repeat. Having a realistic 3D model can show if your wingdings can fit in, but only if you can count on a relative accurate model. Let's say maybe no more than 5% error, or better. If I add a few winding layers, is the model showing the right fill factor? If the wires are scrambled inside, the model will be badly skewed overall.
Thus the requirement is for a model within tolerances to be used for design and specification of tooling and manufacturing operations for toroidal inductors and transformers.

Wrapping wires around a toroid, as you have pointed out, is not a trivial exercise in the math department. It is no surprise to me that the UI and OpenCASCADE engine are not optimized for the task. Can it present a visual representation? Given these limitations, yes; you, bugman, and others have shown this (though, I don't think any have implied it was the way to do multi-layer toroid design). Can it produce a model that meets the stringency of your requirements? Possibly, with the right customization (macros, python, etc.) of the UI. There may be limitations of the OCT engine that may preclude it, so even with custom UI, maybe not. Others with more indepth knowledge of OCT would have to comment.
You can be sarcastic all you want. I do not demand help, I asked for help. It is not this the "Help on using FreeCAD" forum?
All The Best.
It appears from your post and from your web page that you have determined FreeCAD is a non-3D tool, possibly making it all the way up your scale to 2.75D. That the models it makes are fake. That because it doesn't meet your requirements is inaccurate. That geometry which tests good because the tools and functions used to create it worked, but doesn't meet your needs is a bug.

It also appears you have a deep understanding of toroid design and manufacturing. And, opposed to many, have taken the time to do considerable learning of FreeCAD.

My sarcasm is in response to your, admittedly IMO, judgemental terms you use in your asking for help. I'm sorry if I offended you.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
daddyzaur
Posts: 16
Joined: Thu Jun 04, 2020 6:21 pm

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by daddyzaur »

Hi drmacro,
Looks like you're one of the good guys after all. I am grateful for any bit of time you or anyone else can spare.
My help request would be much better understood if I point to the basic test project that made me believe there is a FreeCAD bug. The test file "TR_1P2S_B64290L0632X038_TEST_SQW_2" has only 3 solids, all of them reported error free. Using 2 boolean operations I can get a "perfect" and continuous Helix winding. Unfortunately the file would be extremely large, and the resulting object cannot be processed further. I tried to apply a Fillet on it to make a round cross section. This is a dead end. I could not find ANY way in FreeCAD to build a continuous winding around the torus, close to the Torus surface. I would be very happy if you or somebody else can find another way to do it.
.
This is my understanding: a Helix object progressing linearly has no computing problems. The same Helix forced now to progress around a smooth, perfect circle will crash the most ferocious systems. Only because of this one change. There must be some underlying issue in FreeCAD that messes-up the whole contraption as soon as a single direction change around a perfect circle is required. There are no complex and random shapes: all of them are composed of either linear or perfectly round edges, obeying only the most basic equation.
.
Here is the resulting Helix after cutting/intersecting the two solids, the one Helix that cannot be processed further:
Torus_001.png
Torus_001.png (226.02 KiB) Viewed 2158 times
Torus_003.png
Torus_003.png (351.4 KiB) Viewed 2158 times
drmacro
Veteran
Posts: 8984
Joined: Sun Mar 02, 2014 4:35 pm

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by drmacro »

daddyzaur wrote: Tue Jun 09, 2020 6:53 pm Hi drmacro,
Looks like you're one of the good guys after all. I am grateful for any bit of time you or anyone else can spare.
My help request would be much better understood if I point to the basic test project that made me believe there is a FreeCAD bug. The test file "TR_1P2S_B64290L0632X038_TEST_SQW_2" has only 3 solids, all of them reported error free. Using 2 boolean operations I can get a "perfect" and continuous Helix winding. Unfortunately the file would be extremely large, and the resulting object cannot be processed further. I tried to apply a Fillet on it to make a round cross section. This is a dead end. I could not find ANY way in FreeCAD to build a continuous winding around the torus, close to the Torus surface. I would be very happy if you or somebody else can find another way to do it.
.
This is my understanding: a Helix object progressing linearly has no computing problems. The same Helix forced now to progress around a smooth, perfect circle will crash the most ferocious systems. Only because of this one change. There must be some underlying issue in FreeCAD that messes-up the whole contraption as soon as a single direction change around a perfect circle is required. There are no complex and random shapes: all of them are composed of either linear or perfectly round edges, obeying only the most basic equation.
.
There are definitely two (some would say more) areas where FreeCAD has some issues. Fillets/chamfers and curvy, organic shapes.

For organic shapes (like the wires, especially non-circular cross-section) give the OCT engine fits. (There's occasionally issues with coplaner faces, but this is a convergence management issue, again OCT, not FreeCAD.)

FreeCAD UI is not optimized for defining organic shapes. OCT is not particularly at handling twisty stuff where the twist or deformation is the result of physical attributes of the thing being modeled. (For example, shape deformation because, say, modulus of elasticity.) The sheet metal work bench handles the bend radius based on well defined existing algorithms (i.e someone decided to do the sheet metal workbench and those are layered in the workbench, not in core FC code.)

The fillet/chamfer issue is also an issue with OCT. The high level view is, it won't cross face boundaries. (I'll describe this again as a convergence issue, when the fillet goes beyond the edge of the face; what should the modeling engine favor? The horizontal face? The vertical? The third edge coming from the left?)

In the end these are OCT issues and the FC devs have no control when OCT will address them.

And, these issues may have direct bearing on the wrapping wires around a core. The two guys who have developed the Curves and surface workbenches would know better than I if this is even possible and how difficult it may be. (I haven't done any CAD coding since the 1980's...other than the odd python script. :( )

I have tinkered with how to do this with FreeCAD to no avail: https://www.youtube.com/watch?v=KId94FyFNHw

The fact that Fusion360 has a setting for twist in that sweep would imply they've not only worked on the modeling of such a thing, but have also worked on the UI for similar things.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by chrisb »

You insinuate that all this should be easy if not trivial. But a circle alone is already far from trivial and if you look at the formulae you gave for your spiral around the torus ...
daddyzaur wrote: Thu Jun 04, 2020 8:44 pm This is the kind of parametric Helix settings I used for the ParametricCurve macro:
Equations:
a(t) = 7.5375 // radius of Helix revolving path: (R + r) / 2
b(a,t) = 4.8 // radius of Helix turn: (R - r)/2
c(a,b,t) = 30 // number of turns in a single layer
X(a,b,c,t) = (a+b*cos(c*t))*cos(t)
Y(a,b,c,t) = (a+b*cos(c*t))*sin(t)
Z(a,b,c,t) = b*sin(c*t)
Parameters:
Min t = 0 //circular start point in radians (0 ... n * 2 * 3.141592)
Max t = 6.075 //circular end point in radians (0 ... n * 2 * 3.141592) max 6.283185 or 6.075
Interval = 0.01 //calculus step
... you see that you have a tesselation of 0.01 which means you compose all of these rather complicated formulae to quite a bunch of control points.
I guess that a program like FreeCAD can be optimized to create such transformers in a rather efficient way, but currently it isn't. So you have to look for some workarounds, which can make FreeCAD extremely slow.

It would be trivial if you can calculate it in your head. It would be simple if you can do it on a piece of paper. As soon as you need a calculator it is no longer simple.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
daddyzaur
Posts: 16
Joined: Thu Jun 04, 2020 6:21 pm

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by daddyzaur »

Hi chrisb, appreciate your answer. Not to put salt on this wound, but yes, both sin and cos in the helix equations can, actually, be computed on paper as a trivial power series, or replaced with a look-up table matching the error limit. It will take a while to multiply and divide by hand, but it can be done on paper. I understand the missing puzzle piece would be the procedure to deal with this kind of data, and that sounds like a reasonable explanation.
.
This fully answers my question and I will avoid burning again a few more nights, wondering what I am doing wrong. That was the most and very frustrating part, learning a whole new CAD thingie and having no clue where to look for problems. For this clarification I am deeply grateful to you and to drmaco!
.
Lacking any other clever ideas, I will try to improve on what I've got. The limitation would be to keep a reasonable size ratio for the core geometry and winding distribution. I can add trough the spreadsheet any number of windings and multi layers, starting/ending at any random angle, with any gap between turns and layers, random number of turns, etc. In this case "any" means as long as all of them can fit inside the Torus. I guess I can use it for real work for most of my projects. Maybe somebody can help with creating a macro. I will be happy to provide the version with all those options I plan to add.
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by chrisb »

daddyzaur wrote: Wed Jun 10, 2020 3:33 am Not to put salt on this wound
Not at all, I'm glad to see someone can calculate these by hand. In fact computers are not clever at all, they are only fast.
I wasn't very precise when I said "on a sheet of paper", but you may agree that for calculating 600 controlpoints plus calculating the B-spline going through them it may take enough sheets of paper to not call it easy :) .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
tcsut
Posts: 5
Joined: Wed Oct 21, 2020 6:10 am

Re: 3D FreeCAD Toroidal Transformer Winding Project

Post by tcsut »

I created two python scripts for creating a toroidal transformer winding (parameterizable).
The first variant implements the piping path by custruction of a cutting face with the core ring shape. Unfurtunately the fillet cuts are quite complicated and therefore the computational power is high and the creation is slow.
The second variant approximates/simplifies the fillets path with a radius, which performes much better.

How to use:
import ToroidalWinding
ToroidalWinding.create('test1')

or
import ToroidalWinding2
ToroidalWinding2.create('test2')

change parameters after creation.
enjoy!
Attachments
ToroidalWinding2.py
Version 3
(3.71 KiB) Downloaded 88 times
ToroidalWinding2.py
Version 2
(3.67 KiB) Downloaded 38 times
ToroidalWinding2.py
Version 1
(3.48 KiB) Downloaded 36 times
ToroidalWinding.py
(3.58 KiB) Downloaded 51 times
Last edited by tcsut on Fri Dec 18, 2020 12:42 pm, edited 4 times in total.
Post Reply