cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a signal combining a Sine wave and Hann Window?

Hailing SKY
Associate II
Posted on January 19, 2018 at 14:48

Dear All,

I would like to generate a 2 kHz �10 V Sine-wave with Hann window, as shown in the figure below. Do you have any ideal how to implement this function in STM32F4, and are there any additional circuits required for this? I am new to this field. Please let me know if you have any idea.

Best regards,

Hai

0690X00000609H2QAI.png

#sine-waveform #stm32 #hanning-window
8 REPLIES 8
Posted on January 19, 2018 at 15:35

I am new to this (sic) field

Which field, exactly:

  • Programming - in general?
  • Programming - microcontrollers?
  • DSP?
  • other?

Here's a free online DSP textbook: 

http://www.dspguide.com/

 (also available in dead-tree form - for money).

Here's some learning & reference materials for 'C' programming: 

http://blog.antronics.co.uk/2011/08/08/so-youre-thinking-of-starting-with-c/

 
Posted on January 19, 2018 at 18:11

Do any of the parameters change?

Pattern buffer to DAC (DMA+TIM) to OPAMP?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 19, 2018 at 18:17

I really wish people would fill out their profiles. If people have degrees in Art History, or 18th Century English Poetry it would be helpful to know

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 19, 2018 at 18:20

Thanks Clive. The frequency can be different in the application. It will be ideal if the frequency can be adjusted, e.g. from 50 kHz to 500 kHz. This generated signal will be used for actuation purposes. The amplitude is fixed.

Posted on January 19, 2018 at 18:32

Ok, so perhaps a pattern buffer of 50000-60000 samples you can push at up to 1msps. The math to generate the pattern buffer not that complicated.

500 KHz might be a challenge. Could you build a simple modulation circuit? Looks like AM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 19, 2018 at 20:57

Thanks, Clive. I found AN3216 and AN4566 for generating particular DAC outputs, but haven't got a chance to read them in detail. Are those parameters (sample number and DAC clock frequency) calculated using theories introduced in these notes? 

Is the modulation circuit used for amplifying the DAC output amplitude from 3.3 V to 10 V? I do not have such experience, but if you can give me some references, I am pretty sure I can implement the circuit. Thanks.

T J
Lead
Posted on January 19, 2018 at 22:06

you would generate a series of normalised floats in a table, from the function W(n), and 'play' the Audio with a DMA

mechanically we process along Pi and along n

W(n) is an artist impression of what we want.

You need to see detail along Pi within each (n)

We like binary numbers, so lets pick a clean number like 1024. // thats 2MHz output for 2KHz sinewave.

do you want a super clean output with low distortion ?

double step = Pi/1024;      // 2MHz output maybe too high.

double W[1024 * n ];

int k=0;

for (j = 0; j < n; j++) 

   for (i = 0; i< 1024; i++)

         W(k++) =YourSuperFunction( i,n);

YourSuperFunction(i,n){

   double thisStep = Pi /1024*i;

  // calculate W with current step position and n

}

Once the table is filled,

you would setup a DMA to 'play' the Audio through the DAC to get to 3Vpp  // 2MHz should be achievable.

to get to 10V you would normally capacitively couple an audio amplifier, where the output can easily be 80Vpp

Posted on January 23, 2018 at 15:10

Thanks T J for the detialed instruction. I will work on this, and let you know the result. 

Best,

Hai