Lazy Discrete Fourier Transform on the Arduino Uno

Channel:
Subscribers:
3,660
Published on ● Video Link: https://www.youtube.com/watch?v=ON6XEtqmbgI



Duration: 0:18
3,812 views
44


I got around to implementing my "Lazy Discrete Fourier Transform" algorithm on the Arduino Uno yesterday. Not all the optimizations are in place yet, but it's running nicely so far, pretty much real time.


The data comes from the ADXL345 digital accelerometer, which is set to a sampling rate of 800 Hz, detecting +/- 4g at 10 bits of precision.

The code first grabs around 3000 samples of the Z acceleration, and uses it to compensate for the gravity and the orientation of the sensor.

The data is ran through my LDFT algorithm, which finds the amplitude at frequencies from 0 to 299 Hz with precision of slightly more than 1 Hz per bin (bins always overlap with this method, AFAIK), each bin at 16 bits integer precision. Absolute value of the transform is shown in the OLED in the 0-127 Hz range, so it's 1 bin per column.

You can see it detecting a peak reliably at around 13-14 Hz, which is the resonant frequency of my table (which I measured before with more precise methods). At the end you can see it detecting 0 Hz (constant gravity) plus some sensor noise as I tilt the sensor.


The whole idea behind the algorithm wasn't implemented yet, and I don't think I'll need it in practice given current results, but it would allow many other different optimizations. I'll have to study more signal processing theory to really see what's going on and see if it's more than a silly hack.


The main point is that I'm more interested in lower frequencies than higher frequencies, so Fast Fourier/Hartley Transforms would require me to store a lot of samples to detect those reliably. With limited memory, as in the Arduino Uno where I only have 2048 bytes of SRAM, I cannot afford that approach. Those transforms also extract the entire spectrum, so they spend a lot of computation on the higher frequencies I don't care about.

The low frequency vibrations I'll be detecting are also short lived, so the whole FFT/FHT approach wouldn't work well enough because windowing at different times could mess it all up, especially since the windows have to be large.

Wavelet transforms might have helped, but it's not trivial to implement and it seems to me they would perform badly on the Arduino as well.


My algorithm is an alternative take on the problem that takes all these issues under consideration. It's optimized to detect amplitudes of lower frequencies in short bursts of signals. (So in principle, it sounds similar to wavelets, but I'm not using anything like wavelets.)


But, as opposed to FFT/FHTs/wavelets, the result is not a complete representation of the data. Part of the optimization is that I explicitly discard a lot of the information in the signal based on certain assumptions of regularity and the frequencies of interest. This is one of the ideas behind the algorithm, so applicability may be really limited.


I'll have to study the approach and signal processing theory in more detail (and more algorithms that do similar things) before I give out any specific details on this, as maybe there's something worth publishing more formally in here, instead of just copying and pasting my code online.

Probably not, as I'm a pretty stupid person, so I doubt I'd stumble upon something big.

It's just nice to see my own little hack working.




Other Videos By 1ucasvb


2021-01-09Puzzle Castle (1996) - Game music and soundtrack (Game & CD audio rips, downloads in description)
2017-01-08Bartek Wąsiel (BeWu) - "Candy Mountain" -- Chiptune Visualization / Atari SAP
2017-01-08[60fps] Grzegorz Kwiatek (Greg) - "Misunderstanding" -- Chiptune Visualization / Atari SAP
2017-01-07Tomasz Dajczak - "Eureka (Theme / Song 4)" -- Chiptune Visualization / Atari SAP (NEW ALGORITHM)
2017-01-07[60fps] Łukasz Sychowicz (X-Ray) - "Zizibum" -- Chiptune Visualization / Atari SAP (NEW ALGORITHM!)
2017-01-07Łukasz Sychowicz (X-Ray) - "Overmind (Song 1)" -- Chiptune Visualization / Atari SAP
2017-01-07Łukasz Sychowicz (X-Ray) - "Zbig" -- Chiptune Visualization / Atari SAP (NEW ALGORITHM!)
2017-01-07Jakub Husak - "His Dark Majesty (Song 4)" -- Chiptune Visualization / Atari SAP (NEW ALGORITHM!)
2016-09-18The Weather Man (2005) - "Fast Food" scene
2016-07-09Test run of my Universal Resonator prototype
2016-06-11Lazy Discrete Fourier Transform on the Arduino Uno
2016-05-31Fast Fourier Transform (FFT) vs my "lazy Discrete Fourier Transform" (LDFT)
2016-05-31Test for my discrete Fourier/Hartley-like transform algorithm
2016-04-25Chiptune Orchestra - "Piona" by Łukasz Sychowicz AKA X-Ray (Atari POKEY)
2016-04-16Orchestrated Game Music: "Dawn of City" AKA "10000.mid", by Sue Kasper from the game "SimCity 2000"
2016-04-10General Relativity - Conceptual illustration of time and space distortion
2015-05-05Orchestrated Game Music: "Song 3", by Simeon Peebler, from the game "Warheads SE"
2015-04-09Chiptune Orchestra - "Draconus" by Adam Gilmore (Atari POKEY)
2015-04-02Chiptune Orchestra - "Global War" by Peter Elfinger (Atari POKEY)
2014-06-21Łukasz Sychowicz (X-Ray) - "Maxi 2, Song 2" -- Chiptune Visualization / Atari SAP
2014-06-20Nils Feske (505) - "Short" -- Chiptune Visualization / Atari SAP