Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Frequency response using SPICE

Status
Not open for further replies.

slackjack

New Member
I've made a spice netlist of a circuit I am designing. The input to the circuit is an AC signal source --> v1 1 0 dc 0 sin(0 34 60). Well I can do a transient analysis on this easily. But I also want to see what happens at the output as I vary the frequency of the AC signal source. Unfortunately using .AC simply doesnt work (to vary the frequency). I suspect that I defined my signal source incorrectly to be used with .AC.

Please help.

Thanks.
 
Replace the variable in question with {AC}
Not .AC
.AC is the spice directive for AC measurement. If it doesn't have a value with {AC} in it in the circuit it has nothing to vary. From what little I know only voltage/current sources can be asigned {AC} Voltage/frequency/current
 
Last edited:
slackjack said:
I've made a spice netlist of a circuit I am designing. The input to the circuit is an AC signal source --> v1 1 0 dc 0 sin(0 34 60). Well I can do a transient analysis on this easily. But I also want to see what happens at the output as I vary the frequency of the AC signal source. Unfortunately using .AC simply doesnt work (to vary the frequency). I suspect that I defined my signal source incorrectly to be used with .AC.

The .AC directive tells the simulator to perform an ac analysis in a frequency interval you have to specify. For example: .AC DEC 101 1 100k for the interval [1Hz, 100kHz].
You need to define an AC source, for example V1 1 0 DC 0 AC 1
By the way, which program are you using? if you get LTSpice from linear.com you can enter those parameters without editing the netlist manually.
 
Thanks for the quick responses guys.

Sceadwian said:
Replace the variable in question with {AC}
Not .AC
.AC is the spice directive for AC measurement. If it doesn't have a value with {AC} in it in the circuit it has nothing to vary. From what little I know only voltage/current sources can be asigned {AC} Voltage/frequency/current
I'm a little comfused when you say "Replace the variable in question with {AC}". Does this mean I have to add an AC component to v1?
The .AC directive tells the simulator to perform an ac analysis in a frequency interval you have to specify. For example: .AC DEC 101 1 100k for the interval [1Hz, 100kHz].
You need to define an AC source, for example V1 1 0 DC 0 AC 1
By the way, which program are you using? if you get LTSpice from linear.com you can enter those parameters without editing the netlist manually.
I'm using spice opus. So I see that I dont have a source defined with AC. Is there a simple way to fix "v1 1 0 dc 0 sin(0 34 60)" while retaining the initial frequency and amplitude?
 
Last edited:
slackjack said:
Thanks for the quick responses guys.


I'm a little comfused when you say "Replace the variable in question with {AC}". Does this mean I have to add an AC component to v1?

I'm using spice opus. So I see that I dont have a source defined with AC. Is there a simple way to fix "v1 1 0 dc 0 sin(0 34 60)" while retaining the initial frequency and amplitude?
v1 1 0 sin(0 34 60) AC 1
 
Watch out for the difference between, peak, peak to peak and RMS voltage. SPICE uses peak voltage, if you want RMS then multiply it by √2, if you want peak to peak then multiply it by 2.
 
Hero999 said:
Watch out for the difference between, peak, peak to peak and RMS voltage. SPICE uses peak voltage, if you want RMS then multiply it by √2, if you want peak to peak then multiply it by 2.

I'm designing a power supply so everything is already in peak :D
 
Ron H said:
Did you use the complete .AC directive, as posted by eng1? Otherwise, it won't work.

I sure did. I get in excess of 6000v (which is absolutely not right) when I vary the freq using .AC . I get the same output with or without AC 1 added to my source.

Code:
PowerSupply

[b]v1 4 5  sin(0 34 60) AC 1[/b]

D1 4 2 1N4007
D2 0 5 1N4007
D3 5 2 1N4007
D4 0 4 1N4007

c1 2 0 1000u
c2 2 0 100n
cout out 0 100n

radj adj 0 5k
r1 out adj 240

x 2 adj out LM317

.include parts.lib
.control
set units=degree
destroy all

tran 0.01ms 100ms
plot v(4,5) v(out)  vs (time*1000)

[b]destroy all

ac dec 10 60Hz 7000Hz
plot ac1.v(out) vs ac1.frequency[/b]

.endc
.end
 
Last edited:
If you want to simulate line rejection, get rid of the bridge and replace it with a battery of whatever DC value you want, with an AC source "in series".
v1 2 0 DC 32 AC 1
Run an AC sim (AC dec 100 10 10k).

Or, run a transient sim:
v1 2 0 sin(32 0.5 120).
 
Ron H said:
If you want to simulate line rejection, get rid of the bridge and replace it with a battery of whatever DC value you want, with an AC source "in series".
v1 2 0 DC 32 AC 1
Run an AC sim (AC dec 100 10 10k).

Or, run a transient sim:
v1 2 0 sin(32 0.5 120).

Doing the above changes gets me the same result as if I were doing "v1 4 5 sin(0 34 60) AC 1"

Code:
v1 2 0 dc 34 ac 1



c1 2 0 1000u 
c2 2 0 100n
cout out 0 10u

radj adj 0 5k
r1 out adj 240  

x 2 adj out LM317

.include parts.lib
.control

destroy all


ac dec 5 10 10k
plot v(out)

.endc
.end
:(
 
I ran an AC sim in LTSpice. Netlist, schematic, and Bode plot are below.
Code:
* C:\Program Files\LTC\SwCADIII\lm317 sim.asc
R1 out N002 240
R2 N002 0 5k
V1 N001 0 34 AC 1
XU1 N001 N002 out LM317
.lib lm317.sub
.ac dec 100 10 1Meg
.backanno
.end
The response peak can be minimized by adding >10uF from the output to GND.
I don't know why your results are so screwy.
 

Attachments

  • LM317 AC sch.PNG
    LM317 AC sch.PNG
    7.6 KB · Views: 235
  • LM317 bode plot.PNG
    LM317 bode plot.PNG
    11.7 KB · Views: 220
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top