This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS320F28377S: Generation of sinusoidal signals using the SGEN library

Part Number: TMS320F28377S

Tool/software: TI C/C++ Compiler

Hi all

I would like to generate a signal composed of several harmonics to test a mobile effective value calculation algorithm.

I'm trying to use the SGEN library that works well for the generation of a harmonic, but I'm having trouble incorporating a second harmonic, for example the first and third (50/60 Hz and 150/180 Hz)

In the "signal generator library" document of 2011, it is not clear if it is possible to generate several harmonics, nor does it give examples.

This is the confuguration that I am trying
/ * Create an instance of Signal generator module * /

SGENTI_1 sgen_1 = SGENTI_1_DEFAULTS; // Low THD without generator
SGENTI_1 sgen_2 = SGENTI_1_DEFAULTS;

// Signal Generator module initialization fs_0 = 50 Hz
    sgen_1.offset = 0;
    sgen_1.gain = 0x1fff;
    sgen_1.freq = 2684;
    sgen_1.step_max = 2000;
    sgen_1.alpha = 0;

    sgen_2.offset = 0;
    sgen_2.gain = 0x1fff;
    sgen_2.freq = 8053;
    sgen_2.step_max = 2000;
    sgen_2.alpha = 0;
********************************************** *********************
//
// Next two lines for debug only to halt the processor here
// Remove after inserting ISR Code
//
Timer ISR @ 20kHz

    sgen_1.calc (& sgen_1);
    s1 [i] = sgen_1.out;

    sgen_2.calc (& sgen_2);
    s2 [i] = sgen_2.out;

********************************************** ***********
LINKER:

   SINTBL:> RAMGS3, PAGE = 1
}

Do I have to generate 2 tables? If so, how is it done?

Thank you very much to all

regards

Juan

  • Hi Juan,

    Please give me a day or so to look over your issue and get back to you.
    Thanks,
    Sira
  • Juan,

    After analyzing the library and examples, I think the SGEN library is not equipped to CONTINUOUSLY generate independent waveforms. It does seem DOABLE to generate independent waveforms ONE TIME, but not sample by sample, but the entire buffer. For example, in your case above, you will have to run a loop and generate all the samples for buffer s1, and only then begin generating samples for buffer s2.

    Can you try this approach and let me know if it works? Also, just for confirmation, can you try the opposite approach i.e. generate samples for both s1 and s2 inside the SAME LOOP. I would expect this approach not to work.

    Thanks,
    Sira
  • Juan,

    I didn't explicitly answer this question - I don't believe you need two tables. The issue is more indexing through the tables with the pointers and associated computations (which is what the SGEN ASM routines do) than the tables themselves.

    Thanks,
    Sira

  • Thank you Sira, I raised the program as you proposed and in this way you can generate two signals of different characteristics.

    Thanks again

    Juan

        if(Estados_S1_S2.Fin_Gen_S1 == false)
        {
            sgen_1.calc(&sgen_1);
            s1[i] = sgen_1.out;
    
            i++;
            if(i == SIGNAL_LENGTH + 1)
            {
                i = 0;
                Estados_S1_S2.Fin_Gen_S1 = true;
                Estados_S1_S2.Fin_Gen_S2 = false;
            }
    
        }
    
        if(Estados_S1_S2.Fin_Gen_S2 == false)
        {
            sgen_2.calc(&sgen_2);
            s2[i] = sgen_2.out;
    
            i++;
            if(i == SIGNAL_LENGTH + 1)
            {
                i = 0;
                Estados_S1_S2.Fin_Gen_S2 = true;
            }
        }
    
        if(Estados_S1_S2.Fin_Gen_S1 == true && Estados_S1_S2.Fin_Gen_S2 == true)
        {
            sT[i] = s1[i] + s2[i];
            sine_mains.v = 0.8*((float)sgen_1.out/(float)ganancia_adaptación);      //Generación de la señal senoidal
    
            POWER_MEAS_SINE_ANALYZER_run(&sine_mains);
        //  guiIrms=sine_mains.iRms*I_MAX_SENSE;
            guiVrms = sine_mains.vRms*VAC_MAX_SENSE;
        //  guiPrms=sine_mains.pRms*VAC_MAX_SENSE*I_MAX_SENSE;