Block: Average



PIC




Inports


In

Input value






Outports


Out

Averaged value






Mask Parameters


n

Number of points to be averaged over



ts_fact

Multiplication factor of base sampling time (in integer format)




Description:

Calculation of moving average value over n numbers.

Calculation:

          1-  k
Outk  =   n  ∑   Ini
            i=k- n

Implementations:
FiP8 8 Bit Fixed Point Implementation
FiP16 16 Bit Fixed Point Implementation
FiP32 32 Bit Fixed Point Implementation
Float32 32 Bit Floating Point Implementation
Float64 64 Bit Floating Point Implementation

Implementation: FiP8


Name FiP8
ID 5024
Revision 1
C filename Average_FiP8.c
H filename Average_FiP8.h

8 Bit Fixed Point Implementation



Controller Parameters


n

Average window size



sfrn

Shift factor for computation of average value sfrn = ld(n)



sum

Temporary sum



count

Index counter



avg

Array with data values




Data Structure:

typedef struct { 
     uint16        ID; 
     int8          *In; 
     int8          Out; 
     uint16        n; 
     uint8         sfrn; 
     int16         sum; 
     uint16        count; 
     int8          *avg; 
} AVERAGE_FIP8;

Implementation: FiP16


Name FiP16
ID 5025
Revision 1
C filename Average_FiP16.c
H filename Average_FiP16.h

16 Bit Fixed Point Implementation



Controller Parameters


n

Average window size



sfrn

Shift factor for computation of average value sfrn = ld(n)



sum

Temporary sum



count

Index counter



avg

Array with data values




Data Structure:

typedef struct { 
     uint16        ID; 
     int16         *In; 
     int16         Out; 
     uint16        n; 
     uint8         sfrn; 
     int32         sum; 
     uint16        count; 
     int16         *avg; 
} AVERAGE_FIP16;

Implementation: FiP32


Name FiP32
ID 5026
Revision 1
C filename Average_FiP32.c
H filename Average_FiP32.h

32 Bit Fixed Point Implementation



Controller Parameters


n

Average window size



sfrn

Shift factor for computation of average value sfrn = ld(n)



sum

Temporary sum



count

Index counter



avg

Array with data values




Data Structure:

typedef struct { 
     uint16        ID; 
     int32         *In; 
     int32         Out; 
     uint16        n; 
     uint8         sfrn; 
     int64         sum; 
     uint16        count; 
     int32         *avg; 
} AVERAGE_FIP32;

Implementation: Float32


Name Float32
ID 5027
Revision 0.1
C filename Average_Float32.c
H filename Average_Float32.h

32 Bit Floating Point Implementation



Controller Parameters


n

Average window size



sum

Temporary sum



count

Index counter



avg

Array with data values




Data Structure:

typedef struct { 
     uint16        ID; 
     float32       *In; 
     float32       Out; 
     uint16        n; 
     float32       sum; 
     uint16        count; 
     float32       *avg; 
} AVERAGE_FLOAT32;

Implementation: Float64


Name Float64
ID 5028
Revision 0.1
C filename Average_Float64.c
H filename Average_Float64.h

64 Bit Floating Point Implementation



Controller Parameters


n

Average window size



sum

Temporary sum



count

Index counter



avg

Array with data values




Data Structure:

typedef struct { 
     uint16        ID; 
     float64       *In; 
     float64       Out; 
     uint16        n; 
     float64       sum; 
     uint16        count; 
     float64       *avg; 
} AVERAGE_FLOAT64;