 Great, thanks Phillip. Hello everyone. My name's Derek Kozell. I work with the Guinea Radio Foundation these days, mostly on the community side, but I do enjoy coding. And when the call for papers went out, or call for presentations for this, I had actually just started my PhD, which meant I was completely clueless. But I knew it was going to be about power amplifiers, and I knew that it was going to be about efficiency and linearity, and so I was like, okay, what don't I know that I should rapidly learn and digital predistortion ended up being that topic. So this presentation is basically the summation of the last couple of months of me messing around with Guinea Radio and messing around with the theory, trying to understand it, and hopefully I can share that with you. I always enjoy bringing up a hardware, more a hardware-centric topic in the SDR Dev Room because we all are using hardware if we're actually trying to get on the spectrum. And so often we just treat that as a complete transparent layer that says, I have a simulated signal. That's perfectly what's going to come out the antenna, and that is never, ever true, and it's great when we can actually try and do something about it. So what is digital predistortion? It's a technique for improving the linearity of power amplifiers. Amplifiers in general and systems in general, but the biggest problem tends to be power amplifiers. Ideally, you have this amplifier and you want the output signal to simply be a larger version of your input. But semiconductor physics basically says you're never, ever going to get that. If you're operating at a low power, maybe you'll be close, but there's a lot of reasons why you want to get that higher power. So if we can try and predict the errors that occur in the amplitude, the frequency and phase, maybe we can try and offset some of them. And this is a plot of a very typical result. If you ever read a paper or check out somebody's repository. This is almost always the image you run across. And what we're seeing here is the green signal is the original input signal. And the blue is what happens if you then put it through like a 10 watt amplifier running right at the limit and say, you know, oh yeah, it looks great on the outside. And all of a sudden your signal to noise ratio has really fallen quite significantly. But if we say, okay, we know this is going to happen. We're going to make some either measurements or guesses about how we can fix this. Then you can get the red signal. And we see that the signal to noise ratio has improved quite a bit. It is a little worse than the input. The math errors do accumulate and our estimate is only so good. But it's a significant improvement. So what's the high level overview? Pretty much what we have is at the output we want to have a perfectly linear signal. We want to say what goes in just gets bigger and comes out. I'm going to talk about why this is the shape that you get out of a power amplifier. As you increase the power, it's probably a very familiar term as the 1 dB compression point. As you drive your power amplifier up, eventually when you increase your input signal by 1 dB, it's just not going to go up by 1 dB. First it's going to be 0.9. You probably don't notice. But when it starts being really significant, that error accumulates and all of a sudden you're getting this shape here. So what we want to do is at the input, just increase the amount of power a little more than we think we need. So if we say we want one more dB, we put 1.5 dB higher power. And in the end, hopefully all the math works out. So why do we want to use DPD? I'm going to say DPD when I mean digital predistortion because it just rolls off the tongue quite a bit better. We want to get as much power out of an amplifier as we can. Personally, when I buy a 100 watt amplifier, I don't want to use it at 50 watts because that's where the performance is good. I want to use it at 100 watts. And also, if you're just throwing away half of the capacity of the device, that can be quite expensive. As a hobbyist, maybe you care because your budget's really small. As a company or as a business, you care because that's part of your budget. So we drive it as hard as we can basically and we drive it up to this point. So this is the 1 dB point here basically the theoretical response and the actual compression. We drive it up well into that region and as we look at newer and newer transistor technologies, we're actually seeing that this curve is getting even softer. You know, you start operating up into like the 3 dB compression point and that's considered standard operating. And also, the power amplifier efficiency is much, much, much better if you're operating near the limits of your device. I didn't throw in a plot because I couldn't find a good one that didn't end up getting into the nitty-gritty details. But, you know, we're not talking 5% efficiency decrease here. If you back off so that your signal is only staying in this region, you could be losing, you know, half of your power efficiency right there, if not more. I do have these slides on the transistor theory. I will go through them. They're mostly meant to be a reference for people coming back to the slides later. So don't read too much into the slides. Or it might be very familiar for some people here. The most common transistor used for these high power amplifiers these days tend to be field effect transistors. This is a voltage-controlled device. So the voltage at the input is going to change flowing on the outside. So we have a gate terminal, which tends to be our control terminal. We have a drain, which generally ends up being attached to our power supply, and is also our output point. We'll see that on the next slide. And then the source, which tends to be grounded. So by changing the voltage at the input, at the gate, we're going to change the amount of current flowing from the drain to the source. This tends to be a pretty typical simplified circuit. As soon as you start designing these, you realize there's about 80 components on either side of these, but we can see here, again, the circuit from the previous slide, the transistor, and the drain has a capacitor that's decoupling it from this power supply rail, and we're getting a voltage at the output. So that's the signal outwards. And basically what we're doing is we have the input signal, we're changing the gate source voltage, and that's producing a change in current at the output. And as long as the slope is resistor, you get an amplification. But we can also, even from this slide already see, this curve, this transfer characteristic, it's not a line, and it never is. This is kind of a different way of looking at it. Again, don't read too much into the details. It's meant to be kind of an overview of why is this a problem? Where do we run into these problems? Again, what we're looking at here is the current at the output. This is actually as a function of the drain source voltage. So that power supply rail that you're putting in. But each one of these lines represents a different control voltage, the gate source voltage. So we're going to be actually jumping basically from line to line to line here as our control input. Which is why we end up operating on a line here. And it looks fine in the middle. We can get a very, very linear response because we're operating in the saturated point of the transistor. You start seeing, ah, we're actually going to be in the linear region and we're not getting the current we want there. And as you get down to the bottom, it's not really shown on this graph, but you start running into problems when you get into cutoff. There's just not enough voltage to make the transistor do what you want it to. You start ending up with these soft knees in the curves. So it looks mostly linear, but what are we getting? We're getting distortion. Our ideal transfer function would be something like this, where the output voltage is just the input voltage scaled by some constant. Um, and so, yeah, A is the voltage gain of the amplifier. In guinea radio, I set up this very quick test setup. One of the most common ways that we end up measuring distortion is just by putting two tones in and seeing what comes out the other end. I, the only new block here, if you're familiar with guinea radio, is the configurable PA block, and I'll walk through that more later. But basically, what this is saying is we have a voltage gain of 10. So whatever comes in at the input is just supplied by 10, nothing else. And then I always like adding noise to these, because otherwise you end up with overly ideal results. Um, and we have controls for tone spacing and tone amplitude. Um, they're evenly spaced around the center frequency. And this is what we get as our, um, output result. And I'm happy to say this actually does match up with, uh, what I hoped it would be. I realized I hadn't measured this before the presentation. We're getting about a 20 dB gain here, which is exactly what we would expect by a 10x voltage increase. Um, that's very reassuring. And we see that, you know, the noise has been amplified. Our signals of interest have been amplified. Perfect. We're in an ideal function. But that's not what the transfer function ends up actually looking like. Instead, we have these extra terms. And it turns out that you can model this function very well just by having a power series polynomial. I won't go into why that's a really natural, uh, function, but it turns out that a lot of DSP and particularly the Fourier transform make this a fairly natural approach. And it does fit the curves quite nicely. So we see the linear gain a1 here. So this is the a from the previous equation. Then we've added on another one, a2, which is going to multiply the squared function of the input. And a3, which is in one words, to infinity. Um, and pretty much if you've let a computer just try and fit this without any constraints, you will end up with, you know, 90 terms here. And that, that's just not something we can really compute realistically on a computer with any sort of performance. Uh, just as a, and note here, this is a behavioral model. We're not trying to simulate the circuit at all. We're just saying this is what it looks like. You know, this is a, the behavior of the model, not the physics that are underlying it. And it only depends on the current input value. That'll come into relevancy right at the end of the presentation. So second order distortion, let's just look at what happens if you take the input signal, multiply it by some constant, and then multiply it. I, this is the interesting term here. The result is a tone at twice the original frequency. So we're generating a second harmonic. We don't have a mixer, we just have an amplifier, but we're getting a second harmonic out. Um, that was a really fun connection for me to make, because I always knew that mixers were just highly nonlinear devices that have been optimized to function as, as mixers. I, but they're using exactly the characteristic here. They just have a very high, um, they, they're combining terms like this. Cubed, we're getting a term that's at the fundamental frequency and at the third harmonic at three times the fundamental. Uh, so that's an interesting takeaway. Our third order distortion is actually contributing back power on our original frequency. Um, there is going to be a phase term to later. So we're causing phase distortion on our fundamental signal due to these nonlinearities. Um, now the even order distortion didn't produce a tone near our, near our passband. So I'm really glad that these are getting handed out, um, because they make a great prop for me today. If you have a power amplifier like this, that's the power amplifier and a filter, you're throwing away all of those second harmonics, the third harmonics, all of the terms that, um, you're getting here. The only ones that are going to be a relevance are the ones that fall quite near to our fundamental frequency. So let's just throw away all of the even terms. And this, this is a simplification that gets done basically with every pre-distorter and most power amplifier, most transistor models when you're using them for, uh, amplifiers. And just to completeness, here's the fifth order and we get the frequency, the third harmonic and the fifth harmonic. X. And it's omega t, I swear. Um, fixed slides will be up later today. Um, so let's go back to our two tone distortion. Now we have a better model of our transistor. It has these non-linearities. Um, so let's put two tones into it. You know, omega one, omega two, they're going to be very close to each other in frequency. Um, and the third order distortion causes uh, here, basically two frequencies. Uh, two times, you know, the first tone minus the second, two times the second tone minus the first one. So I, yeah, the fundamental tone will be distorted by all the odd power, like I mentioned, and we'll get some indifference tones. And they're scaled by some constants, um, not particularly, uh, important in the details, but you can work through analytically just all of these terms and, and get a good result. I love this picture. Um, and I love what the projector is doing to it. Uh, it's a star field. Um, so what we're getting is, you know, we look at the fundamental tone here. That's our ideal result. We're actually getting a little bit of power from the third degree and the fifth degree. So this is, this is the power contributions stacked up on each of these tones. And you can see that's not only true of the fundamental, it's also true that this is going to be the third order, the primary third order distortion, but it also has a contribution from the fifth and then it, the fifth is standing alone here, but you would also get like the seventh order and the ninth order if you continued on. I just love that, love that picture. I think it's really well composed. So if we put this into the new radio, this is now our input signal. We have this basically the same output power on the fundamental. We will get a little bit of extra contribution and we're seeing the third order plus a little of the fifth and the fifth order and I didn't include a seventh so it's, it's just there. Um, but I'll quickly swap over and we can run this live. Uh, maybe? Yes. Wonderful. Interesting. Um, so we see if the tone amplitude is low enough, it looks basically like a completely linear system, but as we start driving that output up higher and higher and getting better and better energy efficiency, we get the intermodulation tones. Apparently it really doesn't like this. Um, and I'll just try and drive it really high one. Okay, well, so you can see here we're getting even more terms there. And so an interesting takeaway from here is that these, the amplitude of these intermodulation tones map directly to those coefficients that I, we have. So if this will cooperate, I'll open up the power amplifier and it won't. No? Well, I'll just describe it then. So on the configurable PA block parameters, we have the alpha coefficients. So that, uh, number that we were seeing in the equations in the uh, slides. You can enter each of those up to the ninth order. Ah, yeah, okay, so they're called beta here because it is actually mapped on the distortion side, but it's exactly the same math. So we have a beta one for our fundamental frequency, third order, fifth order, seventh and ninth order distortion. See if it likes this better. Uh, five. It does. Interesting. So yes, so how do we determine these coefficients? You have a power amplifier like this and you can be absolutely sure that probably not tonight, but sometime in the next week I'll be putting this onto an SDR, driving it quite hard and seeing, you know, can I create a model of this that works quite well? Uh, and if I can, I'll post it on Twitter. Um, so we need to determine these coefficients, the alpha one, three, five, and as many as you think you need. Uh, the common approach, because I, finding these, finding these, the common approach is to put in a single test tone at very low amplitude, at basically the minimum amplitude that your expected input signal is going to be at and sweep that to the maximum amplitude of your input signal. And ideally you'd see it traversing this perfect line, the perfect linear response of input voltage to output voltage. What you actually get is that curve that we saw. And then you can use, as this is called an AM, AM plot, amplitude amplitude plot. And the general approach is to use something like this, which means squares optimization algorithm to estimate those coefficients. Uh, I will just in passing say that if you work through all of the math here to determine these coefficients, you can gather all of the terms together and say, you know, I know that this here, if I mention the power level, it is this percentage, the alpha one, this percentage the alpha five, and so you can directly derive those coefficients, just from a single two-tone test here. And also if you have something like this, you can see that the ninth order isn't actually contributing anything meaningfully, because we don't have a spur here. So that also tells you how many terms you need to represent your power amplifier. Um, which is fun. Like I said, it's also going to distort your phase. I'm a little suspicious of the actual details of this plot, but the general trend is there. We see that as you increase the amplitude, it's the actual phase, you know, if you kind of estimated that, the actual phase is, um, fairly linear, but it's sloped as you go through. So if you apply DPD, the idea is to, you know, take that slope, subtract it away, so your input signal would actually look like that, and in the end you would just get a zero-degree phase difference across the amplitude. Um, the way you build that into the model is you just make the coefficients complex. So if you look at the flow graphs, which will be available for download, um, you'll see I'm using NumPy with the complex. And so the original ideal model was just 10 plus J0, and the non-ideal has phase shifts to it. Uh, this is going to time out pretty well. Pre-distortion, like I said, uh, the idea is that we're going to change our input to match out the output. We're going to be limited by the maximum amount of power that you can actually supply at the input. You know, if you have only 10 dBm, maximum output of your SDR or of your transmitter, you just can't, you know, all of a sudden put out the 30 dBm or whatever to hit this point. Instead, you're going to be limited to here. So we can operate and fix basically the errors up to this point. Um, the maximum correction point right here. Uh, I guess they're saying P saturation, but there's going to be a limit to how much you can correct. So inverting the transfer function, we have that great Volterra series which tells us it's going to be low by this much. I- Ideally, you'd have a function that just tells you you should be high by this much. Um, you can do this analytically or algebraically, but it becomes very lengthy. So again, people tend to use training algorithms. So they'd sample a bit of the RF output, demodulate it back down anti-aliased it, all the stuff you would do in a normal receiver. And then you'd have some DSP here that's comparing the output signal to the desired input and saying we have an error, we're going to adjust some of the coefficients, we're getting better, we're going to adjust a bit more, and it stabilizes. Um, so we're going to indirectly learn what the amplifier is doing. The direct learning method is we know what the PAMP power amplifier is doing, we're going to figure out the function, and we're just going to have a lookup table here. Um, it's a canoe radio blocks. Uh, this isn't just a pure theory thing. Uh, there are differences out of treatment and he published a paper in 2016 about it. Um, these blocks are available on Github, Shrikant, Pagadari, and it includes some OFDM test code. So this is an image from his paper and you can see that image that I posted at the beginning, the same sort of thing. Um, the blue all the way down here is his ideal signal. Uh, and then he filters it just to try and get rid of uh, um, yeah, so I think this blue line, the blue dotted line here is the original signal put through the power amplifier, we see it's going above his spectral mask. He tries filtering it, that doesn't do it, um, and so then ends up digitally predistorting it and filtering it and gets it below the mask here. And so that's quite a considerable improvement, over 20, 25 dB worth of signal to noise ratio improvement. Um, this is uh, for full band, so if you just have like one signal or you want to predistort everything in your pass band, um, this is a great place to start with that. Uh, this was a really interesting find and I didn't appreciate it in the beginning. This was some work done by Chance Tarver and Mahmoud and it was published in 2017 and it's sub-band. So he's taking a look at what happens if you have a couple different like LTE signals all in the same band. Some of those modulation products are probably going to be outside of their pass band. It's just going to get filtered away anyways. So let's not spend any time computing, uh, you know, doing the math to try and solve that. But, uh, let's say this is sitting in, you know, for argument's sake, like the GSM spectrum or something, something that you really, really had to not have any any spurs in. This allows you to just say, I want to remove this intermodulation product and so you only do the computation for that. Uh, this also included the power amplifier model that I've been using for a while now, uh, and a full indirect learning model as does the previous one. Um, so it has all the test code that you could actually hook up to a USRP, put a power amplifier in, and if you could figure it out, uh, train your modeling and have this work. So feature plans. Uh, I've talked to the authors of both of these over the last couple months trying to understand it. Uh, there's a distinct lack of documentation, um, which he fully, fully puts forward and says, this was for the paper. The paper's great, and I agree the paper is quite readable. Um, but the actual blocks themselves don't have any documentation. Um, the authors of both are agreeable to merging this into a single out-of-tree module, restructuring it so they have common interfaces, you know, common documentation. Um, using the GNU Radio OFDM test blocks rather than just shipping binary files, uh, which is what Chance did. Um, and then we'd be able to do like a full loop back and show you, ah, the error vector magnitude of this signal can be improved by the predistortionist, by this much. All the polynomials so far have not had any memory, so you end up getting thermal effects or capacitive effects on a power amplifier that say that the output is not only dependent on the current input, um, it changes over the operating conditions. There's lots of work, I already published on this, it's fairly to add that. Um, and I've been talking in general with some people this is not confirmed, but possibly this might be one of the project ideas listed for the Google Summer of Code for GNU Radio. Um, as I said, I myself am a PhD student now, I'm working on power amplifiers, so chances are I'll be contributing to this in one way or another, whether it's the power amplifier model side or being the guy who ends up doing some of the DPD. Uh, thanks in questions. Um, I always post my slides up at derekcozell.com I'll also put the three flow graphs um, up there and yes, send me questions, my email address and stuff is up there, so that'd be great. Alright, we've got time for a couple of questions. Yes, same operation. I out of the, as the end result of the lookup table, and so um, please tell me I put one of the slides in. I, if you have this measurement, you just have complex coefficients in the lookup table, and so instead of doing one, multiply you're doing two. Um, and it, it works, yeah. I, you get basically the same accuracy on both of them, so I, alright, that's, that's going to be it for questions because we need to start switching, so maybe hang around and talk to you.