Skip to main content
Hailing SKY
Associate III
January 19, 2018
Question

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

  • January 19, 2018
  • 8 replies
  • 1469 views
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
    This topic has been closed for replies.

    8 replies

    Andrew Neil
    Super User
    January 19, 2018
    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/

     
    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Tesla DeLorean
    Guru
    January 19, 2018
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    January 19, 2018
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Hailing SKY
    Associate III
    January 19, 2018
    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.

    Tesla DeLorean
    Guru
    January 19, 2018
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    T J
    Senior III
    January 19, 2018
    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

    Hailing SKY
    Associate III
    January 23, 2018
    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