Stepping the amplitude of a two  sources  for transient analyses in LTspice - Page 1
Forum section: electronics / beginners

author: ocset
author_rank: Super Contributor
timestamp: August 04, 2019, 10:00:48 am
content: Hi,I have a mains sinusoidal voltage source in LTspice, and a DC voltage source.I want to step them...AC 254 264 274DC 1 2 3...ie so it doesAC=254 and DC = 1VAC=264 and DC = 2VAC=274 and DC = 3V

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: August 04, 2019, 10:35:46 am
content: 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

author: ocset
author_rank: Super Contributor
timestamp: August 04, 2019, 10:39:00 am
content: Thanks Jay_Diddy__BThats 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.

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: August 04, 2019, 10:46:32 am
content: Treez,are you looking for254 and 1V264 and 2V274V and 3Vor all nine combinations?Jay_Diddy_B

author: ocset
author_rank: Super Contributor
timestamp: August 04, 2019, 10:47:41 am
content: Just the three you have there.

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: August 04, 2019, 10:52:59 am
content: Treez,This gives all combinations:The result is:Jay_Diddy_B

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: August 04, 2019, 11:01:13 am
content: Treez,This give the tree combinations. The voltages are a function of the run number.Regards,Jay_Diddy_B

author: StillTrying
author_rank: Super Contributor
timestamp: August 04, 2019, 11:02:00 am
content: AC 254 264 274I usually just put 3 AC sources in series and set the number of cycles and a start delay for the 2nd and 3rd.

author: ocset
author_rank: Super Contributor
timestamp: August 04, 2019, 12:06:13 pm
content: 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.....

author: Ian.M
author_rank: Super Contributor
timestamp: August 04, 2019, 12:35:07 pm
content: 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:.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 useSINE(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 pairingYou'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_ModelTo 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.

author: 3roomlab
author_rank: Frequent Contributor
timestamp: August 04, 2019, 12:46:53 pm
content: this is how I roll it in 1 run (same method as what mr stilltrying said)

author: ocset
author_rank: Super Contributor
timestamp: August 04, 2019, 03:09:00 pm
content: Thanks Ian.M, i tried it but cant seem to get it to work.Please find LTspice sim attached

author: Ian.M
author_rank: Super Contributor
timestamp: August 04, 2019, 04:34:35 pm
content: You are missing a comma in the Vac table after the pair 3,200V.