an introduction to solvers plecs

Post on 25-Feb-2018

309 views

Category:

Documents


13 download

TRANSCRIPT

  • 7/25/2019 An Introduction to Solvers PLECS

    1/66

    1

    An Introduction to Solvers

    Plexim GmbH

    Outline

    Variable-step simulation

    Ideal switches

    Piecewise linear simulation

    Non-stiff, stiff solvers

    Stability domain

    Event detection

    2

  • 7/25/2019 An Introduction to Solvers PLECS

    2/66

    3

    Different Degrees of Simulation Detail

    1. Power circuit modeled as linear transfer function

    Small signal behavior

    No switching, no harmonics

    ! Controller design

    2. Power circuit modeled with ideal components

    Large signal behavior, voltage and current waveforms

    Overall system performance

    ! Circuit design and controller verification

    3. Power circuit with manufacturer specific components

    Parasitic effects (magnetic hysteresis)

    Switching transitions (diode reverse recovery)

    Component stress (electrical or thermal)

    ! Choice of components

    Powerconverter

    Controller

    LoadPower input Power output

    Controlsignals

    Reference

    Measurement

    vi ii io vo

    4

    Comparison - SPICE and PLECS

    Passive component models are similar

    R, L, C

    The main difference is the semiconductor model

    MOSFET model - SPICE

    Detailed physical device model

    Has 47 parameters

    MOSFET model - PLECSSimplified behavioral model

    Two parameters: Ronand T

  • 7/25/2019 An Introduction to Solvers PLECS

    3/66

    5

    High Speed Simulations with Ideal Switches

    Conventional continuous diode mode

    Arbitrary static and

    dynamic characteristicSnubber often required

    Ideal diode model in PLECS

    Instantaneous on/offcharacteristic

    Optional on-resistanceand forward voltage

    6

    Comparison: Diode Rectifier

    Simulation with conventional and ideal switches

    Simulation steps:1160"153

    Computation time:0.6s "0.08s

  • 7/25/2019 An Introduction to Solvers PLECS

    4/66

    7

    State Space Model: Buck Converter

    State space description

    Switch conducting Diode conducting

    8

    Variable Time-Step Simulation: Buck Converter

    Transistor conductsDiode blocks

  • 7/25/2019 An Introduction to Solvers PLECS

    5/66

    9

    Variable Time-Step Simulation: Buck Converter

    Transistor opens

    Impulsive voltage acrossinductor

    10

    Variable Time-Step Simulation: Buck Converter

    Impulsive voltage closesdiode

  • 7/25/2019 An Introduction to Solvers PLECS

    6/66

    11

    Variable Time-Step Simulation: Buck Converter

    Transistor open

    Diode conducts

    12

    Variable Time-Step Simulation: Buck Converter

    Switch timing Problem:Diode opens too late

    Impulsive voltage acrossinductor

  • 7/25/2019 An Introduction to Solvers PLECS

    7/66

    13

    Variable Time-Step Simulation: Buck Converter

    Zero-Crossing Detection:

    Time-step is reduced

    Diode opens exactly at

    the zero-crossing

    14

    Operating Principle of PLECS

    Circuit transformed into state-variable system

    One set of matrices per switch combination

    AB C

    D

    1s

    Switchmanag

    er

    PLECS S-function

    Solver

    u

    g

    y

  • 7/25/2019 An Introduction to Solvers PLECS

    8/66

    Solver Overview

    Continuous solvers

    Taylor series polynomial

    Step size control

    Acceptable error

    Relative, absolute tolerance

    Output refining

    Discrete solvers

    Trapezoidal rule

    Step size selection

    15

    Taylor Series Expansion

    Approximate a continuousfunction with a higher orderpolynomial

    The higher the order, themore accurate the solution

    16

    y=sin(x)

    1storder

    5thorder

    Source: WikipediaTaylor series:

  • 7/25/2019 An Introduction to Solvers PLECS

    9/66

    17

    Continuous Solver Operation

    y(t) can be constructed using in a piecewise fashion usingp1(t) and p2(t), which are Taylor series polynomials

    A continuous solver calculates the point yn+1by calculatingthe equivalent Taylor series for p1(t)

    An nthorder solver has the same accuracy as an nthorderTaylor series.

    "#$%!$%

    '#$%

    $$( $()"

    '('()"

    *( *()"

    Solver Settings

    18

  • 7/25/2019 An Introduction to Solvers PLECS

    10/66

    Acceptable Error

    Local error

    Difference between 4th and 5th order solutions

    Acceptable errorDefines the local error limitDetermined by tolrelexcept for small state values

    19

    Acceptable errorLocal error

    Result valid if:

    Step Size Control

    Step size automatically controlled by the solver(variable step)

    Goal: Keep error within acceptable error limits

    Key advantage: Accuracy directly specified by the user

    Step size calculated using

    Relative error, !

    Relative tolerance, tolrelPrevious time step, hold

    20

    hold

  • 7/25/2019 An Introduction to Solvers PLECS

    11/66

    Tolerances

    Relative tolerance

    Determines acceptable error limit when x > 0

    Start with 10-3

    (0.1%)Numerical limit is 10-16

    Absolute tolerance

    Best to set to auto

    21

    Example LC circuit

    22

    Analytical solution:

    Result: tolrel= 1e-3

  • 7/25/2019 An Introduction to Solvers PLECS

    12/66

    Example LC circuit

    23

    Analytical solution:

    Result: tolrel= 1e-6

    Refining the Output

    Option 1: Reduce tolrelor time step

    Solver must recalculate polynomial coefficients at each timestep

    Less efficient

    Option 2: Increase refine factor

    Solver uses existing polynomial coefficients to calculate

    additional points.More efficient

    24

  • 7/25/2019 An Introduction to Solvers PLECS

    13/66

    Solver Families

    Non-stiff

    Inherently more efficient (no iteration required)

    Smaller stability domainForward Euler - 1st order

    ode45/Dopri - 5th order

    Stiff

    Less efficient (iteration required)

    Larger stability domain

    Backward Euler - 1st order

    Radau/ode23tb - 5th order

    25

    Forward Euler

    Truncate the Taylor Seriesafter the first term:

    1st order accurate

    Explicitintegrationalgorithm

    26

  • 7/25/2019 An Introduction to Solvers PLECS

    14/66

    Numerical Experiment

    Scalar system

    Analytical solution

    Forward Euler

    Unstable for ah

  • 7/25/2019 An Introduction to Solvers PLECS

    15/66

    Stability Domain of Forward Euler

    Integration algorithm

    Stable if the eigenvalues of

    Fare inside the unit circle

    I.e. if the eigenvalues of Ah

    are inside a unit circlearound (-1, 0)

    29

    Analysis of RLC Example

    30

  • 7/25/2019 An Introduction to Solvers PLECS

    16/66

    31

    Floating Point Arithmetic

    What is 0.3 - 0.2 - 0.1 ?

    0.299999999999999989

    - 0.200000000000000011

    - 0.100000000000000006

    = -0.000000000000000028

    What MATLAB calculates:

    32

    Floating Point Arithmetic (2)

    a

    b+

    c+

    a + b + c=

    Summation of floating point numbers

  • 7/25/2019 An Introduction to Solvers PLECS

    17/66

    Backward Euler

    Develop Taylor Seriesaround a time in the future:

    Must be solved iterativelyfor the unknown x(t*+h)

    Implicitintegrationalgorithm

    33

    Numerical Experiment (Revisited)

    Scalar system

    Analytical solution

    Backward Euler

    34

  • 7/25/2019 An Introduction to Solvers PLECS

    18/66

    Stability Domain of Backward Euler

    Integration algorithm

    Stable if the eigenvalues ofAhare outside a unit circle

    around (1, 0)

    35

    Stability Domain

    36

    Dopri

    RadauTustin

  • 7/25/2019 An Introduction to Solvers PLECS

    19/66

    Higher Order Integration Methods

    E.g. Explicit Midpoint Rule

    Two stages (one intermediate, one final)

    2nd order accurate

    More accurate than two FE steps of half size!

    37

    Event Detection

    Define auxiliary functions that help locate discontinuities.

    Function zeros must coincide with the discontinuities.

    38

  • 7/25/2019 An Introduction to Solvers PLECS

    20/66

    Missed Events - Problem

    39

    B

    A

    Output

    0

    0

    Time step1 Time step2

    Missed Events - Solution

    40

    B

    A

    Output

    0

    0

    1

  • 7/25/2019 An Introduction to Solvers PLECS

    21/66

    PWM Generation

    41

    A

    B

    !

    "#$%

    $& $&'(

    "&

    "&'(

    Trapezoidal Rule

    42

  • 7/25/2019 An Introduction to Solvers PLECS

    22/66

    Time Step Selection

    Accuracy is indirectly determined by the time step

    To ensure accuracy, reduce the time step and observe any

    changes in the outputOr: Compare with a continuous simulation

    Continuous waveform

    Highest transient frequency constrains sample time

    Set tsample< ttransient/10

    Integration underestimate approx 3%

    Switched system

    Switches turned on at sample instants

    Set tsample< tsw/100

    43

    Comparison - Continuous and Discrete solver

    44

    Simulated current

    Time steps:

    Continuous: tolrel= 10-6

    Discrete: ts = 50"s

    Underdamped RLC circuit

  • 7/25/2019 An Introduction to Solvers PLECS

    23/66

    Conclusion

    Variable step solver operation

    Causes of model stiffness

    Solutions to stiffnessExplicit (non-stiff) vs. Implicit (stiff) solvers

    Limits of stability

    Limits of numerical accuracy

    Event detection

    45

    46

    Plexim GmbH

    Tips to Achieve a Fast Simulation

  • 7/25/2019 An Introduction to Solvers PLECS

    24/66

    47

    Introduction

    The problemLarge simulation models can become slow

    Many states, detailed component modelsSpeeding up the simulation

    Model simplification

    Model tuning

    Real-time accelerator

    Averaged modeling

    Efficient PWM generation

    Example - Three phase inverter

    48

    Simplification of PV Cell Model

    Exact model: accounts for non-linear VI characteristicNeeded for implementing MPPT simulation

    Temperature and insolation dependency also important

    Insolation = 1000 W/m2

    T = 25 CMPP occurs at 17.6 V

  • 7/25/2019 An Introduction to Solvers PLECS

    25/66

    49

    Diode PV Cell Model

    Current = fn(voltage, insolation,temp)

    Cell model

    Shockley diode eq.

    I

    Reference:

    50

    PV Lookup Table Implementation

    Simplified implementation

    Voltage-controlled current source

    Capacitor included to add a state and avoid an algebraicloop

    Precalculated PV data

  • 7/25/2019 An Introduction to Solvers PLECS

    26/66

    51

    Model Tuning

    Simulation settings.

    Choose the correct solver.

    Variable time step solver.

    Reducing the switching frequency reduces the computationaloverhead.

    Blockset StandaloneNon-stiff ode45 Dopri

    Stiff ode23tb/ode15s Radau

    52

    Real Time Accelerator

    Converts model into c-code.

    Compiles executable.

    Runs as native rather than interpreted program.

    PLECS circuit converted into C-code.

    Automatically integrated with Simulink c-code.

    Speed gain = 2 - 5 times.

    Generate and compile takes 20 seconds.

  • 7/25/2019 An Introduction to Solvers PLECS

    27/66

    53

    Averaged Converter Modeling

    Averaged converter models

    Retain the low frequency dynamics.

    Averages switching action over one cycle.Requires specialized knowledge of topology.

    Speed gains are an order of magnitude.

    Procedure

    Average inverter model.

    Average space vector modulation.

    Break algebraic loops.

    54

    Averaging a Three Phase Converter

    Full switching model

    Simulates exact electrical dynamics.

    Switching action slows down the simulation where slower dynamics arestudied.

  • 7/25/2019 An Introduction to Solvers PLECS

    28/66

    Inverter Leg

    55

    d=0.3

    d.T

    Vdc

    d.Vdc

    d.ia

    ia

    Averaged Inverter Leg

    56

    Va modeled using as a controlled voltage source

    idc modeled as a controlled current source

  • 7/25/2019 An Introduction to Solvers PLECS

    29/66

    57

    Averaged Inverter Model

    Assumes AC voltages are ideally imposed

    Used for rotor-side and grid-side converter

    Averaging of inverter legs A and B

    58

    Averaging Space Vector Modulation

    Converter Vdq* to ma, mb, mcUse 3 phase PWM.

    Extend operating range using overmodulation.

    Approximation of space vector modulation with a continuous modulation index

  • 7/25/2019 An Introduction to Solvers PLECS

    30/66

    59

    Overmodulation

    Add zero-sequence signal to modulation index

    Reference: Vector Control of a Double-Sided PWM Converter and Induction Machine Drive, R. Ottersten

    60

    Algebraic Loops

    What?

    Multiple direct feedthrough blocks connected in a loop.

    PLECS continuous inputs appear as a direct feedthrough system toSimulink.

    In feedback control systems, this will cause an algebraic loop.

    Problem: Algebraic loops must be solved iteratively

    The simulation time of each step is increased

  • 7/25/2019 An Introduction to Solvers PLECS

    31/66

    61

    Breaking Algebraic Loops

    Option 1. Use memory block or similar

    Time delay causes instability.

    Step size may need to be limited.Option 2. Use a low pass filter

    The extra state breaks the algebraic loop.

    Time constant must be chosen with care.

    Provides more deterministic behavior with variable stepsimulation.

    Breaking an algebraic loop with a low-pass filter.

    62

    Average DC-DC Converter Modeling

    Average switch cell modeling

    Replace switch/diode combination with a voltage current source.

    Ref: Fundamentals of Power Electronics, Erickson & Maksimovic

    Equations

    I2= (1 - d)/I1

    V1= (1 - d)/V2

  • 7/25/2019 An Introduction to Solvers PLECS

    32/66

    63

    Simplification of Current Controlled Converters

    Boost converter is current controlled

    Can replace the inductor with a current source.

    Efficient PWM Generation in PLECS

    Doubly fed induction generator example, 0.1 s simulation, PLECS Blockset

    Sampled PWM: 29.6 s

    Continuous PWM: 45.1 s

    64

    Sampled PWM Continuous PWM

    => 52 % faster

  • 7/25/2019 An Introduction to Solvers PLECS

    33/66

    65

    Control aims

    Sinusoidal input currents

    Regulated dc bus voltage

    Example - Three Phase Boost Rectifier

    Block Diagram

    66

    PWM

    Stiff systemSimulated for 0.2 s in PLECS Blockset & Standalone

  • 7/25/2019 An Introduction to Solvers PLECS

    34/66

    Results - PLECS Blockset

    67

    Controls in Simulink

    ode23tb solver used (stiff)

    Results - PLECS Standalone

    68

    Radau solver used (stiff)

  • 7/25/2019 An Introduction to Solvers PLECS

    35/66

    Conclusion

    Choose the right solver for the job (stiff or non-stiff)

    Use sampled PWM

    Make appropriate simplificationsFor extremely large models:

    PLECS Standalone

    Real-time workshop

    Averaged converter modeling

    69

    70

    An Introduction to Thermal Modelingand Simulation

    Plexim GmbH

  • 7/25/2019 An Introduction to Solvers PLECS

    36/66

    Why Thermal Simulation?

    Reduce development time

    Predict performance and investigate keytradeoffs early in the design process

    Thermal measurements can be difficult andtime consuming

    71

    72

    Sources of Thermal Losses

    Passive components

    Resistive power loss: ploss(t) = vR(t) iR(t)

    Loads e.g. break resistors

    Filters

    Winding resistance

    Power semiconductors

    Conduction lossSwitching loss

  • 7/25/2019 An Introduction to Solvers PLECS

    37/66

    73

    Semiconductor Losses

    Conduction loss

    Switching loss

    Gate signal

    74

    Switching Losses

    Switching energy loss dependent on:

    Blocking voltage, device current, junction temperature, gate drive

    Eon= f(Vce, Ic, Tj, Rg)

    Turn on Turn off

  • 7/25/2019 An Introduction to Solvers PLECS

    38/66

    75

    Example IGCT Turn-off: Varying Stray Inductance

    Courtesy ABB

    0.0

    1.5

    3.0

    4.5kV

    0.0

    1.0

    2.0

    3.0kA

    VPK= 3800V

    VDC = 2 kV

    TJ = 125C

    5 10 15 s

    300 nH (10.5 Ws)

    800 nH (12 Ws)

    1500 nH (13.5 Ws)

    tf!2.5s, ttail!7s

    76

    Switching Loss Calculation from Transients

    Accurate physical device models required

    Often unavailable

    Physical parameters often unknown during design phase.

    Stray inductance of PCB

    Small simulation steps required

    Large computation times

  • 7/25/2019 An Introduction to Solvers PLECS

    39/66

    77

    Lookup Table Approach for Switching Losses

    Instantaneous switching maintained for speed.

    Switching losses are read from a database after switchingevent.

    Esw= f(Tj, vblock, ion) (Rg= const)

    78

    Example Lookup Table

    Turn-off loss a function of:

    Current before switching

    Voltage after switching

    Temperature at switching

    Rgis assumed constant

    Exact loss found using

    interpolationNote the voltage andcurrent polarities!

  • 7/25/2019 An Introduction to Solvers PLECS

    40/66

    79

    Semiconductor Conduction Losses

    On-state loss

    Conduction profile is nonlinear:

    von= f(ion, Tj).Conduction profile stored inlookup table

    Exact voltage found usinginterpolation

    Conduction power loss:

    ploss(t) = von(t) ion(t)

    Off-state loss

    Negligible - low leakage current

    80

    Simulation of an Electrical-Thermal Model

  • 7/25/2019 An Introduction to Solvers PLECS

    41/66

    81

    Combined Electrical-Thermal Simulation

    Thermal and electricaldomains not coupled

    Semiconductor losses dontappear in electrical circuit

    Energy conservation can bemaintained by subtractingthermal losses from electricalcircuit

    Switching losses added overzero time

    Filtered by large capacitanceof thermal circuit

    82

    Semiconductor Thermal Behavior

  • 7/25/2019 An Introduction to Solvers PLECS

    42/66

    83

    Verification of Lookup Table Approach

    IGBT loss modeling using an ideal switch and lookup table

    Simulation speed increased by a factor of 20

    Good agreement with measurements

    Pt - simulated IGBT lossPtm - measured IGBT loss

    Thermal Modeling of a Pulsed Resonant Converter

    84

    Acknowledments: Dr. Fabio Carastro, University of Nottingham

    Simulation results

    Experimental results

    "t = 1.4!

    "t = 1.4!

  • 7/25/2019 An Introduction to Solvers PLECS

    43/66

    85

    A combined electrical-thermal model

    Losses, heatsink, ambient temperature.

    How are these represented using PLECS?

    86

    Thermal Domain

    Thermal circuit analogous to electrical circuit.

    Thermal and electrical circuits solved simultaneously.

  • 7/25/2019 An Introduction to Solvers PLECS

    44/66

    87

    A complete electrical-thermal model

    The heatsink is the interface between the two domains

    Automatically absorbs component losses

    Propagates temperature back to semiconductorsThermal impedance modeled with RC elements

    88

    Hierarchical Modeling of Thermal Structures

    Junctions

    Dual IGBTmodule

    Heatsink

    IGBT Plate

  • 7/25/2019 An Introduction to Solvers PLECS

    45/66

    89

    Different Thermal Equivalent Networks

    Cauer equivalent

    Physics based thermal equivalentcircuit

    Each Rthand Cthpair represents a

    physical layer in the thermal circuit.

    Foster equivalentCurve fitting approach based onheating and cooling characteristics.

    No correspondence between Rth,nresp. Cth,n and the physical structure!

    Any modification of the systemrequires recalculation of all values

    Junction-Case Thermal Impedance

    Define in thermal editor to observe junction temp fluctuations

    Foster coefficients often given in datasheet

    90

    Example junction-case thermal impedance

    Foster network coefficients

  • 7/25/2019 An Introduction to Solvers PLECS

    46/66

    Foster Network Pitfalls

    Only accurate if reference point x is a constant temperature

    Cannot be arbitrarily extended beyond point x

    Tjuncimmediately affected by temperature changes at x

    91

    Reference: M. Mrz and P. Nance, Thermal modeling of power electronic systems, www.iisb.fraunhofer.de

    Solution 1 - Use First Order Cauer Network

    Calculate #from 63% R value

    C = #/R

    92

    Vcreaches 63.2% Vfinalafter #

  • 7/25/2019 An Introduction to Solvers PLECS

    47/66

    Solution 2 - Use a Constant-Temperature Heatsink

    Set Cheatsinkto 0

    Set heatsink temperature with a const temperature source

    Foster network can be used for junction thermal impedance

    93

    Measuring Average Device Losses

    ConceptCalculate total switching

    and conduction energy lostduring a sw cycle

    Output as an average

    power pulse during thenext cycle

    94

    ImplementationBased on a C-Script block

    Conduction and switching losses measure with a Probe

  • 7/25/2019 An Introduction to Solvers PLECS

    48/66

    95

    Challenge: Large Thermal Time Constants

    Thermal time constants: 0.1 100 s

    Switching frequency: 1 100 kHz

    Long simulation time until thermal steady-state is reached

    Example

    96

    Newton Raphson Analysis

    Newton iterationApproach: Finding the roots of

    : initial state vector : final state vector after a time T

    Iterative solution

    Jacobian J calculated numerically

    requires n+1 simulation runs (for n statevariables)

  • 7/25/2019 An Introduction to Solvers PLECS

    49/66

    97

    Newton Raphson: Convergence

    Typically converges after

  • 7/25/2019 An Introduction to Solvers PLECS

    50/66

    Thermal Loss Feedback 1

    99

    Efficiency:

    P1,Pi=100W Po=100WP2=95W

    Thermal Loss Feedback 2

    100

    Efficiency:

    P1=105W Po,P2=100WPi=100W

  • 7/25/2019 An Introduction to Solvers PLECS

    51/66

    Thermal Loss Feedback 3

    101

    Efficiency:

    Thermal feedback:

    P1=105.3W Po,P2=100WPi=100W

    Physical RdsImplementation

    102

    Rdsconstant during switching cycle

    Resistance resolution:

  • 7/25/2019 An Introduction to Solvers PLECS

    52/66

    103

    Obtaining Switching Loss Data

    Experimental measurements

    Switching losses highly dependent on gate drive circuit andstray parameters

    Use a switching loss setup to characterize loss dependency onvoltage and current for two temperatures

    Datasheets

    Given for a specific gate resistance and stray inductance

    Good approximations can be made by extrapolatingmanufacturers data (or asking for complete lossmeasurements)

    Conclusion

    Fast & accurate thermal simulation using lookup tables

    Operation of a combined electrical-thermal simulation

    Calculating average device losses

    Steady state analysis using Newton Raphson analysis

    104

  • 7/25/2019 An Introduction to Solvers PLECS

    53/66

    105

    Advanced PLECS Tools

    Plexim GmbH

    106

    Advanced Tools

    C-Script block

    Control design tools

    Steady-state analysis

    AC sweep

    Impulse response analysis

    Loop gain analysis

    Other

    Subsystem - custom components

  • 7/25/2019 An Introduction to Solvers PLECS

    54/66

    Small Signal Analysis Tools

    Possible workflow for controller design using PLECS tools:

    107

    AC Sweep Analysis

    Impulse Response Analysis

    Converter Open LoopTransfer Function

    Voltage controller designFreq domain

    Loop Gain Analysisplbodefunction

    Calculate loop gain

    Gain/phasemargins met?

    Verify with simulation

    108

    Frequency Sweep

    Algorithm:

    For each frequency:

    1. Run steady-state analysis

    2. Apply sinusoidal perturbation

    3. Extract system response using Fourier analysis

    Caveats:Period length: least common multiple of system period andperturbation period

    Computationally expensive

  • 7/25/2019 An Introduction to Solvers PLECS

    55/66

    109

    Impulse Response Analysis

    Impulse responseof a buck converter

    Transfer function:

    110

    Impulse Response Analysis

    The original Laplace transform:

    Apply some math

    Reference: D.Maksimovic, Computer-Aided Small-Signal Analysis Based on Impulse Response of DC/DCSwitching Power Converters, IEEE Trans. On Power Electronics, Vol. 15, No. 6, Nov. 2000, pp. 1183-1191

  • 7/25/2019 An Introduction to Solvers PLECS

    56/66

    111

    Buck Converter: Transfer Function

    112

    Stability Verification

    Loop Gain

    Use Loop Gain Analysis Tool (Blockset) AC Sweep (Standalone), or

    Calculate using plbode function

    Measure gain and phase margins to check stability

  • 7/25/2019 An Introduction to Solvers PLECS

    57/66

    Custom Components

    Why?

    Support the top-down design approach

    Easy to reuse, configure and measureCustom component features

    Formed using the subsystem

    User defined parameter, icon, initialisation commands andprobe signals

    ! All machines in PLECS are custom components

    113

    0

    0.5

    1

    0510152025

    0

    0.5

    1

    1.5

    2

    2.5

    3

    3.5

    4

    Voltage (V)Insolation (kW/m2)

    Current(A)

    Example - PV String Model

    114

    Current surface datain lookup table

  • 7/25/2019 An Introduction to Solvers PLECS

    58/66

    Masked Subsystem Implementation

    115

    116

    C-script Block

    Plexim GmbH

  • 7/25/2019 An Introduction to Solvers PLECS

    59/66

    117

    What can it do?

    C-control code emulation

    Model custom components

    Efficient sequence generationState machine modeling

    118

    Function call interface

    Solver operation (PLECS or Simulink)

    Some function calls dependent on continuous or discrete states

  • 7/25/2019 An Introduction to Solvers PLECS

    60/66

    Main loop

    Always executed

    Output() called at least onceUpdate() called after Output if discrete state variables exist

    Integration loop

    Executed if continuous states defined in settings

    Used for solving continuous differential equations

    Continuous states used for declaring DEs

    Event detection loop

    Executed if a zero crossing signal defined in settings

    For detecting the exact instant of a discontinuity

    119

    Function calls in C-script block

    120

    C-Script parameter window

  • 7/25/2019 An Introduction to Solvers PLECS

    61/66

    121

    Code editor window

    122

    Sample time setting

    Discrete

    Value: +ve

    Fixed sample time

    Continuous

    Value: 0

    Inherited from solver

    VariableValue: -2

    At each time step the NextSampleHit must be specified.

  • 7/25/2019 An Introduction to Solvers PLECS

    62/66

    Hybrid fixed and variable step setting

    Fixed and variable time

    Format: [1/fs,0; -2, 0]

    First row element is the time settingSecond element is the offset time

    Continuous, only major time steps

    Format: [0, -1]

    C-Script not called during integration or event detection loop

    Eliminates unnecessary calls for certain blocks.

    Use for blocks with discrete output. Example: Lookup table

    123

    Pitfalls - cascading C-Script blocks

    124

    Controller cycle hit time - fixed step:Cycle time obtained by multiplication: tn = 1/fs*n

    PWM cycle hit time - variable step:Cycle time is obtained by addition: tn = 1/fs+ 1/fs + ... n

    Synchronization may be lost due to accumulated rounding error

    Solution

    Use a hybrid fixed/variable step setting for PWM block

  • 7/25/2019 An Introduction to Solvers PLECS

    63/66

    125

    Macros

    For interacting with model or solver

    Examples

    Input(0)Output(0)

    NextSampleHit

    CurrentTime

    126

    Example - Space Vector Control

    Three phase boost rectifier

    Sinusoidal input currents

    Regulated dc bus voltage

  • 7/25/2019 An Introduction to Solvers PLECS

    64/66

    127

    Control Strategy

    Outer voltage control loopInner decoupled current control loop

    Space vector modulation

    128

    Space vector modulation

    Timing calculationSwitch signal generation

    C-script block1

    C-script block2

  • 7/25/2019 An Introduction to Solvers PLECS

    65/66

    129

    Efficient sequence generation

    Typical switching sequence

    Space vector modulation

    Option blanking delayMethod 1: Fixed time step

    Test if t > thit, apply new switch signal

    Requires small steps for accuracy => increased computationaloverhead

    Method 2: Variable time stepCalculate hit times at beginning of switching sequence

    Fewer simulation steps more efficient

    130

    Example: PWM with blanking

    Calculate transition times, t1,t2,t3,t4at beginning of cycle

    State machine program executes at each transition:

    Switching signal is updated

    NextSampleHit is updated

    Bipolar switching signal 1: S1, S4 on-1: S2, S3 on

  • 7/25/2019 An Introduction to Solvers PLECS

    66/66

    Efficient state machine implementation

    Event driven

    Useful for controller mode sequencing.

    Example: Startup, overload, shutdown.

    131

    External event

    C-ScriptState machine

    >

    Relational operator- generates major step

    Time setting:Simulation model: variableC-Script: continuous

    if (IsMajorStep) test_input(v1,i1);

    update_state_machine();

    v1

    External event >i1

    Conclusion

    Implement complex nonlinear and/or piecewisefunctions without complex block diagrams

    Model custom components and controls

    Generate efficient sequencing with exact but flexibletime step control

    State machine modeling

    Incorporate external C code for hardware controllers