# Generate a 120 degrees out of phase sine wave

I want to phase shift a sinusoidal by 120 degrees two times (in order to generate a 3 phase signal).

I generated the first sine wave using an internal DAC. The sine wave is offset by 1.65V with a peak of 3.3V at 50Hz.

I came across the below circuit that says is it designed to phase shift from 0 degrees to 180 degrees however in LTspice I am not getting that result.

How do I phase shift a sine wave by 120 degrees?

My circuit is below:

The waveform is shown below:

• "... that says is it designed to phase shift from 0 degrees to 180 degrees." Did it say at what frequency it would achieve this? What's the value of {x}? What phase shift did you calculate for R4 / X? Mar 27, 2022 at 13:22
• @Transistor, youtube.com/watch?v=FHXZ9C914S0&t=157s , this is the video on youtube I saw. The value of X varies from 10 to 10k in steps of 500. Is this circuit even correct? What will you recommend in order to produce the 120 degrees phase shift? Mar 27, 2022 at 13:28
• This smells like homwork. Do you understand how the circuit is supposed to work? How does it cause a phase shift? Mar 27, 2022 at 13:31
• @AnalogKid this is a common emitter setup, that inverts the ouput signal by 180 degrees w.r.t to the input waveform. The C1 and R4 forms the phase shift charactersitic. This allows you to phase between 0 degrees to 180 degrees Mar 27, 2022 at 13:39
– G36
Mar 27, 2022 at 22:01

As the ultimate aim is to generate a three phase waveform, rather than simply shift a sine waveform by 120 degrees, the following circuit may be of use.

The basic idea is to drive a number of time-shifted square waves of the right frequency through a shift register. By summing precise amounts of each square wave, we can eliminate all harmonics except for those at frequencies of the top clock +/- 1.

Some may see it as using too much 'old technology', but it's a very flexible technique, applicable to many more applications than this. Of course if you're already using an MCU, then your 'shift register' outputs could be just a bunch of GPIOs.

For instance, if the clock is 12 x the required output frequency (as the circuit below), it generates the fundamental, and then no harmonics until the 11th, 13th, 23rd, 25th etc. A filter to remove the 11th harmonic can have a very relaxed transition band so can be low order, or in some applications, may not be necessary at all.

The output voltage is very stable, depending as it does on the power supply voltage. The output frequency can be controlled by choosing the top clock frequency.

In the diagram below, the NOT gate round the first six stages of the shift register produces a /12 Johnson counter. This is for a 4018/74HC164 type register where the outputs are delayed only one clock. If you used a HC595 clocking the output register at the same time, the outputs are delayed an extra clock, and the NOT gate has to come from the previous tap.

Starting from a proper RESET, this counter will continue to run correctly. However, it is possible, if some glitch is received, or if the clock/reset timing is not correct, that some illegal states can circulate round the counter. If you want to detect or avoid these, then the input to the shift register could be taken from a /12 counter, or you could use logic to detect illegal sequences and reset the registers.

By choosing where to tap off each output, we can control the relative phases of the multiple outputs. Here the outputs are taken every 4th tap, to give us our three phases.

The resistors are chosen so that their conductance is given by points on a sinewave. For a /12 method it's particularly straightforward, 30 degrees per tap. We therefore have

angle sine resistor
0 0 open
30 0.5 20k
60 0.866 11.55k
90 1.0 10k
120 0.866 11.55k
150 0.5 20k

The resistor accuracy determines the harmonic suppression. For instance you need 1% resistors to give you roughly -40dBc harmonics. It's worth building the 11.55k from a 11k + 560Ω (E24 values).

simulate this circuit – Schematic created using CircuitLab

We can generate the output with ratios other than 12x. For three phase generation, it's convenient to use a ratio with a factor of 3 in it, but even that's not essential. For other ratios, we simply choose the conductance of the summing resistors for the appropriate points on a sine waveform.

• Some may see it as using too much 'old technology' It's an approach that can be emulated using modern MCUs rather easily, with either specialized on-chip peripherals like the IO coprocessor on Raspberry Pico, or a very simple interrupt handler that shifts GPIO registers. I wouldn't call it 'old tech' at all. Thanks to MCUs, it's even more practical today than it was in the days of discrete logic. In mass production you'd use a custom thin film resistor array (think Caddock etc.) or use digital pots to trim 0.5% resistors down to 0.005% or better. Mar 28, 2022 at 9:08
• With an MCU, instead of generating square waves, you can also generate PWM waveforms that have the effective amplitude exactly as needed, and sum them using the widely available and fairly cheap equal-resistance networks that have decent ratio matching. This approach can be in fact emulated directly without the use of external networks by outputting a PWM waveform with more than 2 transitions per period - it's known as The Magic Sinewaves and is well suited for 3-phase generation. Mar 28, 2022 at 9:11
• @Kubahasn'tforgottenMonica You're welcome to add an answer referencing the magix sinewaves article. Mar 28, 2022 at 9:25

The shift-register approach from Neil's answer can also be simulated - see below.

The entire circuit can run from a single 9V supply. The clock could be generated by a CMOS multivibrator. The shift registers could be CD4015 - they have an asynchronous reset which should be applied on startup. The output amplitude can be about 4Vpp before the op-amps start cutting the tops off. With a rail-to-rail op-amp, the whole thing will run just fine from 3V or 5V.

The low-pass filters could be of course better, I just threw some likely values in and the output looks OK, but certainly could be made cleaner.

simulate this circuit – Schematic created using CircuitLab

• Perfect. I found a uC that has three DACs. Going to try and see if the uC can amount the waveforms accurately. Mar 28, 2022 at 11:29
• @JoeyB For your 50Hz application you really only need three PWM outputs and a sine lookup table, and a DMA or interrupt handler to update the PWM setpoints. Three DACs are usually not necessary - once you get to the fidelity that DACs afford, you'll find that MCU DACs have enough nonlinearity and drift that PWM will perform better, especially if you use an external CMOS switch to toggle the filter inputs between two reference voltages. With Magic Sinewaves, you'll need less filtering on the output vs. ordinary PWM. Mar 28, 2022 at 11:34
• " especially if you use an external CMOS switch to toggle the filter inputs between two reference voltages" What do you mean by this? Why would I need to toggle the filtere inputs? Won't I just be sending the PWM output to the filter and take the ouput from the ouput of the filter. Mar 28, 2022 at 14:53
• The PWM output is not perfect: its high- and low-level voltages are noisy and depend on the power consumption of the MCU itself. So, instead, you can use that imperfect digital PWM output to control an analog multiplexer that will switch between two accurate input voltages. The output of that multiplexer (switch) will be an accurate square wave with well-controlled amplitude. Then, when you filter it, the amplitude will remain more stable than if you were filtering the MCU output, whose efficient amplitude can vary. In the end, it depends on how accurate you need the output to be. Jun 8, 2022 at 22:11

Just something I was playing with a while back....