4 ms·
So they are generating a signal by toggling the IO pin on and off. Not only will there be a huge amount of harmonics, wouldn't processor interrupts wreak havoc
by ourlordcaffeine 7y ago
So they are generating a signal by toggling the IO pin on and off. Not only will there be a huge amount of harmonics, wouldn't processor interrupts wreak havoc on the output signal and cause even more interference?
- deleted 7y ago[deleted]
- myself248 7y agoYes and no; if they're doing it right, they're using the DMA or PLL engine which runs independent of the main CPU/ALU. See https://github.com/F5OEO/PiFmRds https://github.com/F5OEO/PiFmRds "This version modulates the PLL instead of the clock divider for superior signal purity. The harmonics are unaffected, so the legal warning still applies." Filtering this stuff isn't hard, but I'm realizing there aren't any good stone-simple tutorials for it. Might have to write one.
- tknkx 7y agoCan someone explain to me why generating a square wave creates lots of harmonics, as opposed to other kinds of waves?
- davidgay 7y agoA square wave IS the base frequency plus ALL[1] the odd harmonics (https://en.wikipedia.org/wiki/Square_wave#Fourier_analysis https://en.wikipedia.org/wiki/Square_wave#Fourier_analysis explains it better than I could). [1]: Yes, so in reality you neither get an infinite set of harmonics, nor a perfect square wave.
- gmueckl 7y agoThe spectrum of a signal is its Fourier transform. Only sine and cosine signals have a "pure" signal with a single frequency. Anything else decomposes into a whole host of spectral contributions. Square waves are especially bad because they require contributions from infinitely many harmonics to produce the steep flanks. That is also why a clean square wave cannot exist: some kind of band limit is always present, resulting in ringing around the flanks. See also Fourier Analysis on the Wikipedia article: https://en.m.wikipedia.org/wiki/Square_wave https://en.m.wikipedia.org/wiki/Square_wave
- deleted 7y ago[deleted]
- GoToRO 7y agoBecause you try to generate a square wave by adding toghether "round" waves (sinusoidal). In order to get into the "corners" you must add "round" waves with smaller and smaller diameters (period). Small periods means high frequencies. The more waves you add, the squarer the sum becomes.
- FeepingCreature 7y agoI've done a hobby project where I'm using pure RPi GPIO to drive a servo motor with PWM, so processor interrupts would ruin my day. So I can tell you that the rate at which modern Linux interrupts a running application is massively overstated. If your system is configured right, that happens maybe two or three times a second at most. If you're running on a dedicated core, as you should, 99% of the time your application just happily runs along.