calculate the true RMS value

SupportCommunity FPScript calculate the true RMS value

Ansicht von 5 Beiträgen - 1 bis 5 (von insgesamt 5)
  • Autor
    Beiträge
  • #12801
    MAZOYER ThomasMAZOYER Thomas
    Teilnehmer

    Hello,

    how can I calculate the “true” RMS value of a signal whose frequency varies ?
    I try with the formula of the RMS “Mean(MySignal, MEAN_SQUARE + CALC_BLOCK, xx)”, but as the frequency varies, the CALC_BLOCK “xx” varies to !

    My problem is with the Block-by-block calculation, where One value is calculated per interval, which interval is not constant due to frequency.

    In the example join, the interval lengh is more than 1000 points at the beginning, and around 50 points at the end so I can not calculate the RMS value by block.

    #8459
    MAZOYER ThomasMAZOYER Thomas
    Teilnehmer

    Hello,

    how can I calculate the “true” RMS value of a signal whose frequency varies ?
    I try with the formula of the RMS “Mean(MySignal, MEAN_SQUARE + CALC_BLOCK, xx)”, but as the frequency varies, the CALC_BLOCK “xx” varies to !

    My problem is with the Block-by-block calculation, where One value is calculated per interval, which interval is not constant due to frequency.

    In the example join, the interval lengh is more than 1000 points at the beginning, and around 50 points at the end so I can not calculate the RMS value by block.

    #9273
    Bernhard KantzBernhard Kantz
    Moderator

    The RMS value is a mean value, for a good estimation it is sufficient to average over enough full periods of the signal.
    To compute the RMS over single periods, one can use the FPScript function LevelCrossings() to determine the indices of upward zero crossings as boundaries in the signal to compute one RMS value per period.

    // indices of upward zero crossings (with 5 % hysteresis)
    Dim idx = LevelCrossings(IA, 0, 0.05 * Range(IA), EVENT_POSITIVE, EVENT_INDEX)
    
    // prepare output datasets in the desired length
    Dim rms_y = IA.Y[0L] # Shape(idx[1L,-1L])
    Dim rms_x = IA.X[0L] # Shape(idx[1L,-1L])
    
    Dim i_begin, i_end
    
    For Each Row i In idx[1L,-1L] Do
    	// extract a full period
    	i_begin = idx
    	i_end   = idx - 1L
    	// use x (time) of the interval center
    	rms_x = IA.X[(i_begin + i_end) / 2L]
    	rms_y = Mean(IA[i_begin, i_end], MEAN_SQUARE)
    End
    
    Signal(rms_y, rms_x)
    
    #21270
    Tho MAZTho MAZ
    Teilnehmer

    Hello,

    does not work know with version 10.0.16. I have the following error : 

    “Wrong data structure in index operation.

    When using an index with a range specification ‘[<from>,<to>]’ both arguments must be scalar values. ”

     

    Could you please help me ?

    #21272
    Bernhard KantzBernhard Kantz
    Moderator

    The code seems above seems to be mangled, maybe in the transition to the new web site. The FPScript formula below should do the job.

    //Recherche des index où le signal d'entrée passe à zéro (orientation positive) afin d'isoler les périodes du signal
    Dim PMax = Maximum(Acceleration)
    Dim Idx = LevelCrossings(Acceleration, 0.0, 0.05 * PMax, EVENT_POSITIVE, EVENT_INDEX)
    
    //Calcul des valeurs RMS
    //Code optimisé pour un calcul plus rapide
    //Ici on n'étend pas les variables time et rms dans la boucle for avec l'opérateur :=
    //On définit au préalable la taille de time et rms et on les remplies dans la boucle For
    Dim N = NumberOfRows(idx)
    Dim rms  = AdjustUnit(? # N-1, Acceleration)
    For k = 0 To N - 2 Do
        rms[k]  = Mean(Acceleration[Idx[k], Idx[k+1]], MEAN_SQUARE)
    End
    
    Return Signal(rms, Acceleration.X[Idx])
    
Ansicht von 5 Beiträgen - 1 bis 5 (von insgesamt 5)
  • Du musst angemeldet sein, um auf dieses Thema antworten zu können.