Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Limitation of line length for B-source equations?
The following B source definition (all on one line, it is a mere 600 characters) is no problem in LTspiceIV:
~~~ Bxx S_junction_1 0 I=V(n1 ) * 9.3993002816 + V(n2 ) * -8.3877049435e+01 + V(n3 ) * 1.0381596463e+02 + V(n4 ) * 7.7568930320e+01 + V(n5 ) * -6.0938454341e+01 + V(n6 ) * -1.1355133106 + V(n7 ) * -1.5622632040e+01 + V(n8 ) * 4.8948254492e+01 + V(n9 ) * -5.9853970925 + V(n10) * -3.6704588281e+01 + V(n11) * 4.2526090679 + V(n12) * -1.2632025682e+01 + V(n13) * 7.0439969303 + V(n14) * 5.6648248733 + V(n15) * 3.2392479658 + V(n16) * 4.8449566268e-01 + V(n17) * -2.4475209917e-01 + V(n18) *-3.9824174985 + V(n19) * -7.5842504091 + V(n20) * 1.6805598922 + V(n21) * 1.2729728817 + V(n22) * -3.9681499520e-01 ~~~ In ADI LTspice 17.1.8, the line can be entered in the "old-style" editor (ctrl+right-click) just fine. AFAIK, the fact that it can be entered means that at least the syntax is correct. It is possibe to save the *.asc and read it in again, however, when clicking on the B-source to check/change it, there is an error "This attribute exceeds the 260 character limit for a Windows grid control". The circuit doesn't run. If I make a netlist, save it, and pass it to LTspice, it stops with an error and ^L shows a few strange characters where the B-source text should be. I hope I simply made a mistake, because when this is a new limitation, it will make many of my old LTspiceIV circuits unusable. Or maybe there is a workaround? I have tried to split the text in multiple lines and use "+" to continue them in the trusted SPICE fashion, but "+" doesn't work in the ctrl+right-click B-source editor, and it also appears not to work when entered in an ASCII netlist with a text editor. -marcel |
marcel,
It is a known fact that the line length is limited in LTspice's attribute editor.? That was discovered way back when Mike Engelhardt was still working for ADI or LTC. If I remember right (it's been a long time), it was only in the attribute editor where the line length has this limit, which I thought was about 256 characters per line.? Once the line makes it into the .asc schematic file, it was OK.? What you're seeing now contradicts that, so maybe it has changed since then. Andy |
It is a bit better/weirder than I thought.
My circuit with the added "+" character to extend the B-source line *did* in fact run. The warning that is reported (by popping up the expanded listing) is that there are current sources without parallel resistance (an unrelated issue). It is warning, not an error, and I misread it. On the place in the log listing where the B-source line should have been there are three characters (maybe 1 more, I didn't fire up the hex editor) like this: ?…×? This might be an intended place holder for an overly long line. So, there is no compatibility problem, unless the three characters prevent reading the *.log file correctly, or unless the B-source line needs to be edited in the GUI. -marcel |
¿ªÔÆÌåÓýOn 02/07/2023 12:53, mhx@... wrote:You're right, you can't then enter the symbol dialogue, but you can right-click on the displayed string - not the symbol - and directly edit the expression, stretching the dialogue window, if necessary. The problem with long expressions like this is you can't make them invisible without going into the attribute editor, which you can't do when the 260 character limit is exceeded.The following B source definition (all on one line, it is a mere 600 characters) is no problem in LTspiceIV: ~~~ Bxx S_junction_1 0 I=V(n1 ) * 9.3993002816 + V(n2 ) * -8.3877049435e+01 + V(n3 ) * 1.0381596463e+02 + V(n4 ) * 7.7568930320e+01 + V(n5 ) * -6.0938454341e+01 + V(n6 ) * -1.1355133106 + V(n7 ) * -1.5622632040e+01 + V(n8 ) * 4.8948254492e+01 + V(n9 ) * -5.9853970925 + V(n10) * -3.6704588281e+01 + V(n11) * 4.2526090679 + V(n12) * -1.2632025682e+01 + V(n13) * 7.0439969303 + V(n14) * 5.6648248733 + V(n15) * 3.2392479658 + V(n16) * 4.8449566268e-01 + V(n17) * -2.4475209917e-01 + V(n18) *-3.9824174985 + V(n19) * -7.5842504091 + V(n20) * 1.6805598922 + V(n21) * 1.2729728817 + V(n22) * -3.9681499520e-01 ~~~ In ADI LTspice 17.1.8, the line can be entered in the "old-style" editor (ctrl+right-click) just fine. AFAIK, the fact that it can be entered means that at least the syntax is correct. It is possibe to save the *.asc and read it in again, however, when clicking on the B-source to check/change it, there is an error "This attribute exceeds the 260 character limit for a Windows grid control". The circuit doesn't run. If I make a netlist, save it, and pass it to LTspice, it stops with an error and ^L shows a few strange characters where the B-source text should be. I hope I simply made a mistake, because when this is a new limitation, it will make many of my old LTspiceIV circuits unusable. Or maybe there is a workaround? I have tried to split the text in multiple lines and use "+" to continue them in the trusted SPICE fashion, but "+" doesn't work in the ctrl+right-click B-source editor, and it also appears not to work when entered in an ASCII netlist with a text editor. My solution to difficulties like this is put the long expressions into a text file. Then wrap then the B-source into a .subckt, in which you can .INClude the text file: .subckt Fudged_B_source 1 2 Bxx S_junction_1 0 I= .inc Expression.txt .ends Fudged_B_source You can also directly paste the entire B-source netlist into a SPICE directive, placed on the schematic. It still looks just as ugly, and you can't make a directive invisible, either. Good job probably, as you would never find it again! --
Regards, Tony |
to navigate to use esc to dismiss