Alf's Musings #19
Alfonso Martínez de la Torre
Founder at OpenMagnetics, a Free Open-Source toolbox for designing inductive components
There have been some disruptions in the power force lately, as Mike Engelhardt , father of LTSpice, the most used circuit simulator in history, has released the next generation of its famous software, QSpice. It was announced to have higher simulation speed, functionality, accuracy, and reliability.
I have been using circuit simulators for years, specially from a scripting point of view (if you are interested, dear reader, take a look at Ngspice and its Python integration) but I don’t feel like I am able to do a worthy review of QSpice, so I am leaving that to better men than me.
The reason I am mentioning this new release is because it allows me to introduce the topic I wanted to discuss today: Software in the Power Electronics world, and more concretely the advantages that modern software can bring to this sector.
One of the reasons for having a new Spice simulator, if I understood Engelhardt properly, was to take advantage of the improvement that modern languages and compilers bring to computer programs, and if there is something that nobody can criticize about QSpice is its speed.
But the world is full of naysayers, so many people think that speed is not important, that it is still fine to have your simulation run in VBA in the back of an excel sheet (or even worse, ask people to pay for it).
Never underestimate what 30 years playing with MS Excel can do. Or how quickly it could be done with modern software.
So I would like to discuss the reasons why using and writing new software, with modern paradigms and tools, is a necessary skill for all Engineers. Yes, also for you, Power Engineers.
PISS (Portray It Simple Stupid)
I am big fan of Douglas Adams’s Hitchhiker Guide to the Galaxy, but I recently discovered Dirk Gently’s series. In it, Adams argues how the best way of understanding a topic is explaining it to somebody less knowledgeable than you, and as there is nothing more stupid than a computer, there is no better way of learning that explaining things to a computer: programming.?
As many of you know, I have been writing my own program for synthesizing power magnetics, and I can attest to what Adams wrote. When you write a program as simple as choosing the right number of turns for a transformer you cannot do as you would with a colleague and just say “just make sure it complies with the turns ratios of all the secondaries”, you have to describe that behavior without ambiguity.
And at that moment is when you discover that some modulo operations are not valid for numbers smaller than 1, that sometimes you have tolerances in your turns ratios and many combinations of turns can comply with a given requirements of turns ratios.
Now imagine the amount of details that you can find when instead of choosing the number of turns you are selecting a magnetic core. I am not going to torture you with that, but I will just leave the flowchart here in case there is some masochist that want to take a look at it.
When you have to do this is when you really start understanding things, because you have to. You have to read every book about area products, every paper about core losses, every standard for calculating insulation coordination. Because in order to automate and program processes, you have to comprehend them.?
So yes, I recommend learning programming because it helps you detect your knowledge holes and fill them. It forces you to look for the whys, not just the whats.
领英推荐
Speed wins
We have a saying in Spanish that I love, and it translates more or less to “Dress me slowly, because I’m in a hurry”. It means that we things are fast-paced and we are late, it is better to keep calm and think things over, because if not we will end up wasting more time due to mistakes.
But in the title of this section I am advocating for speed. Am I contradicting myself? Not necessarily, as I believe there is an overlap of both ideas that is perfectly described by the English saying “Work smarter, not harder”. And in this context, I am arguing that smarter is with Software. Let me continue with the magnetic core selector I mentioned before.
Imagine that you have to select a core to design a magnetic for a given topology, and you want the core to be available online so you can get it in a few days. But you also want the best core, right?
I will tell you how I have seen this problem solved in the past: You design your magnetic with the usual method, maybe your typical excel, maybe some expensive outdated software, and after designing it you go to the web and surprise! the core that you chose is not available.
Now comes a really tough path, marked with cross reference tables for core materials, and a lot of visits and clicks in Digikey/Mouser/etc.
Or maybe this is not your first rodeo, so you do a basic filter in Digikey and download the excel sheet (actually sheets, as these webpages limit the number of rows in each download). At the end you will spend more hours looking for a decent replacement than you spent choosing the original core.
And this is a process that you will have to repeat every time, as the stocks and prices change. You will take time next time, don’t worry. But I still wouldn’t recommend this Sisyphus’s torture to anyone.
Instead, what I would do is use a little modern software technique called “web scraping”, which, in a few words, means that our software will access the web as if it were a human, capture the same information that we see in Mouser’s search result, and bring it back. We can easily expand that visit to all the pages available on the web, but we will have to process the data a bit, but nothing more that cannot be automated in an hour.
The only problem with web scraping is that it exists in a kind of legal void, and some people will tell you it is not allowed and some people will consider that as long as you access the webpage in the same way as a human would, there should be no problem. My recommendation to avoid problems is to use an API if the webpage provide one, and if not ask them for permission.
At the end we will have a little program that can grab the information of every magnetic core available in all distributors in minutes. Maybe writing this code will take more time than just doing it manually, but we will have it automated forever. We can run this program every day and have up-to-date stock information.
Actually, this is a part of a little Python script that I wrote as part of a project, and can be found here. It reads all the available ferrite cores in the manufacturers Ferroxcube, TDK, Fair-Rite, and Magnetics; and it complements that search with their stock in Digi-Key, Mouser and Gateway. It processed 4872 different cores last night.
For this particular case, I used Digi-key's and Mouser's API, which complies with their Terms of Use, and for the rest I asked for permission (Gateway even gave me a endpoint to access all their data comfortably)
If we were to combine this automatic search with an algorithm that is able to process them and select the best one for a given design requirements and operating points, we would have the first step towards really automating the design of Magnetic Cores. Well, dear reader, dream no more, that is what I have called the Core Adviser Project. A software designed to give you the best magnetic core for your topology that is available online right now, with a runtime under 2 seconds. Coming Fall 2023.
Does it mean that the magnetic core that you chose by manually lurking the web is worse than the one my algorithm chose? Not axiomatically. But probably yes, as I don’t think a human can process almost 5000 cores, calculating the core losses, making sure that the coil will fit, assuring its existence and instant availability.?
So yes, my magnetic core will almost 100% be better than a manual section. Because of Software.
Until next time!
Freelance senior electronic and software engineer
1 年Speed would be nice especially when the simulation requires 1 second CPU time to calculate 500ps.
Founder at OpenMagnetics, a Free Open-Source toolbox for designing inductive components
1 年Some of you wrote to comment about the legal aspects of web scraping (and you are right), so I would like to add some comment about that regarding the Core Adviser Project. The script I shared is using Digi-key's and Mouser's API to access their data, which is complying with their Terms of Use. For the rest, as I added to the article, is always better to as for permission. Gateway Electronic Components Ltd even gave and endpoint that I could access their data more easily!
Technical Manager Southern Europe TDK-Lambda
1 年Nice! So….waiting fall 2023!