Block: SinGen



PIC




Inports


A

Amplitude



f

Frequency






Outports


u

Sine wave output






Mask Parameters


fmax

Maximum Frequency in Hz



Offset

Offset



Phase

Phase [-Pi..Pi]



ts_fact

Multiplication factor of base sampling time (in integer format)




Description:

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

Calculation fixed point implementation:

uk  =  Ak  ⋅ sin (2fk ⋅ fmax ⋅ kTS + ϕP hase) + 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 + ϕPhase) + AOffset
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 416
Revision 1.0
C filename SinGen_FiP8.c
H filename SinGen_FiP8.h

8 Bit Fixed Point Implementation



Controller Parameters


delta_phi

Angle increment



phase

Angle offset



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     int8          *A; 
     int8          *f; 
     int8          u; 
     int8          delta_phi; 
     int8          phase; 
     int8          offset; 
     int8          phi; 
} SINGEN_FIP8;

Implementation: FiP16


Name FiP16
ID 417
Revision 1.0
C filename SinGen_FiP16.c
H filename SinGen_FiP16.h

16 Bit Fixed Point Implementation



Controller Parameters


delta_phi

Angle increment



phase

Angle offset



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     int16         *A; 
     int16         *f; 
     int16         u; 
     int16         delta_phi; 
     int16         phase; 
     int16         offset; 
     int16         phi; 
} SINGEN_FIP16;

Implementation: FiP32


Name FiP32
ID 418
Revision 1.0
C filename SinGen_FiP32.c
H filename SinGen_FiP32.h

32 Bit Fixed Point Implementation



Controller Parameters


delta_phi

Angle increment



phase

Angle offset



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     int32         *A; 
     int32         *f; 
     int32         u; 
     int32         delta_phi; 
     int32         phase; 
     int32         offset; 
     int32         phi; 
} SINGEN_FIP32;

Implementation: Float32


Name Float32
ID 419
Revision 0.1
C filename SinGen_Float32.c
H filename SinGen_Float32.h

32 Bit Floating Point Implementation



Controller Parameters


delta_phi

Angle increment



phase

Angle offset



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     float32       *A; 
     float32       *f; 
     float32       u; 
     float32       delta_phi; 
     float32       phase; 
     float32       offset; 
     float32       phi; 
} SINGEN_FLOAT32;

Implementation: Float64


Name Float64
ID 420
Revision 0.1
C filename SinGen_Float64.c
H filename SinGen_Float64.h

64 Bit Floating Point Implementation



Controller Parameters


delta_phi

Angle increment



phase

Angle offset



offset

Amplitude offset



phi

Current angle




Data Structure:

typedef struct { 
     uint16        ID; 
     float64       *A; 
     float64       *f; 
     float64       u; 
     float64       delta_phi; 
     float64       phase; 
     float64       offset; 
     float64       phi; 
} SINGEN_FLOAT64;