DFT

    Date: 07/07/06 (Algorithms)    Keywords: no keywords

    Hi

    I'm trying to do a DFT using this (VB, sorry not very good at C):

    Private Sub Transform()
    For n = 0 To 500
    Hann(n) = (ChIN(n) - 127) * (1 - Cos(n * 3.1416 / 500)) 'Hann Window
    Next n

    For k = 1 To 500
    r = 0
    i = 0
    For j = 1 To 500
    r = r + Hann(j) * Sin(k * j / 380)
    i = i + Hann(j) * Cos(k * j / 380)
    Next j
    ChIN(k) = 1 / 100 * Sqr(r * r + i * i)
    Next k
    End Suba

    It is working on a microcontroller measuring vibration, taking 500 samples (1byte resolution) and I don't really know how to get rid of the DC (big peak at 0Hz on the frequency spectrum). I though of dividing the signal in half (ChIN(n) -127) but with some signals work and with others it doesn't. Not very stable.... :(

    Anyone with experience in DFTs or FFTs?

    Source: http://community.livejournal.com/algorithms/81046.html

« Found on www.thedailywtf.com || logic problems »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home