Keyboard Shortcuts
Likes
Search
Multiple instances of "C:U2:spark"
开云体育That problem isn't in the subcircuit, but there is a problem there. The expression for the capacitance is wrong, as you can see because it increases with the separation of the electrodes. The capacitance is ?o*area/distance. The 'multiple instances'
problem is in the .ASY or .ASC or both. Have you put a
reference to the subcircuit in the .ASY as well as in the
.ASC?
======================================================================================
Best wishes John Woodgate OOO-Own Opinions Only Rayleigh, Essex UK I hear, and I forget. I see, and I remember. I do, and I understand. Xunzi (340 - 245 BC) On 2023-07-03 10:15, Richard Andrews
via groups.io wrote:
I made a subckt of a spark gap and linked it to an edited neonbulb symbol and now I get the warning "multiple instances of "C:U2:spark"". Please help me straighten this out. |
开云体育When you autogenerate, the .ASY
includes the path to the subcircuit, If you also put an .INC
statement on your .ASC, you get the 'multiple instances'
error. ======================================================================================
Best wishes John Woodgate OOO-Own Opinions Only Rayleigh, Essex UK I hear, and I forget. I see, and I remember. I do, and I understand. Xunzi (340 - 245 BC) On 2023-07-03 10:38, Richard Andrews
via groups.io wrote:
No, all I did was open the subcircuit right click on the circuit name to auto-generate a symbol. Then I placed the symbol on my circuit and run it. Thanks for your help by the way. |
A fresh install rarely helps, especially when the problem is a mistake in your circuit. * Spark gap resistance
|
In short, every bit of your subcircuit is not SPICE.? It's pretty algebra (if also incorrect), but it is not SPICE and it doesn't belong inside a subcircuit.
The only parts of your subcircuit that make sense, are the .SUBCKT line, the .ENDS line, and the comments.? Everything else should not be there. Andy |
开云体育I suppose the algebra could be
included as comments also. Maybe Richard thought that the *
worked for both lines of text. ======================================================================================
Best wishes John Woodgate OOO-Own Opinions Only Rayleigh, Essex UK I hear, and I forget. I see, and I remember. I do, and I understand. Xunzi (340 - 245 BC) On 2023-07-03 11:37, Andy I wrote:
In short, every bit of your subcircuit is not SPICE.? It's pretty algebra (if also incorrect), but it is not SPICE and it doesn't belong inside a subcircuit. |
It looks like Richard wanted his comments to define parameters.
Of course they don't.? Having a line like this: ? ??* A = 5.19e-11 makes it a comment, where it does nothing.? It does not define a constant or parameter named "A", so it's invalid to later use "A" within a formula because "A" is not "known".? Maybe Richard intended to write: ? ? .param? A = 5.19e-11 But that's only one of many mistakes he made. Andy |
Richard,
By the way -- I should have said this earlier, but I forgot to -- What you did was the reason for the error message. You had two capacitors both named "Cspark, inside of the same subcircuit.? LTspice needs to alter that name when it "expands" the subcircuit into the expanded SPICE netlist.? It does that by inserting extra characters into the name.? In your case, it turned "Cspark" into "C:U2:spark".? So what it did was insert? "U2" in the middle of the name, after the first character which must be a "C" to indicate that it is a capacitor.? In your case, it found that Cspark was inside of a subcircuit which had the instance name "U2", so "U2" was the text that it inserted between the "C" and the "spark".? The extra colons are how it separated U2 from the rest of the name. I am just explaining how "Cspark" got turned into "C:U2:spark".? "CLU2:spark" "C:U2:spark" is LTspice's way of saying "the capacitor you named 'Cspark' which I found inside of the subcircuit instance named 'U2'." (And I need to proof-read more carefully what I type.? I made careless errors which I didn't catch before clicking the "Send" button.) Andy |
开云体育On 03/07/2023 13:21, Richard Andrews via groups.io wrote:I had a reference to help me with model cards, but I seem to have misplaced it.What I would suggest is that you initially develop your spark gap model as a schematic, without worrying too much about SPICE netlist syntax. You can then extract the netlist and use that as a basis for your .subckt when you have got it working. You're making life much more difficult than it needs to be. BTW, did you look at all the previous spark gap models in the group's Files section? If not, go to Files and type "spark gap" in the search box. You should get 40 hits, including some complete libraries and some development schematics that help the understanding of how they work. --
Regards, Tony |
开云体育On 03/07/2023 14:30, Richard Andrews via groups.io wrote:I uploaded a new file. Now I get that ltspice thinks B is a node. Hello Tony Casey, I'll try your first option later. Thank you.This is what you uploaded: .subckt sparkgap p n * Parameters * d: Gap distance in meters * aa: Gap area in sqr meters * p: Gas pressure in Pascals * Model constants ?.param A = 5.19e-11 ?.param B = 23.8 ?.param C = 11.6 * Spark gap voltage Vspark = (B * p * d) / log(A * p * d) - log(log(1+(1/1.2)))-C * Capacitance of gap * Spark gap resistance Cspark p n 8.85e-12 * aa / d Rspark p n 1e12 / Vspark .ends What about Vspark? That needs to be defined as a parameter, too. As it is, LTspice think Vspark is a voltage source, so naturally is assuming the next two strings are the nodenames that it is connected to. Only circuit elements can begin without a dot. What a circuit element is assumed to be is defined (normally) by its first letter: "R" for resistor, "C" for capacitor and "V" for voltage source", and so on. Some initial letters are also invalid: no element name can begin with "N" or "P" - they are not defined. Everything else is a directive and must start with a dot. It is also normal to begin a .subckt definition with a comment, starting with "*". Originally, SPICE assumed the first line was always a comment, but I'm not sure how strictly that is enforced, now. LTspice is quite forgiving of certain things. Additionally, where are "d", "aa" and "p" defined? Are you going to try to pass them into the .subckt as arguments? If so, they still need to be defined as parameters, too, even if the default value is overwritten by an argument. -- Regards, Tony |
Richard,
For some reason, you don't seem to like following advice.? Where is your schematic (.asc) file where this error happened?? Where is the symbol (.asy) file?? I really don't care that someone else could create another (different) new symbol from your subcircuit; where is YOUR symbol file?? Yes, it makes a difference. Looking at the second subcircuit file that you have uploaded -- I do not know if this has any bearing on the new (singular matrix) error message that you got, but the syntax you used is probably not right.? It's better, but still wrong.? LTspice expects to have a number for its component values, not an expression.? You used a resistor "value" of "1e12 / Vspark", which is not a number.? Perhaps in your mind it should evaluate to a number, but that expression is an expression, not a number.? It must be a number.? I'm guessing that LTspice probably used the "1e12" as the resistor's value and ignored what comes after it, but that is only a guess. If you wanted that expression to turn into a number, you need to enclose it within curly braces, like this: ? ??Rspark p n {1e12 / Vspark} Curly braces turn an expression into a number.? Try doing that.? Do the same thing with your capacitor's value: ? ??Cspark p n {8.85e-12 * aa / d} As I say, it might or might not work, but try it.? Only you have the schematic and the symbol, because you did not bother to include them when you uploaded your model. What is "aa"?? Is that a parameter that gets passed to this subcircuit?? Same with "d". The voltage source in your subcircuit still is incorrect.? You have a voltage source named "Vspark" and it's connected between nodes "=" and "(B", and it has a confusing value.? I'm surprised that LTspice accepted it and didn't abort on that. In the resistor's expression, it refers to the value Vspark.? But Vspark is not defined as a paramater.? Is that supposed to represent a fixed parameter?? Or the voltage on some (yet unknown) node in your subcircuit?? Or the current through the voltage source coincidentally named "Vspark"?? What you wrote does not make sense. FYI, the subcircuit you uploaded does not have a node "b", so the error message you quoted us could only have come from the schematic file WHICH YOU DID NOT BOTHER TO UPLOAD.? Please.? When we ask you to upload your schematic and symbol files, please follow that advice, and do it. By the way, I know a pretty good reference to help you with "model cards" and other SPICE syntax.? It's called "Help" and it comes with LTspice.? Run LTspice, then go to its built-in Help.? In fact, much of LTspice's Help about individual component lines and models, happens to be written from the point of view of Netlist syntax, which is exactly where you need when creating a subcircuit.? Admittedly it is somewhat sparse in places, but it is there and it is more useful that you probably think it is. Andy |
Tony wrote, "It is also normal to begin a .subckt definition with a comment, starting with "*". Originally, SPICE assumed the first line was always a comment, but I'm not sure how strictly that is enforced, now. LTspice is quite forgiving of certain things."
That advice only applies to the top-level netlist, not to subcircuits.? Subcircuits usually begin with the ".subckt" command.? Comments are recommended (to document your work), but otherwise they are unnecessary for subcircuits.? The first line of a top-level netlist is ignored (treated like a comment, even if it doesn't start with a "*" character).? The first line of a subcircuit is not ignored. Andy |