top of page
  • ZackW

Building a Royer Oscillator

Updated: Jan 18, 2023

This was a hardcore learning project, and turned out to be essentially a study in magnetics, SPICE, and research methods. Parts of this post are a bit naive in retrospect, but are included anyway to demonstrate the learning process. I will have other blog posts that don't include quite so much of my own thought processes.

 

Introduction & Inspiration

There's a guy on Twitter - Rue Mohr - who does a lot of interesting little projects and posts about them in threads. One of his endeavors in particular caught my eye since it involved using an interesting property of magnetic cores to make an oscillator. He was using it to make a voltage converter with a respectable 24W power output, voltage converter and oscillator all-in-one. I wanted to build one in order to better understand magnetic principles, since I've been relying on essentially heuristics up till now when using different cores. I also just hadn't heard of that kind of oscillator that could run a load all by itself before, and as it turns out they are a very useful circuit.


Anyway. I'm new to them, but as far as I can tell the basic principle of a Royer oscillator is that when the magnetic core of a transformer enters saturation it stops being a very good transformer - allowing you to sort of back-drive it. The secondary winding loses its ability to maintain a certain current, and that property can be used to switch the gate or base of a transistor. Another way to say this is that there is a temporary positive feedback fed to the switching elements. Magnetic saturation depends on several factors, but the basic concept relies on the magnetic flux density reaching a point that the magnetic core can't "hold" any more.


Testing

The first core I'm playing with is a "binocular" core, I think typically for RF applications. They have a very high inductance, higher than what you often get for normal toroidal inductors. This test core is a BN43-202, and the first windings I've put on it are just 18 turns (18T). In the image below, the core is fed a "square" wave from a IR2011 driver, at roughly 10kHz. The point at which the blue voltage (representing the current, since it's the voltage over a 1 ohm resistor) starts to rise exponentially is where the inductor has entered saturation. In this case, it's about 100mA. From the start of the driving waveform to saturation is about 30us.

Rue Mohr uses a sort of normalized variable, he says "its sort of the inverse of the saturation flux times the area". This will be called `KB`. The formula for calculating it is:

`KB = N/(t*(2*V))`

For me, N=18, t=30us, and V=0.1 I think. I don't understand this yet, and so will try and go into it further. The basic idea is still to figure out when the core saturates, or essentially the maximum amount of magnetic flux that the core can 'hold'. I think this can also be expressed in flux density, which is "the measure of the number of magnetic lines of force per unit of cross-sectional area". I know some manufactures of cores actually put these values in the datasheet, or at least values that make it possible to calculate the maximum flux density. I found a couple places to look, notably Rowaves has the same core and links to fair-rite for values. Something to examine in the future would be Micrometals it looks like, they have a lot of different core materials that I don't recognize.


As a reminder, `B` has the units of gauss and is a measurement of flux density. A tesla is also a unit of magnetic flux density. H is often measured in oersteds, and represents the magnetic field strength. Also sometimes measured in amp/meters. Figuring out when a core saturates is sort of complicated I think, but can be approximated without fully understanding the subject. First of all, we might be able to tell graphically from this provided chart:

Theoretically, the maximum gauss that the core can sustain is about 2200, before it flattens out. I'm greatly regretting picking the binocular core as an example piece to work on, since it doesn't provide normal and easy to follow magnetic paths. Easy for me to follow, that is.


Trying to Figure Out The Physics

I worked on this problem with my brother-in-law Josh Barksdale for a bit, he's generally better at math and figuring out how equations can be made to describe the physics I'm trying to figure out. Our first approach was to use the solenoid equation from "icalculator" - example 4. It gives the equation for the gauss the center of a loop of wire to be:

`B = N*(u_0*I)/(2*r)`

Notice that this uses the permeability of free space (`u_0`), and requires the radius of the position in the loop that you are calculating the gauss at. (Actually these equations are in teslas, not gauss). This means the gauss in this example would be inversely proportional to the radius at which you are measuring. In using this approach, we go and look at the point at which `B` seems to no longer rise linearly with `H` in the graph above, which for the 43 mix 'binocular' core, seems to be around 2500 gauss. So, at this point you can solve for I (current) and theoretically have an `I_(sat)` value to work with for saturation-based circuits like a Royer oscillator. This is a bad approach, but we followed through and Josh put together the equation finding `I_(sat)` with ~80% of the core being "saturated" past 2500 gauss.


`i_(sat) = (2*sqrt(0.8)*R*B_(sat))/ (u_r*u_0*N)`

`R` -> radius of the torroidal cross-section [m]

`B_(sat)` -> datasheet saturation flux density [T]

`u_r` -> core relative permeability

`u_0` -> permeability of free space [N/A^2]

`N` -> number of turns

`i_(sat)` -> saturation current [A]


Some experiments were done, trying to figure out if a few different cores would saturate when predicted. They did not. And actually the test circuitry for measuring saturation is a challenge in and of itself. I will cover some notes on that in a section below.


After figuring out the first approach was probably doomed, we moved on with further research. In example 5, a solenoid, the equation is given as:

`B =(u_0*N*I)/(L)`

Note that the radius variable is now gone, which I believe implies that the magnetic field density is about constant in the center of the solenoid. I'm not sure why this is, but this is probably a bit more relevant for our project which involves wires wrapped like a solenoid around toroidal cores (aka donut shaped). Not all cores are toroidal though, and I would sort of like to know the equations that you use to figure out the equivalent gauss in complicated cores. I'm sure integrals would be involved.


I also happened to receive a relevant book as a Christmas gift, which turned out to have most of the answers. The book is one of the holy grails of electronics, "The Art of Electronics: The X Chapters"! Their section on inductors covers saturation, and gives this handy equation for saturation (at DC, eq. 1x.16, see [1]):

`I_(dc) >= (B_(sat)*l_e)/(u_r*u_0*N)`

The magnetic path length `l_e` is often given by the manufacturer of the core, and `B_(sat)` is also often shown graphically. I've seen this equation a few times after more research, and so it's probably more or less correct. I'm not sure how helpful this equation is for calculating the period of something like a Royer oscillator, since A) the oscillator enters saturation and continues forward some amount, and B) It's not clear to me where on the saturation curve `B_(sat)` is supposed to be.


For easier calculations and simulations I found an FT50-43 core, a fairly common one in my experience. It's a bit easier to find the magnetic path length for this guy, and hopefully it will be fairly saturable. It's the same material as the previous test core, but instead of a binocular core it's a toroid. `B_(sat)` looks to be about 2200-3400 (0.22-0.34 tesla), but again I'm not sure which point along the curve counts as "saturated". The chart appears to the be the same one as the BN43-202 core, shown above. Anyway, with something like 20 turns the equation should work out like this:

`I_(dc) >= (B_(sat)*l_e)/(u_r*u_0*N) = (0.3 * 0.0295)/(800*u_0*20) = 0.440A`

From the book, `l_e ~= 2*pi*r`. I'm also fairly certain the `u_i` value given from Fair-Rite is the same as `u_r`, especially given this short brief by a guy named Robert Weaver. Actually `l_e` was given by Fair-Rite as well (2.95cm). It seems like 440mA was a lot more than I saw in testing the core, but my testing apparatuses are all flawed and might have been understating the saturation current. I will be building a more powerful driving circuit soon, with highside & lowside FETs, and among other projects I will revisit this one and try and measure some more saturation currents at various frequencies.


I feel like this video deserves to be mentioned here - he makes some things clear that weren't clear to me before. First off, he concludes that the flux inside of the toroid would be `B = u_0*I*n` - which is delightfully simple. The thing that really surprised me was the fact that he also finds the flux in the center and outside of the toroid to actually be zero - I sort of just assumed that it would be low. And it's not zero by merit of the high permeability core, it's zero because of the shape the windings make - so it shouldn't matter whether or not the core enters saturation or not. I think. That sort of does away with the notion that flux starts to "leak out" once the core enters saturation, and that the leaky flux just isn't coupling to other windings.


More Physics

For me, and I suspect many other people, the best way to understand how to design circuits is to really understand the related physics principles as much as possible. For this research project I would really love to be able to examine flux density in various core configurations, and how it relates to current and other variables. This might be possible with a lot of elbow grease, an excellent understanding of Maxwell's equations, gross oversimplifications of the bodies involved, and many hours of work. After a bit of mind-liquefying research, it looks like there are analytical (simplified versions for specific shapes) methods out there, but a really common approach is to use some kind of numerical method. Indeed, a good search term for studying these things is "computational electromagnetics". And for open source programs that use different methods to accomplish these simulations, I found this post with a good overview.


For me, the programs of interest are primarily:

  • OpenEMS, it uses FTDT and you can interact with it using Octave and python. Seems like a smaller/simpler project, potentially doing a lot less work for you but being easier to understand at the same time. Lots of links are broken at the time of writing, use the wayback machine to access more tutorials. There are also examples in the github code if you look hard enough. I couldn't get the python bindings to install correctly.

  • ElmerFEM, uses FEM methods, has a GUI and some circuit specific tools. Also has a ton of lectures/presentations available on Youtube if you're willing to wade through them. Difficult to install on Ubuntu 22.04 at the time of writing. Examining the various manuals, tutorials, and github test code is recommended.

If I were more time-smart, and rich, I would just use one of the commercial packages. There's several available, at least one of which integrates with Solidworks and looks to be pretty easy to use.


I spent a good bit of time messing around with ElmerFEM, specifically because it has a GUI and is therefore a bit easier to stab at. I followed a few thermal tutorials successfully, and even got it to do some interesting voltage gradients, but the level of understanding required to set up magnetic simulations escapes me. I also started to run into problems with mesh creation, seemingly simple meshes would eventually crash the program as it tried to process them. I didn't get the python bindings for OpenEMS working, and so didn't really play with it.

Thermal simulation results from ElmerFEM displayed in paraview

Measuring `I_(sat)`

The biggest problem with trying to measure `I_(sat)` is probably that you need to keep a constant voltage over the inductor while the current rises. The flatter you can keep your voltage, the more accurate your current will indicate the behavior of the inductor (as far as I can tell). A guy on Youtube runs a channel named "RF Man Channel", and he has a pretty good video on the subject. His approach is to do a single low-side switch to pull more and more current through the inductor and see when the current stops behaving linearly. As a quick refresher, the inductor formula for current is:

`i = 1/L int_(-oo)^(t_0)v dt`

Hence if `L` remains constant, and `v` remains constant, the integral should indicate a linearly rising current as time increases. You can think about most measurement approaches as keeping V constant, and watching for when that `L` value changes since it will be a function of current. (So, `L(i)`).


The approaches I've found that I believe are capable of measuring `i_(sat)`:

  • Subjecting the inductor to a square wave - I did this first by using small npn/pnp transistors in a totem configuration, and then with an IR2011 MOSFET driver

  • Attaching the inductor to a constant voltage source and toggling a switch to ground - include a free-wheel diode to prevent massive voltage spikes when the lowside switch turns off. I've done this as well with similar results as the other method

  • Make a transformer instead of an inductor on the core, measure the current in the secondary and primary - increase the current in the primary until you start to see the K factor decrease. I haven't tried this yet, it would be best done with a sine-generator and I don't have a convenient one strong enough. LTSpice hints that a square wave feed would work as well.


I will be building a couple half-bridges soon, and the two kinds I have designed should be able to test just about any reasonable inductor I'm liable to run across. I will attempt to add some more core measurements when I have those constructed.


And actually it should be possible to get a rough idea of `i_(sat)` from a working royer oscillator.


Design Equations

This is my attempt to put together some equations to make these things easier to build.


Time it takes to reach `I_(sat)` given `B_(sat)`, voltage (`V`), number of turns (`N`), magnetic path length (`l_e`), and inductance (L):

`i_(sat) = 1/L V t_(sat) = (B_(sat)*l_e)/(u_r*u_0*N)`

Solving for `t_(sat)`

`t_(sat) = (B_(sat)*l_e*L)/(u_r*u_0*N*V)`

That should be a half-period (inductor enters saturation twice for a given cycle), so the frequency should be:

`f_(royer) = (u_r*u_0*N*V)/(2*B_(sat)*l_e*L)`


So, with the following values for our FT50-43 test setup:

  • `u_r` = 800

  • `N` = 10

  • `V` = 5 volts

  • `B_(sat)` = 0.3 tesla

  • `L` = 4.8 uH

  • `l_e` = 0.0295m

... We get 591kHz, or 0.845us per half-cycle. Which disagrees strongly with both LTSpice & the real circuit. Actually we're off by essentially a factor of 10. And, according to the generic toroids calculator, with 10 turns on an FT50-43 core I should have more like 44uH. With that value, we get a frequency of more like 64.5kHz which is much closer to the realm of possibility. Actually funnily enough it's about in the middle between LTSpice and the real circuit. When I first measured the core, my inductance meter thought it was 4.8uH, but with a good ol' double check it sure enough read 43.8uH instead. Oops.


So, we hopefully now have a fairly generic design equation for this kind of oscillator, which is what I set out to make in the first place. I would like to test it some more, but don't have a lot of time as of writing this blog post! Hopefully I can revisit this again soon, and run further tests to see if my model holds out.


Results

Despite the physics, it turns out these really aren't that hard to build. I have built 2 so far, just out of some fairly high permeability cores I was pretty confident would work based on heuristics.

A FT50-43 Core based oscillator

The oscillator constructed from an FT50-43 core ran around 76KHz, depending on input voltage the frequency would go up or down.


A VGA-cable choke based oscillator

The EMI choke based oscillator ran at a much lower ~10kHz rate. I also noticed that at low voltages (starting around a volt or two) the frequency would be inversely proportional to voltage instead of the other way around like it normally was. The EMI choke also had a roughly 2:1 secondary winding, and in the image the second (lower) trace is from that secondary winding. The oscillator still functioned when the secondary winding was loaded (even loaded heavily), although loading of the secondary winding did result in marked changes of frequency.



What I've Learned

Again, this is always the most important part! In this project I covered a lot more stuff than I was originally intending. I learned a lot about how to read a manufacture's datasheet on their magnetic core, and I also learned about some new magnetics manufactures to look for in the future. I also learned how to simulate non-linear transformers (and inductors for that matter) in LTSpice using the 'Chan' model. I studied Maxwell's equations and got to a slightly better understanding of them and their implications. And, I learned how to build (assemble) simple Royer oscillators.


If I was to draw some more general conclusions from this project, I would say it reinforced using simulations to better grasp the concepts of a certain circuit. To that end I think I should get better at making mathematical models to use math-specific programs like Octave (or Matlab) for simulation, and I should work on improving my skills with tools like ElmerFEM. I think I could have also saved some time by directly studying the first Royer oscillator paper (if such a thing exists) and building something based on that. I spent a good deal of time messing with a flawed MOSFET circuit I had badly copied from a forum user, that probably hadn't even built a saturating magnetic oscillator in the first place. I could have saved that time by getting a better picture of possible circuits before jumping ahead to the physics.


References / Sources Studied:

[1] P. Horowitz and Winfield Hill, The art of electronics : the x-chapters. Cambridge ; New York, Ny: Cambridge University Press, 2020. [2] J. H. Chan, A. Vladimirescu, X.-C. . Gao, P. Liebmann, and J. Valainis, “Nonlinear transformer model for circuit simulation,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 10, no. 4, pp. 476–482, Apr. 1991, doi: 10.1109/43.75630.







605 views0 comments

Recent Posts

See All
bottom of page