<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: DSP - digital signal processing and 60 hz noise</title>
		<link>http://forums.leaflabs.com/topic.php?id=855</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:13:08 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=855" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5325</link>
			<pubDate>Fri, 17 Jun 2011 14:15:00 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">5325@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;StephenFromNYC - you could sample the 60Hz mains hum at a similar time (using one ADC) to the actual signal. (Using two ADC's it could be simultaneous samples, but then you'd have to hack some code together).&#60;/p&#62;
&#60;p&#62;With a bit of calibration, it should be feasible to pretty-much filter the 60Hz hum from the actual signal with very little computational effort (a-fudge_factor*b).&#60;/p&#62;
&#60;p&#62;At low sampling rates, I guess the 60-Hz hum could be derived from a bit of wire stuck in an ADC input. At higher sampling rates, a cheap OpAmp would do. A low-pass filter (capacitor) would filter out higher frequencies, that might pollute the signal, with a very high &#34;computational efficiency&#34;.&#60;/p&#62;
&#60;p&#62;Can you estimate how much noise it is suffering?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>trevden on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5290</link>
			<pubDate>Thu, 16 Jun 2011 22:39:38 +0000</pubDate>
			<dc:creator>trevden</dc:creator>
			<guid isPermaLink="false">5290@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Might it be a ground loop problem? What are you sampling? Make sure the ground line between the Maple and whatever you're sampling is solid and short.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5222</link>
			<pubDate>Tue, 14 Jun 2011 16:12:05 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5222@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks! My grandma is looking forward to it as well =].&#60;/p&#62;
&#60;p&#62;The Maple (standard, non-RET6 edition) has enough RAM and FLASH for a lot of stuff. My project includes an LCD driver (with fonts stored in FLASH), libfixmath, SD Driver, FFT library w/ pre-calculated coefficients stored in FLASH, and that all fits in under 40kB of FLASH, with another 60 kB to go. To store 256 samples, and fft-output data I need only about ~2kB RAM (each sample is a complex number stored as 32-bits). That leaves you with plenty of RAM for a bunch of other stuff, like more samples, more data, and even SD/LCD buffers!&#60;/p&#62;
&#60;p&#62;A very simple filter to consider is a &#60;a href=&#34;http://en.wikipedia.org/wiki/Median_filter&#34;&#62;median filter&#60;/a&#62;. It works very much like an average filter poslathian mentioned, but it removes noise a little better. An average filter's value is susceptible to spikes. For example, lets say you're reading a signal (whatever it may be - these are arbitrary values) and took 4 samples, but during the 3rd sample there was a spike in your system (you touched the sensor with your sweaty finger!) and the ADC captured a noisy sample: [5 5 100 5]. An average filter would yield a value of 29. That's clearly VERY wrong. If you apply a median filter the 4 samples would turn out to be: [5 5 5 5]. You can then apply an average to this and get 5 as your answer -- a less noisy answer than 29 would have been.&#60;/p&#62;
&#60;p&#62;You may not get noise from AC power lines in the middle of central park, but you'll have to deal with a lot of horse poop.&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5219</link>
			<pubDate>Tue, 14 Jun 2011 15:50:53 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">5219@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello-&#60;/p&#62;
&#60;p&#62;Thanks for all the ideas.  I am still digesting the number crunching and estimates from poslathian and robodude666.&#60;/p&#62;
&#60;p&#62;poslathian, I can see how your suggestion for a four point running average might work if the sampling were slower than 60 Hz.  If you used several consecutive points some would be high, others would be near the right value, and some would be low and so the average would be near the &#34;correct&#34; value without the noise.  However, if the sampling is much faster than 60 Hz I believe the averaging would not help (because, at the faster ADC rate all the values taken in a small window would be either all too high, all near the correct value, or all too low).  Am I missing something?&#60;/p&#62;
&#60;p&#62;robodude666, congratulations on graduation!  Yes I already had Ivan Mellen's page bookmarked.  Thanks for letting me know how you feel about the official ARM CMSIS DSP library.&#60;/p&#62;
&#60;p&#62;If I run out of memory on my Maple R3 I might simply send the noisy ADC data to my system and let my system crunch the DSP filters.&#60;/p&#62;
&#60;p&#62;Perry, I assumed 60 Hz noise would be present where even a single AC power line was present.  I wonder how much noise I would see if I took my Maple into the middle of Central Park.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5213</link>
			<pubDate>Tue, 14 Jun 2011 15:00:08 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5213@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;A perk of graduating next week is not having much school work to worry about, and Professors don't require you to stay in class =]. I'll be working a lot today on my DSP stuff. If I feel the performance is reasonable, I'll surely create a git repo. I've only taken a couple DSP classes, so I'm sure someone will be able to optimize a thing or two. Open Source Powers Activate!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5209</link>
			<pubDate>Tue, 14 Jun 2011 13:39:34 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5209@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;robodude666,&#60;/p&#62;
&#60;p&#62;I'm psyched about your project!  Any chance you might break it up into a standalone library?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>perry on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5173</link>
			<pubDate>Mon, 13 Jun 2011 19:21:31 +0000</pubDate>
			<dc:creator>perry</dc:creator>
			<guid isPermaLink="false">5173@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Stephen,&#60;/p&#62;
&#60;p&#62;It appears you have discovered mains hum! &#60;a href=&#34;http://en.wikipedia.org/wiki/Mains_hum&#34; rel=&#34;nofollow&#34;&#62;http://en.wikipedia.org/wiki/Mains_hum&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;If you live in any sort of populated area with lots of electricity around you (I believe NYC counts ;)), you will see it. &#60;/p&#62;
&#60;p&#62;-perry
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5168</link>
			<pubDate>Mon, 13 Jun 2011 16:58:20 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5168@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm doing some work myself now on DSP-related things. For starters, here's a lovely &#60;a href=&#34;http://www.embeddedsignals.com/FFTCM3.s&#34;&#62;hand-optimized&#60;/a&#62; FFT function for the STM32 (ARM Cortex-M3 optimized) that works wicked well (alliteration!).&#60;/p&#62;
&#60;p&#62;I haven't looked much at the STM's DSP library, though I have looked at the official ARM CMSIS DSP library, and it looks rather slow -- it's full of a LOT of C code. To get the best performance possible out of DSP, hand-optimized assembly is preferred.&#60;/p&#62;
&#60;p&#62;Depending on what you need, like poslathian said, a digital filter may work just fine. Memory never hurts, also so the RET6 would be a better choice depending on what you're doing. Take a look at FIR and IIR filters. FIR filters, ultimately, would yield higher accuracy but lower performance between the two. IIR would give you better performance, but they'd require a bit more work to implement. I'm in the middle of porting my MATLAB implementations of these filters into C, and possibly assembly in the future. I'll post back with results, of course =].&#60;/p&#62;
&#60;p&#62;The other night I finally got my Maple FFT Spectrum Analyzer (I'll make a thread on the project later) working using the above FFT function + a QVGA LCD. It's simple, but works rather well. I maintain a ~44.1kHz sample rate by delaying the ADC sampling in a for-loop by 22 microseconds, though a timer-based interrupt would certainly be better. Even so, I'm getting decent performance. Using a 256-point FFT, and blocking ADC-sampling, I am able to capture 256 samples, performance the FFT, calculate the magnitude response, and render the entire graph to the LCD in about 29 milliseconds. With a 64-point FFT and 8 kHz sample rate (125 microsecond delay between samples), I am able to get a ~12 millisecond turnaround time. Not too shabby I'd say.&#60;/p&#62;
&#60;p&#62;If you can pull off a timer-based interrupt at the sample rate you desire, applying an IIR/FIR filter with a low N-count is certainly feasible. You can probably even pull it all off with polling/blocking ADC-sampling just as easily. However, if high-precision is required.. the computation time may end up being too great to do anything else and hardware filters may be a better choice.&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5162</link>
			<pubDate>Mon, 13 Jun 2011 15:01:32 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">5162@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Stephen,&#60;br /&#62;
It all depends on the exact sort of operations you want to do, and how fast, and how much you want to store. &#60;/p&#62;
&#60;p&#62;For example, if you wanted to make a window average filter over 4 samples like this:&#60;/p&#62;
&#60;p&#62;y_out[n] = (x_in[n-3] + x_in[n-2] + x_in[n-1] + x_in[n]) &#38;lt;&#38;lt; 2;&#60;/p&#62;
&#60;p&#62;you could easily run that at 250KHz, probably even at the max ADC rate of 1MHz, especially if you were using the DMA and other fancy things.&#60;/p&#62;
&#60;p&#62;On the other hand, if you wanted to STORE 50,000 samples and then make some sort of looper or something, youre going to run out of memory rather quick. &#60;/p&#62;
&#60;p&#62;My guestimate would be that you are going to have a tough time running out of processing - even at 100KHz sample rate, if you use the DMA you have something near 720 instructions PER SAMPLE to run your DSP math. Much more likely is that you run out of memory for some stateful (like delay) operation. at 44KHz, the ~17KB you have on regular Maple is less than .5 seconds of audio. &#60;/p&#62;
&#60;p&#62;Of course, if all you are doing is delay, you can get external FIFO chips that are cheap and big, much simpler than RAM. &#60;/p&#62;
&#60;p&#62;Unless your DSP is very sophisticated, with many filters being strung together, you will likely not need to use dedicated hardware/dsp chip. Its probably cheaper/easier to string two maples together, sending samples over hardwarespi/i2c in order to extend your filter chain than it would be to get setup on a whole new platform just because you are running 6 FIR filters and you ran out of performance with 4.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "DSP - digital signal processing and 60 hz noise"</title>
			<link>http://forums.leaflabs.com/topic.php?id=855#post-5153</link>
			<pubDate>Mon, 13 Jun 2011 12:03:16 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">5153@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello-&#60;/p&#62;
&#60;p&#62;When I use analogRead to rapidly acquire ADC data the curve has the shape of a sine-wave.  Honestly, I have not confirmed that the cyclical variation I am seeing is actually 60 Hz or some other rate (if I had a scope it would be easy, but I do not).  I forgot which analog pins I tested (I think I used pins with low numbers).  I am aware that some ADC pins are better than other pins for reducing noise).&#60;/p&#62;
&#60;p&#62;I am wondering if anyone has experience implementing DSP functions on a Maple R3 or Maple Mini board?  Is there enough memory space on the R3 or Mini?  Would the Maple RET6 Edition board be a better choice?  Initially I would like to collect 5000 samples per second, but if successful I might try to collect up to 20K-50K samples per second or a bunch of simultaneous data points at a high rate.&#60;/p&#62;
&#60;p&#62;I have considered using a hardware filter to remove the noise.  I do not know if it is more elegant to implement the filtering in software.  It would be nice to see how far we can push the Maple boards.&#60;/p&#62;
&#60;p&#62;Is the software solution more or less work?&#60;/p&#62;
&#60;p&#62;st.com has some code on their web site for DSP, but I have not tried it yet.&#60;/p&#62;
&#60;p&#62;I am asking these questions before I have done much work, because your answers will give me guidance and insight.  I realized I may have to learn more about DMA or transfer the data via SerialN rather than SerialUSB.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
