Main Content

sschdl.generateOptimizedModel

Replace Simscape switches and converter blocks with dynamic switches optimized for FPGA deployment

Since R2024a

    Description

    generatedModel = sschdl.generateOptimizedModel(input) replaces common Simscape™ switches and converter blocks with their dynamic equivalents to optimize the model for FPGA deployment. To learn more about dynamic switch replacement, see Generate HDL Code for Simscape Models by Using Dynamic Switch Approximation.

    generatedModel = sschdl.generateOptimizedModel(input,Name,Value) replaces Simscape switches or PMSM (Simscape Electrical) block with a dynamic equivalent using one or more name-value pair arguments.

    The function supports replacement of these blocks:

    The generated optimized model has the same name as input but with the suffix _generated. Once the optimized model is generated, open the model and verify the connection. Connect any gate signal inports of the replaced blocks to their respective sources and remove any additional Simulink-PS Converter (Simscape) blocks.

    example

    Examples

    collapse all

    Open the three-phase PMSM drive model at the MATLAB® command prompt.

    ModelName = 'sschdlexThreePhasePMSMDrive';
    open_system(ModelName)
    

    Open the Three-phase inverter subsystem that contains Simscape blocks.

    open_system([ModelName '/Three-phase inverter'])
    

    To optimize the model for FPGA deployment, run the sschdl.generateOptimizedModel function at the MATLAB command prompt.

    generatedModel = sschdl.generateOptimizedModel('sschdlexThreePhasePMSMDrive',ReplaceSwitches=1,ReplacePMSM=0);
    
    The following blocks have been replaced: 
    'sschdlexThreePhasePMSMDrive/Three-phase inverter/IGBT A(H)'
    'sschdlexThreePhasePMSMDrive/Three-phase inverter/IGBT A(L)'
    'sschdlexThreePhasePMSMDrive/Three-phase inverter/IGBT B(H)'
    'sschdlexThreePhasePMSMDrive/Three-phase inverter/IGBT B(L)'
    'sschdlexThreePhasePMSMDrive/Three-phase inverter/IGBT C(H)'
    'sschdlexThreePhasePMSMDrive/Three-phase inverter/IGBT C(L)'
    
    Saving sschdlexThreePhasePMSMDrive as sschdlexThreePhasePMSMDrive_generated and replacing switch and converter blocks with equivalent FPGA HIL supported blocks.
    Warning: The following gate signal ports were disconnected during optimized
    model generation, and may need to be connected manually before simulation: 
    Warning: 'Input Port 1' of 'sschdlexThreePhasePMSMDrive_generated/Three-phase
    inverter/IGBT A(H)' is not connected. 
    Warning: 'Input Port 1' of 'sschdlexThreePhasePMSMDrive_generated/Three-phase
    inverter/IGBT A(L)' is not connected. 
    Warning: 'Input Port 1' of 'sschdlexThreePhasePMSMDrive_generated/Three-phase
    inverter/IGBT B(H)' is not connected. 
    Warning: 'Input Port 1' of 'sschdlexThreePhasePMSMDrive_generated/Three-phase
    inverter/IGBT B(L)' is not connected. 
    Warning: 'Input Port 1' of 'sschdlexThreePhasePMSMDrive_generated/Three-phase
    inverter/IGBT C(H)' is not connected. 
    Warning: 'Input Port 1' of 'sschdlexThreePhasePMSMDrive_generated/Three-phase
    inverter/IGBT C(L)' is not connected. 
    

    The generated optimized model for the three-phase PMSM drive model is saved as sschdlexThreePhasePMSMDrive_generated. In this model, the Three-phase inverter subsystem contains the replaced blocks.

    Input Arguments

    collapse all

    Simscape model name or a cell array of Solver Configuration (Simscape) block paths, specified as a character vector or string scalar, or a cell array of character vectors or string scalars. You can specify a Solver Configuration block attached to the Simscape network that you want to optimize within the model.

    Data Types: char | string | cell

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: generatedModel = sschdl.generateOptimizedModel("sschdlexThreePhasePMSMDrive",ReplaceSwitches=1,ReplacePMSM=0);

    Example: generatedModel = sschdl.generateOptimizedModel("sschdlexTwoPhaseDCDCConverterExample",AveragedSwitch=1);

    Since R2024b

    Logical true to enable replacement of Simscape switches in the model. Logical true and false correspond to 1 and 0, respectively.

    Data Types: logical

    Since R2024b

    Logical true to enable replacement of Simscape PMSM (Simscape Electrical) block in the model. Logical true and false correspond to 1 and 0, respectively. On replacement of the Simscape PMSM block with an equivalent optimized PMSM block, the Simscape network splits. You can check the Solver Configuration block attached to the Simscape network. Add and connect an additional Solver Configuration block.

    Data Types: logical

    Since R2024b

    Logical true to enable replacement of Simscape switches in the model with the dynamic equivalents of Averaged Switch. Logical true and false correspond to 1 and 0, respectively.

    Data Types: logical

    Output Arguments

    collapse all

    Path of the generated model that is optimized for HDL code generation, returned as a string array or cell array of character vectors. In the generated optimized model, when you double-click any dynamic switch block, the parameter values of Block Parameters Conductance (1/Ohm) Gs and Time scaling s are configured by using a Simulink.Parameter object. The values are stored in the base workspace and referenced from the block. For example, in the generated optimized model for the three-phase PMSM drive model the values are referenced as SolverConfiguration_Gs and SolverConfiguration_s from the blocks.

    Limitations

    • This function does not support all switches and converter blocks. Only listed switches and converter blocks are supported.

    • In the model, if a parameter references any workspace variable or an expression then the parameter value is replaced by the evaluated value.

    Version History

    Introduced in R2024a

    expand all