## Re: [Qucs-help] Questions about creating a subcircuit from scratch

 Re: [Qucs-help] Questions about creating a subcircuit from scratch From: Guilherme Brondani Torri - 2014-08-15 15:02:13 ```Hello, The subcircuit text is shown when you are in 'Edit Circuit Symbol' mode. Subcircuits have a schematic and symbol modes. You are right in being nervous. If you need to manually hack the schematic files you (or we) are doing it wrong. ;) A minimalistic example using subcircuits with parameters and equations would be like this: * create a new project * new schematic (for subcircuit) * add a resistor, inductor, and capacitor, wire them in series, add two ports * save the subcircuit as RLC.sch * Give value of resistor as 'R1' * Add equation 'ind = L1', * Give value of inductor as 'ind' * Give value of capacitor as 'C1' * save * File > Edit Circuit Symbol * Double click on the 'SUB File=name' tag under the rectangular box * Add name = R1, default value = 1 * Add name = L1, default value = 1 * Add name = C1, default value = 1 * OK * new schematic (for testbench) * save Test_RLC.sch * Project Contents > pick and place the above RLC subcircuit * Add AC voltage source (V1) and ground * Add AC simulation, from 140Hz to 180Hz, 201 points * Set on the subcircuit symbol * R1=1 * L1=100e-3 * C1=10e-6 * Simulate * add a Cartesian diagram, plot V1.i * you should see a resonance and be able to change parameters of the RLC subcircuit on the top schematic. In any case, for your convenience I this example as a Qucs Package on my dropbox (use Project >Extract Package to open it) https://www.dropbox.com/s/hmlasdomkasicox/RLC_subcircuit.qucs For the name on ports to show on the top schematic: * while in 'Edit Circuit Symbol' you can add any customization in terms of the 'paintings' from the dock (text, lines, rectangles). They will show up on the subcircuit symbol inserted on the top schematic on save. Yes, each time you save it will trash any manual changes to .sch files. You can add 'text' on top of the ports with a meaningful name on the subcircuit symbol. * port names on subcircuit schematics will show up on the subcircuit symbol edit mode, but not on top schematics, you need to further annotate the symbol if you want the ports to me named everywhere. Best regards, Guilherme On 8/14/14, 1:36 PM, Neil Thomas wrote: > Running Qucs 0.0.17, I want to make a subcircuit that encapsulates a > complex component, and has a parameter to control it that's accessible > from the it's placed on. > > I create the circuit on a new schematic, add ports, add equations to > control the components, and save it. I now want to create my own > parameter, and the help says 'double click on the subcircuit parameter > text'. I can't find anything that I recognise as being this. Through > searching these archives and comparing examples, I discovered that if I > modify the .sch text file, adding the string "1=my_param=0==" to the > <.ID x y SUB> line in the block, or adding that line if it > didn't exist (sometimes it did, sometimes not, not figured out when it > does), then the subcircuit would indeed be controllable by setting > my_param at the top level. > > So OK, I have a file hack, but I'm nervous that it might not be fully > working as the program expects, or continue to work next version. What > should I have done in the gui at this point to create an accesssible > parameter? What is the parameter text that should appear when creating a > subcircuit? > > On a couple of cosmetic issues: - I have named the ports, but the names > don't appear when it's placed on a schematic. When I try > file>edit_circuit_symbol, it trashes the reasonable stab it has already > made at a symbol, and starts again with no ports. So far, I've not tried > to alter anything on the symbol through the editor. Is it the intention > that I rebuild it manually, or are there ways to control/modify the > automatically created symbol? I have hacked the .sch file to move things > around a bit, but I'm sure there's a better way. > > thanks > > Neil Thomas > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Qucs-help mailing list > Qucs-help@... > https://lists.sourceforge.net/lists/listinfo/qucs-help ```

 [Qucs-help] Questions about creating a subcircuit from scratch From: Neil Thomas - 2014-08-14 11:52:22 ```Running Qucs 0.0.17, I want to make a subcircuit that encapsulates a complex component, and has a parameter to control it that's accessible from the it's placed on. I create the circuit on a new schematic, add ports, add equations to control the components, and save it. I now want to create my own parameter, and the help says 'double click on the subcircuit parameter text'. I can't find anything that I recognise as being this. Through searching these archives and comparing examples, I discovered that if I modify the .sch text file, adding the string "1=my_param=0==" to the <.ID x y SUB> line in the block, or adding that line if it didn't exist (sometimes it did, sometimes not, not figured out when it does), then the subcircuit would indeed be controllable by setting my_param at the top level. So OK, I have a file hack, but I'm nervous that it might not be fully working as the program expects, or continue to work next version. What should I have done in the gui at this point to create an accesssible parameter? What is the parameter text that should appear when creating a subcircuit? On a couple of cosmetic issues: - I have named the ports, but the names don't appear when it's placed on a schematic. When I try file>edit_circuit_symbol, it trashes the reasonable stab it has already made at a symbol, and starts again with no ports. So far, I've not tried to alter anything on the symbol through the editor. Is it the intention that I rebuild it manually, or are there ways to control/modify the automatically created symbol? I have hacked the .sch file to move things around a bit, but I'm sure there's a better way. thanks Neil Thomas ```
 Re: [Qucs-help] Questions about creating a subcircuit from scratch From: Guilherme Brondani Torri - 2014-08-15 15:02:13 ```Hello, The subcircuit text is shown when you are in 'Edit Circuit Symbol' mode. Subcircuits have a schematic and symbol modes. You are right in being nervous. If you need to manually hack the schematic files you (or we) are doing it wrong. ;) A minimalistic example using subcircuits with parameters and equations would be like this: * create a new project * new schematic (for subcircuit) * add a resistor, inductor, and capacitor, wire them in series, add two ports * save the subcircuit as RLC.sch * Give value of resistor as 'R1' * Add equation 'ind = L1', * Give value of inductor as 'ind' * Give value of capacitor as 'C1' * save * File > Edit Circuit Symbol * Double click on the 'SUB File=name' tag under the rectangular box * Add name = R1, default value = 1 * Add name = L1, default value = 1 * Add name = C1, default value = 1 * OK * new schematic (for testbench) * save Test_RLC.sch * Project Contents > pick and place the above RLC subcircuit * Add AC voltage source (V1) and ground * Add AC simulation, from 140Hz to 180Hz, 201 points * Set on the subcircuit symbol * R1=1 * L1=100e-3 * C1=10e-6 * Simulate * add a Cartesian diagram, plot V1.i * you should see a resonance and be able to change parameters of the RLC subcircuit on the top schematic. In any case, for your convenience I this example as a Qucs Package on my dropbox (use Project >Extract Package to open it) https://www.dropbox.com/s/hmlasdomkasicox/RLC_subcircuit.qucs For the name on ports to show on the top schematic: * while in 'Edit Circuit Symbol' you can add any customization in terms of the 'paintings' from the dock (text, lines, rectangles). They will show up on the subcircuit symbol inserted on the top schematic on save. Yes, each time you save it will trash any manual changes to .sch files. You can add 'text' on top of the ports with a meaningful name on the subcircuit symbol. * port names on subcircuit schematics will show up on the subcircuit symbol edit mode, but not on top schematics, you need to further annotate the symbol if you want the ports to me named everywhere. Best regards, Guilherme On 8/14/14, 1:36 PM, Neil Thomas wrote: > Running Qucs 0.0.17, I want to make a subcircuit that encapsulates a > complex component, and has a parameter to control it that's accessible > from the it's placed on. > > I create the circuit on a new schematic, add ports, add equations to > control the components, and save it. I now want to create my own > parameter, and the help says 'double click on the subcircuit parameter > text'. I can't find anything that I recognise as being this. Through > searching these archives and comparing examples, I discovered that if I > modify the .sch text file, adding the string "1=my_param=0==" to the > <.ID x y SUB> line in the block, or adding that line if it > didn't exist (sometimes it did, sometimes not, not figured out when it > does), then the subcircuit would indeed be controllable by setting > my_param at the top level. > > So OK, I have a file hack, but I'm nervous that it might not be fully > working as the program expects, or continue to work next version. What > should I have done in the gui at this point to create an accesssible > parameter? What is the parameter text that should appear when creating a > subcircuit? > > On a couple of cosmetic issues: - I have named the ports, but the names > don't appear when it's placed on a schematic. When I try > file>edit_circuit_symbol, it trashes the reasonable stab it has already > made at a symbol, and starts again with no ports. So far, I've not tried > to alter anything on the symbol through the editor. Is it the intention > that I rebuild it manually, or are there ways to control/modify the > automatically created symbol? I have hacked the .sch file to move things > around a bit, but I'm sure there's a better way. > > thanks > > Neil Thomas > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Qucs-help mailing list > Qucs-help@... > https://lists.sourceforge.net/lists/listinfo/qucs-help ```
 [Qucs-help] Unexpected 'syntax error, unexpected identifier' From: Neil Thomas - 2014-08-19 16:06:02 Attachments: 5th_ellip_2-2.8G_discreteC.sch ```It's a fairly simple single-level circuit. A few MLINs and MTEEs, a couple of capacitors, power sources. I want to parameterise the width of some of the lines. If I put a constant 'W=0.2 mm' in all of the parameter blocks connected to the lines and tees, everything works as expected. I'm using Qucs 0.0.17 on Windows 8. If I put 'W=wid' into any of the line parameters, and an equation block defining 'wid = 0.2 mm', I get 'syntax error, unexpected Identifier' pointing to the line number at which the equation block appears in the netlist. That happens whether the eqution block I use only has that definition, or I put it in the equation block that also successfully defines 'match = dB(S[1,1])' and 'thru=dB(S[2,1])'. I can see nothing at all wrong with the schematic, or the netlist. I have spelt 'wid' as 'thrum' or 'W1', used more characters, used upper case, used '200 um' instead of '0.2 mm'. What is it objecting to? The schematic as attached is the one that works. De/activate MS3/MS8/Eqn1 to try to get the W=wid equation controlling things. That then doesn't work for me. I don't think it's anything to do with the targets being MLINs, as they can all be constant parameters, and as soon as I enable the eqn block, it objects to the unexpected identifier. It cannot be anything to do with the equation block, as in other circuits I have similar 'param=number' lines in equations. Tearing my hair out. This is just a small circuit, so I must be able to parameterise the line widths, I cannot enter them all manually when I am experimenting. Can anybody see why I cannot parameterise my lowpass filter schematic? How can I go about debugging what's wrong? thanks in advance, sorry for being so stupid -- Neil Thomas Smith Myers Communications Ltd The Omega Centre Stratton Business Park Biggleswade Beds, SG18 8QB United Kingdom Tel: +44 (0) 1767 601144 ext 219 ```
 Re: [Qucs-help] Unexpected 'syntax error, unexpected identifier' From: Guilherme Brondani Torri - 2014-08-19 17:50:19 ```On 8/19/14, 6:05 PM, Neil Thomas wrote: > It's a fairly simple single-level circuit. A few MLINs and MTEEs, a > couple of capacitors, power sources. I want to parameterise the width > of some of the lines. If I put a constant 'W=0.2 mm' in all of the > parameter blocks connected to the lines and tees, everything works as > expected. I'm using Qucs 0.0.17 on Windows 8. > > If I put 'W=wid' into any of the line parameters, and an equation > block defining 'wid = 0.2 mm', I get 'syntax error, unexpected > Identifier' pointing to the line number at which the equation block > appears in the netlist. That happens whether the eqution block I use > only has that definition, or I put it in the equation block that also > successfully defines 'match = dB(S[1,1])' and 'thru=dB(S[2,1])'. I can > see nothing at all wrong with the schematic, or the netlist. I have > spelt 'wid' as 'thrum' or 'W1', used more characters, used upper case, > used '200 um' instead of '0.2 mm'. What is it objecting to? The > schematic as attached is the one that works. De/activate MS3/MS8/Eqn1 > to try to get the W=wid equation controlling things. That then doesn't > work for me. I don't think it's anything to do with the targets being > MLINs, as they can all be constant parameters, and as soon as I enable > the eqn block, it objects to the unexpected identifier. It cannot be > anything to do with the equation block, as in other circuits I have > similar 'param=number' lines in equations. Tearing my hair out. > > This is just a small circuit, so I must be able to parameterise the > line widths, I cannot enter them all manually when I am experimenting. > Can anybody see why I cannot parameterise my lowpass filter schematic? > How can I go about debugging what's wrong? > > thanks in advance, sorry for being so stupid Hi Neil, The Equation block is not aware of physical units. The 'mm' does not make sense for the equation block. It does know about 'm' for metric prefix mili (1e-3). You can use the equation in any of the following formats (the first is confusing in this case, meter vs mili). wid = 0.3m wid = 0.3e-3 wid = 0.0003 wid = 0.3/1000 wid = 0.3/1k To debug, you can see that the error/warning: `line 16: syntax error, unexpected Identifier` The line refers to the netlist line 16: `Eqn:Eqn1 wid="0.3mm" Export="yes"` These logs can be found on - Simulation > Show Last Messages - Simulation > Show Last Netlist. Don't worry it takes a while to learn the quirks of Qucs, the message could be more helpful... Regards, Guilherme ```
 Re: [Qucs-help] Questions about creating a subcircuit from scratch From: Guilherme Brondani Torri - 2014-08-19 18:01:24 ```Hi Neil, Good to know it is working. I agree the help is could be clearer. Documentation is often written by non native speakers and in this case, the help manual has not been reviewed in a while (several years actually). We are a new set of developers, picking up the project after it went abandoned for a few years. There are many areas that could be improved. I will add this and other step-by-step instructions tho the help. This is second time I had to tell someone how to use sub-circuits with parameters... The third time can be avoided if someone put info back into the manual. Please do file bugs if you find the help information is wrong/insufficient. Best regards, Guilherme On 8/19/14, 10:34 AM, Neil Thomas wrote: > Hi Guilherme, > > I think the problem was in the way the help text was written, your > step by step did not fall into the same trap. The help text says '*if* > you want to change the symbol ...' (*my emphasis*), which implies it's > optional. In order to add parameters, it's mandatory. I created the > subcircuit circuit, named the ports on the circuit, saved, then > immediately placed it onto a schematic. Qucs created a default symbol > for me at that point, which was halfway reasonable, and something that > I didn't particularly want to edit, at least not for a first test. I > was surprised not to see the port names pushed up to the top. When I > then went to 'edit symbol' to add the port names, it trashed this > fairly reasonable symbol, leaving me with nothing sensible, so I > aborted that edit. The text that was visible at the point of edit > symbol was SUB File=name, which did not look like a place to enter > parameters. To be fair, the help did say 'to add parameters go back to > the editor you used ...', but there are two editors, and I had been > bitten by the symbol one, wasn't going to try that again in a hurry. > > Perhaps I am particularly astonishable, or lacking in imagination, but > I felt the gui method of creating a subcircuit, and the 'working with > subcircuits' section of the help conspired to fail the 'principle of > least astonishment' several times. Suffice it to say that when I > realised it wasn't doing what I expected, I didn't feel the gui method > was sufficiently obvious to think through, and went back to reverse > engineering the .sch files, which is something I do feel comfortable > with. > > If the 'working with subcircuits' section adopted your step by step, > then I would have managed. I am sort of the software world's canary > down the mine. If the help is clear enough for Neil to work from it, > then anybody will manage. > > thanks > > Neil > > > On 15/08/2014 16:02, Guilherme Brondani Torri wrote: >> Hello, >> >> The subcircuit text is shown when you are in 'Edit Circuit Symbol' >> mode. Subcircuits have a schematic and symbol modes. >> >> You are right in being nervous. If you need to manually hack the >> schematic files you (or we) are doing it wrong. ;) >> >> A minimalistic example using subcircuits with parameters and >> equations would be like this: >> >> * create a new project >> * new schematic (for subcircuit) >> * add a resistor, inductor, and capacitor, wire them in series, add >> two ports >> * save the subcircuit as RLC.sch >> * Give value of resistor as 'R1' >> * Add equation 'ind = L1', >> * Give value of inductor as 'ind' >> * Give value of capacitor as 'C1' >> * save >> * File > Edit Circuit Symbol >> * Double click on the 'SUB File=name' tag under the rectangular box >> * Add name = R1, default value = 1 >> * Add name = L1, default value = 1 >> * Add name = C1, default value = 1 >> * OK >> >> * new schematic (for testbench) >> * save Test_RLC.sch >> * Project Contents > pick and place the above RLC subcircuit >> * Add AC voltage source (V1) and ground >> * Add AC simulation, from 140Hz to 180Hz, 201 points >> * Set on the subcircuit symbol >> * R1=1 >> * L1=100e-3 >> * C1=10e-6 >> * Simulate >> * add a Cartesian diagram, plot V1.i >> * you should see a resonance and be able to change parameters of the >> RLC subcircuit on the top schematic. >> >> In any case, for your convenience I this example as a Qucs Package on >> my dropbox (use Project >Extract Package to open it) >> https://www.dropbox.com/s/hmlasdomkasicox/RLC_subcircuit.qucs >> >> For the name on ports to show on the top schematic: >> * while in 'Edit Circuit Symbol' you can add any customization in >> terms of the 'paintings' from the dock (text, lines, rectangles). >> They will show up on the subcircuit symbol inserted on the top >> schematic on save. Yes, each time you save it will trash any manual >> changes to .sch files. You can add 'text' on top of the ports with a >> meaningful name on the subcircuit symbol. >> * port names on subcircuit schematics will show up on the subcircuit >> symbol edit mode, but not on top schematics, you need to further >> annotate the symbol if you want the ports to me named everywhere. >> >> Best regards, >> Guilherme >> >> On 8/14/14, 1:36 PM, Neil Thomas wrote: >>> Running Qucs 0.0.17, I want to make a subcircuit that encapsulates a >>> complex component, and has a parameter to control it that's accessible >>> from the it's placed on. >>> >>> I create the circuit on a new schematic, add ports, add equations to >>> control the components, and save it. I now want to create my own >>> parameter, and the help says 'double click on the subcircuit parameter >>> text'. I can't find anything that I recognise as being this. Through >>> searching these archives and comparing examples, I discovered that if I >>> modify the .sch text file, adding the string "1=my_param=0==" to the >>> <.ID x y SUB> line in the block, or adding that line if it >>> didn't exist (sometimes it did, sometimes not, not figured out when it >>> does), then the subcircuit would indeed be controllable by setting >>> my_param at the top level. >>> >>> So OK, I have a file hack, but I'm nervous that it might not be fully >>> working as the program expects, or continue to work next version. What >>> should I have done in the gui at this point to create an accesssible >>> parameter? What is the parameter text that should appear when >>> creating a >>> subcircuit? >>> >>> On a couple of cosmetic issues: - I have named the ports, but the names >>> don't appear when it's placed on a schematic. When I try >>> file>edit_circuit_symbol, it trashes the reasonable stab it has already >>> made at a symbol, and starts again with no ports. So far, I've not >>> tried >>> to alter anything on the symbol through the editor. Is it the intention >>> that I rebuild it manually, or are there ways to control/modify the >>> automatically created symbol? I have hacked the .sch file to move >>> things >>> around a bit, but I'm sure there's a better way. >>> >>> thanks >>> >>> Neil Thomas >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Qucs-help mailing list >>> Qucs-help@... >>> https://lists.sourceforge.net/lists/listinfo/qucs-help >> > ```