cancel
Showing results for 
Search instead for 
Did you mean: 

Sinwave harmonics on STM32F4 discovery board

mohit rai
Associate II
Posted on January 02, 2018 at 06:26

Hello,

I am generating digital sin wave sample using the below formula.

sin wave[numberOfSample]=2047*(sin(2*3.14*n/numberOfSample)+1)

I am generating sample for 200 hertz wave.

numberOfSample=40 when sampling frequency=8000 hertz.

In my case,numberOfSample is 40 for 200 hertz sin wave generation.

Problem is that, when I am playing sin wave using DAC, harmonics are also present in my output. 

How can I resolve this problem?

harmonics are present due to above formula that I am using for generating sin wave sample.

I need digital sin wave in  my application. This harmonics creating lot of noise. I have tried low pass  filter (1000 hertz both software and hardware)  but it is not working effectively.

Thanks in advance

Regards,

Mohit Rai

2 REPLIES 2
S.Ma
Principal
Posted on January 02, 2018 at 09:10

Take an excel spreadsheet, create the table of n samples, format it so it can be easily copy paste in a C source code and see if the result is the same. It could also be a problem of formatting, if the DAC is in 8 bit, 10 bit or 12 bit mode etc... a ramp as input table should give more debugging clues. Is the output buffer enabled, and the test is done without output load?

mohit rai
Associate II
Posted on January 03, 2018 at 11:24

hello,

Harmonics was present due to step size in sin wave sample.

When I have changed  in the sin wave generation formula. harmonics are reduced.

sin wave[numberOfSample]=100*sin(2*3.14*n/numberOfSample)+2047.

Regards,

Mohit Rai