Sie sind auf Seite 1von 20

REAL TIME DSP-BASED 3-PHASE SIGNAL SYNTHESIZER

REAL TIME DSP-BASED 3-PHASE SIGNAL SYNTHESIZER


OUTLINE

Motivation, issues Example test signals Signal generation: block diagram Implementation in C Programming organization, benefits, rules
DSP BASED REAL TIME TEST SIGNAL GENERATOR 2

MOTIVATION
Example application: 3-phase power electronics - control synchronization Requirement for various test signals:
phase & frequency step modulation amplitude step modulation notching imbalance other distortion & noise types

OBJECTIVE: minimize code development effort, from block diagram to code


DSP BASED REAL TIME TEST SIGNAL GENERATOR 3

UNDERLYING ISSUES
Development testing in real time Availability and affordability of real time DSP, ex.: Analog Devices ADSP-21161 200 MHz floating point DSP Programming: block diagram level programming preferred object oriented approach Ex.: MatLab/Simulink, C++ BUT: excessive underlying overhead and code, reduced efficiency and execution speed
DSP BASED REAL TIME TEST SIGNAL GENERATOR 4

PROPOSED APPROACH
Given C language:
popular efficient compilation interfaceable to assembly language code struct-ure based syntax, and function pointers Transportability across different h/w platforms

Can effectively translate block / data flow diagram level design into C code, for most efficient execution, development, and maintainability Important point: insist on rigorous, but simple, programming rules
DSP BASED REAL TIME TEST SIGNAL GENERATOR 5

EXAMPLE TEST SIGNALS


3-phase signal synthesis, with:
Harmonic distortion (BD) Notching distortion (CDN)
AS BD

CDN

DSP BASED REAL TIME TEST SIGNAL GENERATOR

SYNTHESIS: FUNCTIONAL BLOCK DIAGRAM


Main functional blocks:
3-phase sinusoid generator, with FM and PM (here: fixed frequency 3-phase harmonic addition 3-phase notching DAC analog output
DAC 0 1 2 3 4 5 6 7 V0 V1 V2 V3 V4 V5 V6 V7

Gen_3phase_0
3- GENERATOR

AS

BD
Dist_3phase_0
3- HARMONICS

CDN
Notch_3phase_0
3- NOTCHING 3-phase signals

Input Ko Ko o o

A B C

A B C

A B C H(k)

A B C

Notch specs

A B C

a b c

{ h1 , h2 , h3 }

{ Ni }

DSP BASED REAL TIME TEST SIGNAL GENERATOR

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 #include DSP_hardware.h // Pre-compiled building blocks // Hardware specific declarations

// 2. Declare functional blocks, assigning names (optional; required forward // declaration when feedback is involved, ex. PLL): // Type name // // State_3phase Distortn_3ph Notching_3ph user-defined (type names defined in Gen_3phase.h) variable (object) name Gen_3ph_0 ; Dist_3ph_0 ; Notch_3ph_0 ; // 3-phase clean signal generation unit // Harmonic distortion unit // Notching distortion unit

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


DSP BASED REAL TIME TEST SIGNAL GENERATOR 8

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 phase 0.2*pi, 0.25*pi, 0.2 , // Specs for 3 notches: 1.2*pi, 1.30*pi, 0.5 , // start angle, end, depth 1.6*pi, 1.70*pi, 0.0 };
DSP BASED REAL TIME TEST SIGNAL GENERATOR 9

DEFINING A LIST OF OBJECTS FOR EXECUTION


// 4. Define a list of objects to execute: // Object: defined in file Gen_3phase.h Object *Gen_3ph_list [ ] = { (void*) &Gen_3ph_0 , (void*) &Dist_3ph_0 , (void*) &Notch_3ph_0 , 0}; // Define list of objects to execute // Address of 3-phase sine generation unit // Address of harmonic distortion unit // Address of notching distortion unit // 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 } ;

DSP BASED REAL TIME TEST SIGNAL GENERATOR

10

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/p pObject_list = Gen_3ph_list ; // List of objects to execute Init_DSP_hardware (DSP_isr); // Hardware specific initialization // Execute function DSP_isr at sampling rate while (1) ; // Repeat forever, or process user input } // main()

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

DSP BASED REAL TIME TEST SIGNAL GENERATOR

11

CODE DEVELOPMENT: 3 STAGES


1. Application level: from block diagram to C code; as in previous example by application programmer: minimal C skills, follow example template specify: - various objects (variables) - operating parameters - connections, i.e. via addresses (C & syntax) Underlying, pre-existing functional units: > in pre-compiled (object) library > defined (described) in pre-existing header (.h) file
Basic I/O at hardware level for specific platform
DSP BASED REAL TIME TEST SIGNAL GENERATOR 12

2.

3.

BENEFITS
Application developed at level of block diagram: clearest and simplest Simple rules to follow, easily copied from example template, minimal C programming skills required Object-oriented approach, without undue underlying overhead; minimal reduction of execution efficiency C code easily transportable (compiled) for any hardware platform

MOST IMPORTANT: strict adherence to programming rules, best captured in example templates
DSP BASED REAL TIME TEST SIGNAL GENERATOR 13

EXECUTING A LIST OF OBJECTS


Given, in Gen_3phase.h:
typedef struct Object { pFunc (*pFn)(struct Object *pS) ; } Object ; // Common to all objects

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++ ) (*pList) -> pFn(*pList) ; } // DSP_func()
DSP BASED REAL TIME TEST SIGNAL GENERATOR 14

// Repeat till end of list // Call function, pass Object address

TRANSLATING BLOCK SYMBOL TO CODE

SOURCE BLOCK DIAGRAM NOTATION Signal flow Input Ko o

Source Signal (variable) Source Signal (variable)

3- GENERATOR

Angle Freq

Code: Ref. To (addr)

3- GENERATOR

*p *pF

A B C

A B C

Constant

Constant

Handler function

KO

(void*) &Gen_3ph_0

DSP BASED REAL TIME TEST SIGNAL GENERATOR

15

OBJECT DEFINITION 3-PHASE SINE GENERATOR


underlying, pre-existing, previously defined, user-defined object types, found in file Gen_3phase.h
C 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) ; float Phase, Wo , Ko , *pFctrl, *pPhCtrl , A, B, C ; } State_3phase ;

// MUST = Gen_3phase // Current phase angle, rads // Center frequency, rad./sec. // Freq. control sensitivity // Freq. control signal addr. // Phase control signal addr. // 3-phase output signals // Name of new data type

DSP BASED REAL TIME TEST SIGNAL GENERATOR

16

INTERNAL OBJECT BEHAVIOUR


underlying, pre-existing, previously compiled, user-defined object type handler function, in file Gen_3phase.C
of 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 ; pG3ph->Phase += (*(pG3ph->pFctrl)) * pG3ph->Ko ; if (pG3ph->Phase > pi) pG3ph->Phase -= 2*pi ; pG3ph->A = sin (pG3ph->Phase + *pG3ph->pPh_ctrl) ; pG3ph->B = sin (pG3ph->Phase + *pG3ph->pPh_ctrl - 2*pi/3) ; pG3ph->C = - pG3ph->A - pG3ph->B ; } // Gen_3phase()
DSP BASED REAL TIME TEST SIGNAL GENERATOR 17

// Advance phase // Freq ctrl input // Keep phase: // -pi < Phase < pi // Phase ctrl input // Phase C = -A B

NOTCHING OBJECT DEFINITION


underlying, pre-existing, previously defined, user-defined object types, found in file Gen_3phase.h C keywords: typedef and struct // This defines, once and for all, the notching data (object) type, // its interface, and internal state variables:
typedef struct Notching_3ph { void (*pFn)(struct Notching_3ph *pS) ; float *pA, *pB, *pC, *pPhase , // 3 times: notch start angle, notch width, and depth: N[9] , A, B, C ; } Notching_3ph ; // MUST = Notch_3phase // Source 3-phase A-B-C // Phase angle // A, C, C: Outputs // Name of new data type

DSP BASED REAL TIME TEST SIGNAL GENERATOR

18

CONCLUSIONS
Based on these simple organization and guidelines, and strict adherence to simple rules, other functional units can 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 to C code Collection of functional objects, in C, transportable to any platform Hardware level I/O for specific platform

DSP BASED REAL TIME TEST SIGNAL GENERATOR

19

THANK YOU

DSP BASED REAL TIME TEST SIGNAL GENERATOR

20

Das könnte Ihnen auch gefallen