Module 6 - Modeling / 6.0 Model Requirements |
To download the examples for Module 6, click Module_6_Examples.zip
In this topic:
In the three previous topics, you created constant resistance, constant current, and constant voltage load subcircuits. Each load is self-contained with parameters passed into the underlying model through the symbol, and each load has a parameter editing dialog to edit the parameters. While these loads are well designed, with a convenient parameter editing dialog, a user has to manually delete one load symbol and replace it with another when changing the load type.
In this topic, you will "merge" these three loads into a single load which will use one of the three loads based on a parameter value. You will define the LOAD_TYPE parameter to select which one of the three loads to use in the simulation. The techniques learned in this topic are applicable to a wide range of models.
To start assembling the load subcircuits,
After the getting started section, the schematic has three loads connected in parallel. Next you will modify the schematic so that only one of the three loads is used in the simulation, the load selected is determined by the parameter LOAD_TYPE.
In the three previous topics, you learned the .IF/.ENDIF constructs can be used to output error messages. In this topic you will learn the same construct can be used to exclude a schematic component from the simulation.
Before you get started, a note on the .IF/.ENDIF syntax when used on a template property. When a simulation is run, the SIMPLIS_TEMPLATE property is evaluated, and in that process, expressions enclosed in curly braces are evaluated, and special template keywords are resolved to text values. Because of this evaluation, the curly braces need to be doubled up when a logical test is placed on the template property. The outer-most curly braces are evaluated during the netlist process, leaving the logical test expression inside single curly braces. The syntax for using .IF/.ENDIF on the SIMPLIS_TEMPLATE property is:
.IF {{ logical_test }} normal_symbolic_template_property .ENDIF
It is also important to remember that the SIMPLIS_TEMPLATE literally defines the netlist entry for a symbol. As such, you need to be very careful when editing the SIMPLIS_TEMPLATE property. In the above example, the SIMPLIS_TEMPLATE is spread out on three lines, and this is critical to the conditional expression evaluating correctly.
To edit the constant resistance load SIMPLIS_TEMPLATE property:
The LOAD_TYPE parameter is a string, and will be passed into the schematic through the symbol. Consider the condition expression:
.IF {{ LOAD_TYPE == 'Constant\sResistance' }}
This conditional expression compares the string value of the LOAD_TYPE parameter to the literal string 'Constant\sResistance'. In SIMetrix/SIMPLIS, strings are enclosed in single quotes. This is an important distinction in parameter types. In all previous topics, parameters were real values, such as 1MegΩ for a resistance value. You can also define parameter values as strings; however, it is difficult to pass strings with spaces through the symbol-subcircuit interface. In this example we "escape" the space character with the character sequence \s. You will see that the dialog function automatically converts \s to a space before displaying the parameter.
The conditional expression will either return the original SIMPLIS_TEMPLATE, or an empty string, based on the string comparison. Clearly the empty string is electrically inactive and the original SIMPLIS_TEMPLATE will include the model for the constant resistance subcircuit.
In this exercise, you will repeat each step from exercise #1. When you get to step #4a, you will use different conditional expressions for the two loads.
.IF {{ LOAD_TYPE == 'Constant\sCurrent' }}
.IF {{ LOAD_TYPE == 'Constant\sVoltage' }}
After making the changes to each SIMPLIS_TEMPLATE, double check that the syntax is correct:
Each subcircuit load has built-in error checking, but the new parameter LOAD_TYPE needs to be checked to ensure the string value is one of the three valid string values:
The following conditional expression uses the logical AND operator "&&" and the logical NOT EQUAL TO inequality "!=" to check if the LOAD_TYPE parameter is not one of the three defined parameters:
.IF { LOAD_TYPE != 'Constant\sResistance' && LOAD_TYPE != 'Constant\sCurrent' && LOAD_TYPE != 'Constant\sVoltage' } .ERROR "The load type parameter (LOAD_TYPE={LOAD_TYPE}) for the subcircuit_load subcircuit must be one of 'Constant\sResistance', 'Constant\sCurrent', or 'Constant\sVoltage'." .ENDIF
Copy this error message to the F11 window. and save the schematic.
Included in the Module_6_Examples.zip file is a pre-prepared dialog definition spreadsheet similar to the one used in the previous three topics. Like the spreadsheets used in 6.1.1, 6.1.2, and 6.1.3, this spreadsheet contains all script commands required to add the dialog and parameter properties to the symbol. The extracted file is located at: C:\Training\Module_6_Examples\6.2_subcircuit_load_dialog_definition_worksheet.xlsx. The dialog definition creates the following dialog for the load:
To add the symbol properties:
Unlike the other models, this subcircuit load has hierarchy, and the parameters must be passed down through the hierarchy from the top level schematic component 6.2_subcircuit_load.sxcmp to the individual loads. In the next exercise you will pass the parameters from the 6.2_subcircuit_load.sxcmp schematic component to the individual loads.
As discussed in topic 5.3 Passing Parameters Through Multiple Hierarchy Levels, parameters passed in through a symbol are only available at that level of hierarchy. To use these parameters in lower levels of hierarchy, such as in the three loads, you have to pass the parameters down through the hierarchy.
Start with the constant resistance load symbol:
The model is now complete and ready for testing.
Now that the model and associated symbol are completed, its time to start testing. A testbench schematic for the complete subcircuit load is located in the Module_6_Examples directory. The testbench has test circuitry for each load type, so you will need to place three loads on the testbench schematic. After you place each load you should configure each of the three symbols to use one of each load type. The testbench schematic is located at: C:\Training\Module_6_Examples\6.4_test_subcircuit_load.sxsch.
This section is left as a self-study exercise. You should run the same experiments as you ran in the previous three topics:
Using a conditional expression on the SIMPLIS_TEMPLATE allows you to include or exclude the entire schematic component from the simulation. This extremely powerful technique allows you to design schematics in which the schematic configuration is determined by parameter values. In this topic, you included one of three subcircuit loads, but the technique can be used for almost any application. A few examples are:
The syntax of the SIMPLIS_TEMPLATE is exacting. A few rules apply:
At the end of the module, please fill out the Module # 6 Evaluation form.