Block: Sin3Gen



PIC




Inports


A

Amplitude



f

Frequency






Outports


u

Sine wave output phase u



v

Sine wave output phase v



w

Sine wave output phase w






Mask Parameters


fmax

Maximum Frequency in Hz



Offset

Offset



ts_fact

Multiplication factor of base sampling time (in integer format)




Description:

Generation of a 3 sine waves with amplitude (A) and frequency (f).

Calculation fixed point implementation:

uk  =   Ak ⋅ sin (2fk ⋅ fmax ⋅ kTS ) + AOffset
                                  2π
 vk =   Ak ⋅ sin (2fk ⋅ fmax ⋅ kTS ---) + AOffset
                                   3
                                  2π-
wk  =   Ak ⋅ sin (2fk ⋅ fmax ⋅ kTS + 3 ) + AOffset
For sine calculation a lookup table with 256 entries is used. This results in a short computation time but with the downside of reduced accuracy for the FiP32 implementation.

Calculation floating point implementation (parameter f_max is ignored):

 uk  =  Ak  ⋅ sin (2πfk ⋅ kTS ) + AOffset
                              2π
 vk  =  Ak  ⋅ sin (2πfk ⋅ kTS ---) + AOffset
                              3
w    =  A   ⋅ sin (2πf ⋅ kT +  2π) + A
  k       k         k     S   3       Offset
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 432
Revision 1.0
C filename Sin3Gen_FiP8.c
H filename Sin3Gen_FiP8.h

8 Bit Fixed Point Implementation



Controller Parameters


delta_phi

Angle increment



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     int8          *A; 
     int8          *f; 
     int8          u; 
     int8          v; 
     int8          w; 
     int8          delta_phi; 
     int8          offset; 
     int8          phi; 
} SIN3GEN_FIP8;

Implementation: FiP16


Name FiP16
ID 433
Revision 1.0
C filename Sin3Gen_FiP16.c
H filename Sin3Gen_FiP16.h

16 Bit Fixed Point Implementation



Controller Parameters


delta_phi

Angle increment



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     int16         *A; 
     int16         *f; 
     int16         u; 
     int16         v; 
     int16         w; 
     int16         delta_phi; 
     int16         offset; 
     int16         phi; 
} SIN3GEN_FIP16;

Implementation: FiP32


Name FiP32
ID 434
Revision 1.0
C filename Sin3Gen_FiP32.c
H filename Sin3Gen_FiP32.h

32 Bit Fixed Point Implementation



Controller Parameters


delta_phi

Angle increment



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     int32         *A; 
     int32         *f; 
     int32         u; 
     int32         v; 
     int32         w; 
     int32         delta_phi; 
     int32         offset; 
     int32         phi; 
} SIN3GEN_FIP32;

Implementation: Float32


Name Float32
ID 435
Revision 0.1
C filename Sin3Gen_Float32.c
H filename Sin3Gen_Float32.h

32 Bit Floating Point Implementation



Controller Parameters


delta_phi

Angle increment



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     float32       *A; 
     float32       *f; 
     float32       u; 
     float32       v; 
     float32       w; 
     float32       delta_phi; 
     float32       offset; 
     float32       phi; 
} SIN3GEN_FLOAT32;

Implementation: Float64


Name Float64
ID 436
Revision 0.1
C filename Sin3Gen_Float64.c
H filename Sin3Gen_Float64.h

64 Bit Floating Point Implementation



Controller Parameters


delta_phi

Angle increment



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     float64       *A; 
     float64       *f; 
     float64       u; 
     float64       v; 
     float64       w; 
     float64       delta_phi; 
     float64       offset; 
     float64       phi; 
} SIN3GEN_FLOAT64;