0
\$\begingroup\$

I've asked this on the LTSpice group and am getting conflicting answers.

I have a tank circuit in a sim I'm working with, and I need to look at the effect of changing the L value across a range (using .step statement) and of course the companion capacitor value needs to be adjusted to match.

.param F 500000
.step param L 1uH 10uH 200nH
.param C (1/(2*Pi*F))**2/L

The capacitor value is set to {C} and the inductor set to {L}

I've been told that this "should work" and that it "will not work".

I suppose it comes down to when the capacitor value param statement is evaluated. When I run it, I'm told that it can't resolve the parameter C.

I'm not married to this approach, it simply seemed the most obvious way to proceed, but I do need to be able to adjust the C value to match the L in each run.

If this can't work, is there a way to get to what I need, having the C automatically adjusted to resonate with the L?

Spehro: I'm not sure exactly what you mean, and what I'm doing isn't working.

I have .param A = (2pi{F}) and .param B = {A}**2 and .param C = (1/{B})/{L} "Missing expression in **2" is the result.

The Photon:

This version: {(1/2piF))**2/L} gives me Error: undefined symbol in: "(1/2pi[f]))**2/l"

So I tried this version, setting the value in the component to:

{(1/2pi{F}))**2/{L}}} Error: undefined symbol in: "(1/2pi([f])))**2/(l)"

\$\endgroup\$
9
  • 1
    \$\begingroup\$ What happened when you tried it? \$\endgroup\$ Jun 1, 2020 at 15:38
  • 1
    \$\begingroup\$ "asked this on the LTSpice group": Link to that. If you got conflicting answers there, why didn't you engage with the people there? \$\endgroup\$ Jun 1, 2020 at 15:40
  • \$\begingroup\$ You tried it and it didn't work. As an alternative, I suggest setting the capacitor value to {(1/(2*Pi*F))**2/L}. \$\endgroup\$
    – The Photon
    Jun 1, 2020 at 16:07
  • 1
    \$\begingroup\$ I've seen the conversation in the LTspice group and you were advised most well, given the details you provided. You were asked whether you defined f elsewhere and you said yes, but it clearly isn't the case. You were also hinted at to upload your schematic, you didn't, someone even tried to help by uploading an example, did you see it? You're blaming others for not helping you but you don't make the slightest effort to show what exactly you have. Also extracting from context ("this will work", "this won't"). You're wasting people's time by not giving details but expecting answers. \$\endgroup\$ Jun 1, 2020 at 17:39
  • 1
    \$\begingroup\$ @user103218 You're talking about an LC tank, is it that difficult to simplify it to the size of an example, something that would allow anyone to realize what is it you're looking at, something that would clarify the situation and allow a proper answer? "I've defined f" means nothing in this context. There is no context to speak of. All you're saying is that you have an LC tank and that assigning a value doesn't work. That's it. In which case, the answer below is good enough for your efforts. \$\endgroup\$ Jun 1, 2020 at 18:49

4 Answers 4

2
\$\begingroup\$

You should give us something reproducible. This may mean spending your time to produce a different schematic, one that does not disclose anything you care deeply about, but at the same time allows us to see the issue you are encountering. Surely, you are capable of take your existing schematic and, by hacking out parts of it while preserving the error, eventually have something to present to us for our examination.

As it stands (unless I'm mis-reading) none of us can replicate your problem. You won't share your netlist or errorlog or schematic. This pretty much shuts down any possibility of us finding your problem, except entirely by hunt-and-peck guessing about it. For now, this makes your question largely an unproductive waste of all our times, in my opinion.

This is your question. Why can't you afford a moment to produce a publishable reproduction of the problem you face, where a solution could be at least conceptually applied by you to your secret schematic?

That said, suppose I wanted to take a resistor divider and specify two things: \$R_\text{TH}\$ and the divider ratio at their shared node. Let's call the "top one" \$R_1\$ and the bottom one \$R_2\$ and the ratio as \$RATIO=\frac{R_2}{R_1+R_2}\$. Then in LTspice I may write:

.param RATIO={0.8}
.param RTH={5k}
.param R1X={RTH/RATIO}
.param R2X={RTH/(1-RATIO)}

Then I would use {R1X} for \$R_1\$'s value and {R2X} for \$R_2\$'s value in LTspice. It's as simple as that.

Skimming over what you've written I've no idea why you write, {A}**2, which is almost certainly an error. It probably should be either {A**2} or else {pow(A,2)}.

Since you won't share and won't work to produce something you can share with us, I think that's about all I can suggest. Go over your work with a jeweler's eye towards detail. See if you can come up with the problem on your own. None of us have a working crystal ball.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ I honestly doubt there's anything classified here, since the quesion in the groups has been posted on Friday (or look for "Calculating the value of a component during a sweep" if the link doesn't work), and it looks like OP's going to still wait for the golden answer. I hope your efforts have not been in vain. I hope the same for the rest that tried to answer in the groups. \$\endgroup\$ Jun 1, 2020 at 20:02
1
\$\begingroup\$

Works fine for me. Replace X with {X} where you want the value and write it as 3 separate statements.

enter image description here

enter image description here

\$\endgroup\$
1
\$\begingroup\$

You need to use .step to change the value of the capacitor for each .step'd value of L.. You will not succeed unless you do.

Above statement by John Woodgate in reply, when the same topic was asked as "Calculating the value of a component during a sweep" at [email protected]

\$\endgroup\$
2
  • \$\begingroup\$ Not really an answer, but thank you for the quote (I think it's straight from the group?). At any rate, it doesn't seem to matter anymore, apparently the shame was greater, which is encouraging, since it hints of a conscience. \$\endgroup\$ Jun 3, 2020 at 18:45
  • 2
    \$\begingroup\$ @aconcernedcitizen - Hi, you were right. I found the quote which was, as you thought, from the LTspice group, and added the necessary reference links, per site rules here. Since it is just a straight quote from elsewhere, with no further explanation or added value, I'm not convinced that it qualifies as an answer here either. However since someone has upvoted it, I won't flag it. \$\endgroup\$
    – SamGibson
    Jun 3, 2020 at 19:17
0
\$\begingroup\$

I've solved it. The A^2 term requires NOT using curly brackets, and everywhere else requires using curly brackets on the variables. Using curly brackets around A breaks it in that one statement, and NOT using curly brackets around the variables anywhere else in this also breaks it.

This works, the values of the capacitor step along with the inductor, and the values then found to be optimal can be entered as fixed values in place of {C} in the capacitor for a final check, once the .step is commented out.

.step param L 39uH 68uH 1uH
.param A = (2*pi*{F})
.param B = A**2
.param C = (1/{B})/{L}

I was also told in the LTSpice google group that this is IMPOSSIBLE, and I would have to generate lists of values externally.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ You were not told that it's impossible and you are again extracting from context. You were also told to include exponentiation within curly braces, even if the braces are not needed when declaring .params. As I said, you had all the answers for your extremely lacking explanations, and you did nothing but mock people's willing to help you. \$\endgroup\$ Jun 2, 2020 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.