Author Topic: Stepping the amplitude of a two sources for transient analyses in LTspice  (Read 2981 times)

0 Members and 1 Guest are viewing this topic.

Offline ocsetTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: 00
Hi,
I have a mains sinusoidal   voltage source in LTspice, and a DC voltage source.
I want to step them...

AC 254 264 274

DC 1 2 3

...ie so it does
AC=254 and DC = 1V
AC=264 and DC = 2V
AC=274 and DC = 3V

« Last Edit: August 04, 2019, 10:37:12 am by treez »
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2735
  • Country: ca
Hi,

There are several ways to do this.






The simulation runs multiple times with a different amplitude each run.

If you want the amplitude to change during a single simulation you can use a multiplier like this:







The result is:




Note: I used amplitudes of 150, 200 and 250V to make the results more visible.

I have attached the model.

Regards,

Jay_Diddy_B
« Last Edit: August 04, 2019, 10:43:19 am by Jay_Diddy_B »
 
The following users thanked this post: ocset

Offline ocsetTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: 00
Thanks Jay_Diddy__B
Thats great  things there.
Sorry i just adjusted it (the initial question of my top post) to involve the DC source being stepped at the same time, because i put it in and realised the DC needs to step in tandem.
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2735
  • Country: ca
Treez,

are you looking for

254 and 1V

264 and 2V

274V and 3V

or all nine combinations?

Jay_Diddy_B
 
The following users thanked this post: ocset

Offline ocsetTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: 00
Just the three you have there.
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2735
  • Country: ca
Treez,

This gives all combinations:



The result is:



Jay_Diddy_B
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2735
  • Country: ca
Treez,

This give the tree combinations. The voltages are a function of the run number.



Regards,
Jay_Diddy_B
 
The following users thanked this post: ocset

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
AC 254 264 274
I usually just put 3 AC sources in series and set the number of cycles and a start delay for the 2nd and 3rd. >:D
.  That took much longer than I thought it would.
 
The following users thanked this post: ocset

Offline ocsetTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: 00
Thanks, is there a way to do tandem stepping of voltage sources...
(...but without there being a relationship between the values such that a math expression can enable  it.)

..ie tandem stepping of voltage sources.....
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12936
Yes you can do that  (assuming you don't need to dynamically change the voltage within a .tran run) by parameterising the sources and using the table() function to look up the desired values.

Step a parameter run number, and from it generate the other parameter values required :
Code: [Select]
.step param run 1 3 1 ; middle no. is no. of runs
.param Vac={table(run, 1,254V, 2,264V, 3,274V)}
.param Vdc={table(run, 1,1V, 2,2V, 3,3V)}
then use SINE(0 {Vac*sqrt(2)} 50) for the AC source and {Vdc} for the DC one.
Note that the table for Vdc is redundant as run already had the desired value!

The 'V' units in the table() functions are syntactic sugar - LTspice ignores unit letters after a number or number followed by a S.I. multiplier suffix unless it mistakes them for valid S.I. multipliers so *DON'T* try to write the value of a 1 Farad capacitor as 1F as LTspice sees that as 1fF.
The spacing is also used to clarify the input:output pairing

You'll find the table() function documented in the help file at  'LTspice'=>'Circuit Elements'=>'B. Arbitrary Behavioral Voltage or Current Sources'.  Input values for each point pair must be in order.  It interpolates between pairs (but does not extrapolate beyond the table limits) so you can use a sparse table.

Also note you aren't limited to stepping sources.  You can step *ANY* component that you can parameterise its value as a number, even active devices if you define a model for each number!  see: http://ltwiki.org/?title=Undocumented_LTspice#Stepping_a_Model

To do the same thing *within* a *single* .tran run you need a control voltage source instead of the parameter 'run' and to use .func (which has slightly different syntax) instead of .param with arbitrary behavioural sources instead of plain voltage sources, however generating a table controlled sine wave purely mathematically is *very* slow so one of the other methods of providing a dynamically changing voltage suggested above by StillTrying or Jay_Diddy_B is probably preferable.
« Last Edit: August 04, 2019, 12:46:31 pm by Ian.M »
 
The following users thanked this post: ocset

Offline 3roomlab

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: 00
this is how I roll it in 1 run (same method as what mr stilltrying said)
« Last Edit: August 04, 2019, 12:55:02 pm by 3roomlab »
 
The following users thanked this post: ocset

Offline ocsetTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: 00
Thanks Ian.M, i tried it but cant seem to get it to work.
Please find LTspice sim attached
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12936
You are missing a comma in the Vac table after the pair 3,200V.
 
The following users thanked this post: ocset


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf