4

Is it possible to alternate between a 0 and 180° shift at regular intervals (say every second) for a sine source in a circuit during a .tran operation in LTspice? (I need to see the reaction of my circuit to a phase shift)

I am using LTspice XVII

c.leblanc
  • 337
  • 6
  • 1
    do you need it to shift through the phases, from 0,1,2,3,4...180? Or a step change, from 0 to 180? – Aaron Feb 28 '23 at 18:22
  • 2
    Can you not generate a sine signal that does this using two sine signals and a changeover switch activated once per second? – Andy aka Feb 28 '23 at 18:24
  • @Andy aka yeap I didn't think of that approach at first but it is close to what I did in the end. I took 2 sine signals, 2 SW switches controlled by 2 square signals with cycle = 2sec, delayed 1 second from each other (one single changeover switch would have been an even easier solution but I didn't find it). – c.leblanc Feb 28 '23 at 19:54
  • @Aaron: it was 0-180 at once :) – c.leblanc Feb 28 '23 at 19:54

2 Answers2

4

The LTspice examples below gives three different techniques.

Circuit A has repeated transitions ad infinitum. It works fine for lower frequencies, perhaps < 1 MHz. Using a faster rise time <= 1 ns for the pulse generator will be better behaved at frequencies above 1 MHz.

Circuit B has only two transitions, but is better behaved at the transition. It will work for frequencies above 1 MHz as well as lower frequencies.

Another option is using an arbitrary piece-wise linear voltage source (PWL option for a voltage source) where you supply a numeric file for the signal.

Adjust the parameters for your case. The example uses a 1 MHz sine wave to see transition issues.

enter image description here

[Edit]
I like Voltage Spike's idea of using a B source due to simplicity (give him the credit if you like this solution).
Example below. You need to mind the rise time of the pulse generator so the phase transition doesn't get damaged. I put in a rise & fall time of \$ 1 \over {frequency \times 1000}\$ which seems to work well.

enter image description here

qrk
  • 7,474
  • 1
  • 5
  • 20
4

One method you could use is a bsource with a function that multiplies the sine wave by -1 or 1 and that signal could be generated by a PWL source.

Voltage Spike
  • 75,799
  • 36
  • 80
  • 208