Real Time DSP Based 3phase Signal Synth

download Real Time DSP Based 3phase Signal Synth

of 20

Transcript of Real Time DSP Based 3phase Signal Synth

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    1/20

    REAL TIME DSP-BASED3-PHASE SIGNAL

    SYNTHESIZER

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    2/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    2

    REAL TIME DSP-BASED3-PHASE SIGNAL SYNTHESIZER

    OUTLINE

    Motivation, issues

    Example test signals

    Signal generation: block diagram

    Implementation in CProgramming organization, benefits, rules

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    3/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    3

    MOTIVATION

    Example application: 3-phase powerelectronics - control synchronization

    Requirement for various test signals: phase & frequency step modulation

    amplitude step modulation

    notching

    imbalance

    other distortion & noise types

    OBJECTIVE: minimize code developmenteffort, from block diagram to code

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    4/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    4

    UNDERLYING ISSUES

    Development testing in real timeAvailability and affordability of real time DSP, ex.:

    Analog Devices ADSP-21161 200 MHz floatingpoint DSP

    Programming: block diagram level programmingpreferred

    object oriented approach

    Ex.: MatLab/Simulink, C++

    BUT: excessive underlying overhead and code,reduced efficiency and execution speed

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    5/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    5

    PROPOSED APPROACH

    Given C language:popular

    efficient compilation

    interfaceable to assembly language code

    struct-ure based syntax, and function pointersTransportability across different h/w platforms

    Can effectively translate block / data flow diagramlevel design into C code, for most efficient

    execution, development, and maintainability Important point: insist on rigorous, but simple,

    programming rules

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    6/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    6

    EXAMPLE TEST SIGNALS

    3-phase signal synthesis, with:

    Harmonic distortion (BD)

    Notching distortion (CDN)

    AS BD CDN

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    7/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    7

    SYNTHESIS: FUNCTIONAL BLOCK DIAGRAM

    Main functional blocks:

    3-phase sinusoid generator, with FM and PM (here: fixedfrequency

    3-phase harmonic addition

    3-phase notching

    DAC analog output

    3- GENERATOR

    A

    B

    Input C

    Ko o

    3- HARMONICS

    A A

    B B

    C C

    H(k)

    3-phase

    signals

    ab

    c

    3- NOTCHING

    A A

    B B

    C Notch C

    specs

    { Ni }{ h1 , h2 , h3 }Ko o

    DAC

    0

    1

    2

    3

    4

    5

    6

    7

    V0V1V2V3V4V5V6

    V7

    AS BD CDNGen_3phase_0 Dist_3phase_0 Notch_3phase_0

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    8/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    8

    TOP LEVEL CODE IMPLEMENTATION IN C

    // The translation of the block diagram into C code:

    // 1. Refer to pre-defined data types and prototypes:

    #include Gen_3phase.h // Pre-compiled building blocks

    #include DSP_hardware.h // Hardware specific declarations

    // 2. Declare functional blocks, assigning names (optional; required forward

    // declaration when feedback is involved, ex. PLL):

    //Type name user-defined (type names defined in Gen_3phase.h)

    // variable (object)

    // name

    State_3phase Gen_3ph_0 ; // 3-phase clean signal generation unitDistortn_3ph Dist_3ph_0 ; // Harmonic distortion unit

    Notching_3ph Notch_3ph_0 ; // Notching distortion unit

    // NOTE: DAC output unit pre-existing in DSP hardware pre-compiled library

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    9/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    9

    DEFINE OBJECTS OPERATING PARAMETERS

    // 3. Define functional block operating parameters:

    State_3phase Gen_3ph_0 = // 3-phase generator unit{ Gen_3phase, 60*2*pi, 0, 0, 0 } ;

    // Handler, 60 Hz freq, no frequency or phase modulation

    Distortn_3ph Dist_3ph_0 = // Harmonic distortion unit

    { Dist_3phase, &Gen_3ph_0.A, &Gen_3ph_0.B, &Gen_3ph_0.C,// Handler, addresses of A-B-C and phase source signals

    &Gen_3ph_0.Phase, { 0.3, 0.05, 0.03 } } ;// generator phase, and specify 3-rd to 15-th odd harmonic levels

    Notching_3ph Notch_3ph_0 = // Define notching operator

    { Notch_3phase, &Dist_3ph_0.A, &Dist_3ph_0.B, &Dist_3ph_0.C,// Handler, addresses of A-B-C distorted signals

    &Gen_3ph_0.Phase, // Signal phase0.2*pi, 0.25*pi, 0.2 , // Specs for 3 notches:1.2*pi, 1.30*pi, 0.5 , // start angle, end, depth1.6*pi, 1.70*pi, 0.0 } ;

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    10/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    10

    DEFINING A LIST OF OBJECTS FOR EXECUTION

    // 4. Define a list of objectsto execute:

    // Object: defined in file Gen_3phase.h

    Object *Gen_3ph_list [ ] = // Define list of objects to execute

    { (void*) &Gen_3ph_0 , //Address of 3-phase sine generation unit

    (void*) &Dist_3ph_0 , //Address of harmonic distortion unit(void*) &Notch_3ph_0 , //Address of notching distortion unit

    0 } ; //0:mandatory end of list

    // 5. Define list of signals of interest for DAC output and scope observation:

    float Signals_3ph[8] = // 8 DAC outputs available

    { &Dist_3ph_0.A, &Dist_3ph_0.B, &Dist_3ph_0.C,

    &Gen_3ph_0.Phase, &Dist_3ph_0.B, &Notch_3ph_0.C } ;

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    11/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    11

    MAIN PROGRAM: INITIALIZATION

    // 6.Main program: initialize hardware and pointer to list of objects:

    void main (void) {pDAC_signals = Signals_3ph ; // List of signals for DAC o/ppObject_list = Gen_3ph_list ; // List of objects to execute

    Init_DSP_hardware (DSP_isr); // Hardware specific initialization// Execute function DSP_isr at sampling ratewhile (1) ; // Repeat forever, or process user input

    } // main()

    From perspective of main application programming: thats all,and the main present focus of interest

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    12/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    12

    CODE DEVELOPMENT: 3 STAGES

    1. Application level: from block diagram to C code; as in previousexample

    by application programmer: minimal C skills, follow

    example template

    specify:

    - various objects (variables)- operating parameters

    - connections, i.e. via addresses (C & syntax)

    2. Underlying, pre-existing functional units:

    > in pre-compiled (object) library

    > defined (described) in pre-existing header (.h) file

    3. Basic I/O at hardware level for specific platform

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    13/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    13

    BENEFITS

    Application developed at level of block diagram: clearestand simplest

    Simple rules to follow, easily copied from exampletemplate, minimal C programming skills required

    Object-oriented approach, without undue underlying

    overhead; minimal reduction of execution efficiency

    C code easily transportable (compiled) for any hardwareplatform

    MOST IMPORTANT: strict adherence to programmingrules, best captured in example templates

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    14/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    14

    EXECUTING A LIST OF OBJECTS

    Given, in Gen_3phase.h:

    typedef struct Object {pFunc (*pFn)(struct Object *pS) ; // Common to all objects

    } Object ;

    The following pre-exists in pre-compiled library:

    void DSP_func (void){ // Executed at sampling rate

    Object **pList = Gen_3ph_list ; // Point to object list

    for ( ; *pList ; pList++ ) // Repeat till end of list(*pList) -> pFn(*pList) ; // Call function, pass Object address

    } // DSP_func()

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    15/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    15

    TRANSLATING BLOCK SYMBOL TO CODE

    3- GENERATOR

    A

    B

    Input C

    Ko o

    SourceSignal

    (variable)

    Source

    Signal

    (variable)

    Constant Constant

    3- GENERATOR

    Angle

    Freq

    *p

    *pF

    A

    B

    C

    KO o

    Signal

    flow

    Code:

    Ref.

    To

    (addr)

    SOURCE BLOCK

    DIAGRAM NOTATION

    Handler

    function

    *

    (void*) &Gen_3ph_0

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    16/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    16

    OBJECT DEFINITION 3-PHASE SINE GENERATOR

    underlying, pre-existing, previously defined, user-defined object types,found in file Gen_3phase.hC keywords: typedef and struct

    // This defines, once and for all, the 3-phase generator data (object) type,// its interface, and internal state variables:

    typedef struct State_3phase {pFunc (*pFn) (struct State_3phase *pG3ph) ; //MUST = Gen_3phasefloat Phase, // Current phase angle, rads

    Wo , // Center frequency, rad./sec.Ko , // Freq. control sensitivity*pFctrl, // Freq. control signal addr.*pPhCtrl , // Phase control signal addr.A, B, C ; // 3-phase output signals

    } State_3phase ; // Name of new data type

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    17/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    17

    INTERNAL OBJECT BEHAVIOUR

    underlying, pre-existing, previously compiled, user-definedobject type handler function, in file Gen_3phase.Cof least interest to present discussion

    void Gen_3phase (State_3phase *pG3ph) {// This defines the internal operation of the 3-phase sine generator, with phase and// frequency modulation

    pG3ph->Phase += pG3ph->Wo ; // Advance phasepG3ph->Phase += (*(pG3ph->pFctrl)) * pG3ph->Ko ; // Freq ctrl input

    if (pG3ph->Phase > pi) // Keep phase:pG3ph->Phase -= 2*pi ; // -pi < Phase < pi

    pG3ph->A = sin (pG3ph->Phase + *pG3ph->pPh_ctrl) ; // Phase ctrl inputpG3ph->B = sin (pG3ph->Phase + *pG3ph->pPh_ctrl - 2*pi/3) ;pG3ph->C = - pG3ph->A - pG3ph->B ; // Phase C = -A B

    } // Gen_3phase()

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    18/20

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    19/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    19

    CONCLUSIONS

    Based on these simple organization and guidelines, andstrict adherence to simple rules, other functional unitscan be easily developed and added to library

    Simplified programming at top, block diagram equivalent,level, with minimal to no C programming skills required

    3 stages of development:

    Main application level, simplest translation from block diagram toC code

    Collection of functional objects, in C, transportable to anyplatform

    Hardware level I/O for specific platform

  • 8/3/2019 Real Time DSP Based 3phase Signal Synth

    20/20

    DSP BASED REAL TIME TESTSIGNAL GENERATOR

    20

    THANK YOU