# Phase Shifter Multi-State Simulation

Click here to learn an important characteristic of phase shifters if you want to use them in a phased array

Here's a second lesson in crunching multi-state files in ADS

Update August 2022.  We fixed the math that turns the bits on and off, see below..., thanks to Patrick.

On this page you will learn how to create a ADS file that drives a multi-state phase shifter design and crunches out its RMS errors. Maybe we'll even add some Monte-Carlo variations to it one of these days.

Phase shifter designers might want you to think that it takes two months to design a phase shifter. In reality, it doesn't take very long, once you have the files set up. It's just a matter of selecting the best bit topologies, setting their center frequency, hitting the optimize button for each bit individually, layout and EM analysis, then connecting the bits taught in a multi-state file and selecting bit order based on VSWR effects of the individual bits beating against each other. Phase shifter designers probably spend more time on Facebook than they do on the Smith chart!

### Main schematic

Behold the ADS schematic below, it has everything you need. It's not 100% idiot proof, which is OK, because we want to screen out potential idiots from designing phase shifters...

There are three two-port networks in the schematic. Between ports 1 and 2, we have the four-bit phase shifter in its reference state, which Microwaves101 defines as the "electrically shortest" phase state. Between ports 3 and 4, we have the phase shifter that ratchets through all of its phase states, in the example we have four bits, so there are sixteen states. Between ports 5 and 6, we calculate ideal phase states, in this case, 0, 22.5, 45, 90... degrees.

The schematic as shown is impossible to read. If you copy in into a PowerPoint and zoom in it will become slightly more readable.  If anyone has any suggestions for exporting ADS schematic files into a readable graphic image for a web page, we'd like to hear about it. This remains a big challenge that we waste a lot of time on! ### Driving the phase bits

This is perhaps the most clever thing you will learn from this web page... how to create the binary sequence that drives the phase bits in a multi-state simulation. There are other ways to do this of course, but you won't find any described anywhere on the worldwide web.

Before we begin, here is the correction that Patrick sent us in July 2022.

• The sweep of XState should start from 0 and not 1
• The formula for BN should be BN=REM(INT(Xstate/2^(N-1),2). In your example the two-parenthesis close at the end. In my opinion the first parenthesis should be before the comma...

We have incorporated Patrick's suggestions so you can no longer see the original math... but we made the changes in bold red font.

ADS sweeps frequency in normal S-parameter simulations. In this multi-state case, we also need it to sweep sixteen phase states. This is done by variable "Xstate" that we define, which starts at 0 and stops at 15 (for this four-bit simulation), and controlled by the "parameter sweep" token. We also have to preset it equal to a number in the "VAR1" token, this is an ADS quirk which can't be explained.

Xstate is used to control four variables, B1, B2, B3 and B4. These form a binary sequence, and control the four phase bits. B1 is the least significant bit (22.5 degrees), while B4 is the most (180 degrees). These are set up by token "VAR2", and some fancy-pants math which we will get to shortly.  We used the remainder and integer functions to come up with the state table, which is shown below. Note that the table used to start at 1 instead of 0, before we fixed it.

Xstate B1 B2 B3 B4
0 0 0 0 0
1 1 0 0 0
2 0 1 0 0
3 1 1 0 0
4 0 0 1 0
5 1 0 1 0
6 0 1 1 0
7 1 1 1 0
8 0 0 0 1
9 1 0 0 1
10 0 1 0 1
11 1 1 0 1
12 0 0 1 1
13 1 0 1 1
14 0 1 1 1
15 1 1 1 1

Here's the equations for B1 through B4, so you don't have to read that ugly ADS graphic.

Here is Patrick's generic equation for the bit values BN.

BN=REM(INT(Xstate/2^(N-1),2)

And her they are individually, after some simplification.

B1=rem(int(Xstate),2)

B2=rem(int(Xstate/2),2)

B3=rem(int(Xstate/4),2)

B4=rem(int(xstate/8),2)

If you need to modify this for a five, six, or seven bit phase shifter, you don't have to be a member of Mensa to follow the pattern.

Note that if you were to implement this function in Excel, the "REM" operator (remainder) in ADS is called "MOD" (for modulo) in Excel.

Thanks again to Patrick for cleaning this up!

### The rest of the schematic

Bit order is shown when you click into the "Four-bit_PS" element. Here four parameterized sub-circuits are cascaded, with the desired phase shift ("PS") and controlled by the "ON parameter. So, where is the 180 bit, you might ask? These particular subcircuits provide balanced phase shifts in positive and negative direction, so if you want 180 degrees total, you input 90 degrees. This is nothing special, just an accident of birth. By clicking into any one of the phase bits (they all use the same schematic with different input parameters), the high-pass/low-pass schematic is revealed (see below). This high-pass/low-pass bit has equations that calculate the lumped element values from the specified phase shift (PS), center frequency (FC) and system impedance (Z0). The resistors R1 and R2 are used to connect the desired tee network depending on the value of "ON". The upper tee network provides positive phase shift, the bottom one provides negative phase shift. Thus the upper arm is the reference state. ### Multi-state graphs

Now we can see the S-parameters of the sixteen phase states on single graphs. On the left is the return losses, on the right are the transmission losses.

### Here are all of the phase states, nicely monotonic!

### RMS error calculations

Here's the RMS amplitude and phase. Now you can admire the wide bandwidth afforded by the ideal high-pass low-pass phase shifter bits! 