DSPRelated.com
Forums

Sine to square wave conversion

Started by Sharan123 October 14, 2015
Hello All,

I have a question on the sine wave to square wave conversion.

As a part of an issue I am trying to solve, we are converting a sine wave
to square wave.
This conversion is simple and is based on whether the amplitude at any
given instant is higher or lower than a given threshold value. Please note
that the sinewave is of a single frequency.

The question I have is, is this a high pass filter concept?

This is what I thought at the beginning.But then a filter attenuates
certain frequency components and leaves rest untouched.

In this case, there is exactly one frequency in the input and after
filtering, there is a square waveform.
We know very well that a sine wave had exactly one frequency & did not
have such high frequency component.

---------------------------------------
Posted through http://www.DSPRelated.com
On Wednesday, October 14, 2015 at 10:26:24 AM UTC-4, Sharan123 wrote:
> Hello All, > > I have a question on the sine wave to square wave conversion. > > As a part of an issue I am trying to solve, we are converting a sine wave > to square wave. > This conversion is simple and is based on whether the amplitude at any > given instant is higher or lower than a given threshold value. Please note > that the sinewave is of a single frequency. > > The question I have is, is this a high pass filter concept?
NO
> > This is what I thought at the beginning.But then a filter attenuates > certain frequency components and leaves rest untouched. > > In this case, there is exactly one frequency in the input and after > filtering, there is a square waveform. > We know very well that a sine wave had exactly one frequency & did not > have such high frequency component. >
Squaring a sine wave is not a filter. A filter is typically a linear process. (no new frequencies are created) Squaring a sine wave is a non linear process and would nt be called a filter. Mark
>Squaring a sine wave is not a filter. > >A filter is typically a linear process. (no new frequencies are created) > >Squaring a sine wave is a non linear process and would nt be called a >filter.
Thanks. I am assuming that most of the power for a square wave is concentrated at the high frequency components. Is this correct? --------------------------------------- Posted through http://www.DSPRelated.com
makolber@yahoo.com wrote:
> On Wednesday, October 14, 2015 at 10:26:24 AM UTC-4, Sharan123 wrote: >> Hello All, >> >> I have a question on the sine wave to square wave conversion. >> >> As a part of an issue I am trying to solve, we are converting a sine wave >> to square wave. >> This conversion is simple and is based on whether the amplitude at any >> given instant is higher or lower than a given threshold value. Please note >> that the sinewave is of a single frequency. >> >> The question I have is, is this a high pass filter concept? > > NO > >> >> This is what I thought at the beginning.But then a filter attenuates >> certain frequency components and leaves rest untouched. >> >> In this case, there is exactly one frequency in the input and after >> filtering, there is a square waveform. >> We know very well that a sine wave had exactly one frequency & did not >> have such high frequency component. >> > > Squaring a sine wave is not a filter. > > A filter is typically a linear process. (no new frequencies are created) > > Squaring a sine wave is a non linear process and would nt be called a filter. > > Mark > >
Look up Fourier *SERIES* in a first year college calculus textbook. You will find that a square wave of period 1/f will have an infinite number of odd harmonics of a sine wave of frequency f.
"Sharan123" <99077@DSPRelated> Wrote in message:
> >Squaring a sine wave is not a filter. >> >>A filter is typically a linear process. (no new frequencies are created) >> >>Squaring a sine wave is a non linear process and would nt be called a >>filter. > > Thanks. I am assuming that most of the power for a square wave is > concentrated at the high frequency components. Is this correct? > --------------------------------------- > Posted through http://www.DSPRelated.com >
By Parseval's theorem, the power spectral density in a square wave is proportional to the inverse square of the harmonic. The infinite sum of the inverse squares over the odd natural numbers is 3/4*(pi^2/6). Using this you should be able to find the ratio of the power contained in all the harmonics to the power contained in the fundamental. -- ----Android NewsGroup Reader---- http://usenet.sinaapp.com/
On Thursday, October 15, 2015 at 3:26:24 AM UTC+13, Sharan123 wrote:
> Hello All, > > I have a question on the sine wave to square wave conversion. > > As a part of an issue I am trying to solve, we are converting a sine wave > to square wave. > This conversion is simple and is based on whether the amplitude at any > given instant is higher or lower than a given threshold value. Please note > that the sinewave is of a single frequency. > > The question I have is, is this a high pass filter concept? > > This is what I thought at the beginning.But then a filter attenuates > certain frequency components and leaves rest untouched. > > In this case, there is exactly one frequency in the input and after > filtering, there is a square waveform. > We know very well that a sine wave had exactly one frequency & did not > have such high frequency component. > > --------------------------------------- > Posted through http://www.DSPRelated.com
Absolutely not. Zero crossing detectors also have no filtering properties. Is this the mains ac voltage you are working with?
On Wed, 14 Oct 2015 09:26:19 -0500, Sharan123 wrote:

> Hello All, > > I have a question on the sine wave to square wave conversion. > > As a part of an issue I am trying to solve, we are converting a sine > wave to square wave. > This conversion is simple and is based on whether the amplitude at any > given instant is higher or lower than a given threshold value. Please > note that the sinewave is of a single frequency. > > The question I have is, is this a high pass filter concept? > > This is what I thought at the beginning.But then a filter attenuates > certain frequency components and leaves rest untouched. > > In this case, there is exactly one frequency in the input and after > filtering, there is a square waveform. > We know very well that a sine wave had exactly one frequency & did not > have such high frequency component.
If we were getting drunk at a university bar I'd make a bet with you that it's filtering, just for the joy of arguing. However, most people wouldn't call it filtering. If you're doing this in the real world you may use a DC-blocking filter (which is a sort of high- pass filter) before running the signal through a comparator to square it up. I'm not sure WHY you're squaring up your sine wave, but note that doing so in a sample-time environment can lose you a lot of phase information if the signal frequency is close to the sampling rate -- if you look at it in the time domain it's obvious; if you're stuck in the frequency domain then you have to go through a bunch of math to see why the way that the harmonics alias cause the issue. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On 2015-10-14 19:05, Tim Wescott wrote:
[...]
> If we were getting drunk at a university bar I'd make a bet with you that > it's filtering, just for the joy of arguing. > > However, most people wouldn't call it filtering. If you're doing this in
Well, since most people call a "median filter" filter, I guess that the need of linearity in order to get the name "filter" is in the eye of the beholder! :-) And there are rank filters too... In general, in signal processing people seem to narrow the concept of filter to "linear filter. Nevertheless, creative image processing people use a broader concept of filter, including morphological filters, which are by definition non-linear. Not to mention threshold filter, bilateral filters, etc. Meaning, IMHO, that squaring a sin *is* a filter. bye, -- piergiorgio
On Thursday, October 15, 2015 at 6:38:20 AM UTC+13, Piergiorgio Sartor wrote:
> On 2015-10-14 19:05, Tim Wescott wrote: > [...] > > If we were getting drunk at a university bar I'd make a bet with you that > > it's filtering, just for the joy of arguing. > > > > However, most people wouldn't call it filtering. If you're doing this in > > Well, since most people call a "median filter" filter, > I guess that the need of linearity in order to get the > name "filter" is in the eye of the beholder! :-) > > And there are rank filters too... > > In general, in signal processing people seem to narrow > the concept of filter to "linear filter. > Nevertheless, creative image processing people use a > broader concept of filter, including morphological > filters, which are by definition non-linear. > Not to mention threshold filter, bilateral filters, etc. > Meaning, IMHO, that squaring a sin *is* a filter. > > bye, > > -- > > piergiorgio
A zero crossing detector cannot filter when there is noise. it only converts amplitude uncertainty into phase uncertainty. ie AM to PM
On Wed, 14 Oct 2015 19:33:21 +0200, Piergiorgio Sartor
<piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de>
wrote:

>On 2015-10-14 19:05, Tim Wescott wrote: >[...] >> If we were getting drunk at a university bar I'd make a bet with you that >> it's filtering, just for the joy of arguing. >> >> However, most people wouldn't call it filtering. If you're doing this in > >Well, since most people call a "median filter" filter, >I guess that the need of linearity in order to get the >name "filter" is in the eye of the beholder! :-) > >And there are rank filters too... > >In general, in signal processing people seem to narrow >the concept of filter to "linear filter. >Nevertheless, creative image processing people use a >broader concept of filter, including morphological >filters, which are by definition non-linear. >Not to mention threshold filter, bilateral filters, etc. >Meaning, IMHO, that squaring a sin *is* a filter. > >bye,
In some cases I do wonder why the term "filter" is applied. "Filter" tends to imply that something in the input gets passed while other things in the input do not. Is the idea that x(t) = sgn(sin(wt)) removes the amplitude information and lets everything else through? Terminology does seem to be a big problem in dsp. For example the term "squaring a sin" has been used by multiple people in this thread. Is that making a square wave out of a sine wave or is that sin^2(x)? ;) Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com