Arduino Forum

Using Arduino => Audio => Topic started by: shakki87 on Nov 24, 2013, 06:49 pm

Title: Harmonic filtering
Post by: shakki87 on Nov 24, 2013, 06:49 pm
I'm using a digital pin to create a 1khz wave. The problem is that its a square wave and it has harmonics. I can hear the harmonic on my radio even in fm band  > 90mhz. I'm trying to use a passive rc low pass filter but it seems it doesn't have any affect. Is  there a way to create a wave that doesn't have harmonics? Either using some filter or by software?
Title: Re: Harmonic filtering
Post by: CrossRoads on Nov 24, 2013, 06:57 pm
How are things wired up? Just a bunch of wires on a solderless breadboard? Those wires all act like antennas, so a first step is to clean up wiring.

What is the 1 KHz connected to? A 2nd step might be co-ax or twisted pair wiring to shield the emissions. Ground the shield at one end so you don't induce ground loops.

A 3rd step might be better filtering. Lower the filter frequency, add a 2nd stage of filtering, maybe add active components (op-amps) to make a sharper cutoff band/knee.
http://sim.okawa-denshi.jp/en/CRlowkeisan.htm
Title: Re: Harmonic filtering
Post by: shakki87 on Nov 24, 2013, 09:18 pm
I'm build  small transmitter between a computer and  a portable terminal. I'm using a breadbroard while I'm  testing the transmitter.
The harmonics interfering with the testing. The wirining is from digital and ground to the filter.  co-ax is a good idea but I don't have it now. Won't the wiring still act as antenna after makeing it a circuit? Next have try 2nd stage filtering.

Title: Re: Harmonic filtering
Post by: CrossRoads on Nov 24, 2013, 11:59 pm
Yes, but the outer shield of the co-ax will contain a lot of the emissions.
Title: Re: Harmonic filtering
Post by: jremington on Nov 25, 2013, 02:58 am
Try putting some ferrite beads on the wire coming out of the digital pin, as close as possible to the pin. Beads like these will cut RF interference in the short wave and FM bands: http://www.ebay.com/itm/50-pcs-2643250302-FAIR-RITE-43-MATERIAL-SHIELDED-FERRITE-BEAD-25-300MHz-/121152377726?pt=LH_DefaultDomain_0&hash=item1c353e937e
Title: Re: Harmonic filtering
Post by: MarkT on Nov 25, 2013, 08:10 pm

I'm using a digital pin to create a 1khz wave. The problem is that its a square wave and it has harmonics. I can hear the harmonic on my radio even in fm band  > 90mhz. I'm trying to use a passive rc low pass filter but it seems it doesn't have any affect. Is  there a way to create a wave that doesn't have harmonics? Either using some filter or by software?


With a digital pin you have to filter in hardware afterwards.  With high-speed PWM then
a LPF you can get a much better approximation to a sine wave with less critical filtering
requirements.  So a 60kHz PWM through a 2kHz-cutoff LPF will fare much better than
putting a square wave through a single RC filter.

Alternatively you can use a much more performant filter (say 6+ poles) using cascaded
active filter sections, so that it has a steep cutoff just above 1kHz.  However such a
filter is both expensive in components and fixed at a single frequency.

In practice if you want to generate a quality sinusoid you use a DAC and generate
enough samples to greatly reduce the error, then LPF the residual noise away.

[one last possibility: LC resonant filter - however not easy for low frequencies and have the
risk of exceeding the supply voltage at resonance]
Title: Re: Harmonic filtering
Post by: shakki87 on Nov 25, 2013, 10:44 pm
Haven't tried the coax cable yet. I tried the 60khz with a 2khz filter but I still get harmonics on radio. 60khz pwm is still a square wave is it not?  And I don't quit understand the idea behind it can you elaborate?
Title: Re: Harmonic filtering
Post by: MarkT on Nov 25, 2013, 11:28 pm
Can you clarify what you are doing with the 1kHz signal?  What is this "small transmitter"?
Title: Re: Harmonic filtering
Post by: shakki87 on Nov 25, 2013, 11:37 pm
I'm going to use the 1khz as a commucation signal eg morse code, fsk. The transmitter is a simple am transmitter for about 10m for now. If concered about law I dont live in US.
Title: Re: Harmonic filtering
Post by: shakki87 on Nov 26, 2013, 08:00 pm
Tried coax cable didnt't change the situation. Still have expose some of wiring to make a connection.

EDIT: Sees that nothing works to filter harmonic. Is there any way to gererate a signal that has a frequency without harmonic?
Title: Re: Harmonic filtering
Post by: CrossRoads on Nov 27, 2013, 02:45 am
Need to generate with a DAC so you can control the corners more.
Title: Re: Harmonic filtering
Post by: shakki87 on Nov 30, 2013, 01:48 am
Got it working. Insted of using filters I used a 1khz  PHASE-SHIFT OSCILLATOR to create the control signal. Now i only have turn the oscillator on or off. It has some harmonics but now a rc filter works in reducing them. Thanks for the information especially the coax cable.
Title: Re: Harmonic filtering
Post by: CrossRoads on Nov 30, 2013, 01:52 am
Got rounder corners to start then? That makes filtering easier.
Title: Re: Harmonic filtering
Post by: shakki87 on Nov 30, 2013, 08:53 pm
Yep. Tried the oscillator on a simulator first almost a perfect sine wave. 
Title: Re: Harmonic filtering
Post by: CrossRoads on Nov 30, 2013, 09:35 pm
Have you looked at the output with a real oscilloscope?
Title: Re: Harmonic filtering
Post by: shakki87 on Dec 01, 2013, 03:42 pm
Not yet. I used audacity to analyse the spectrum. It showed that the signal is a 1KHz and that the harmonic attenuate. Also didn't hear any harmonic on the radio.