[comp.dsp] 180 deg phase shift

frerichs@adsl (dfRERICHS) (05/06/91)

Does anyone know the algorithm that would take a stream of sampled sound
,shift it 180 deg in phase and spit it back out again?

ie   sound -> a/d -> dsp to shift phase -> d/a -> sound

(it would seem from the nature of the problem that a simplistic analog
 circuit to do this might be possible... some sort of RC net... if anyone
 know if this is possible, PLEASE make it known.)

Thanks

djf

karsh@trifolium.esd.sgi.com (Bruce Karsh) (05/06/91)

In article frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
>Does anyone know the algorithm that would take a stream of sampled sound
>,shift it 180 deg in phase and spit it back out again?
>ie   sound -> a/d -> dsp to shift phase -> d/a -> sound

This one is so easy that I wonder if it's not part of a homework problem.

			Bruce Karsh
			karsh@sgi.com

cas@media-lab.media.mit.edu.MEDIA.MIT.EDU (Scud) (05/06/91)

In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
>Does anyone know the algorithm that would take a stream of sampled sound
>,shift it 180 deg in phase and spit it back out again?

Use an op-amp as as inverter (ie with a gain of -1). One chip, one resistor,
one pot.

cas

wdp@ee.egr.duke.edu (William D. Palmer) (05/06/91)

How about an op-amp inverting amplifier?

Dev Palmer
wdp@dukee.egr.duke.edu
Duke Electrical Engineering
Room 309 Old Engineering Bldg.
Durham, NC  27706
(919) 660-5282

grayt@Software.Mitel.COM (Tom Gray) (05/07/91)

In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
>Does anyone know the algorithm that would take a stream of sampled sound
>,shift it 180 deg in phase and spit it back out again?
>
>ie   sound -> a/d -> dsp to shift phase -> d/a -> sound
>
 
Invert the sign bit

jthornto@ee.ubc.ca (Johan Thornton) (05/07/91)

In article <1420@cameron.egr.duke.edu> wdp@ee.egr.duke.edu (William D. Palmer) writes:
>How about an op-amp inverting amplifier?


Sure... it's simple in the analog domain.  In a digital system, the solution
is a bit more complex.  The transfer function is:

      X =  -X


-- 
Johan Thornton
(but my friends call me jthornto@ee.ubc.ca)

mhorne@jomega.rain.com (Michael T. Horne;649-8957;;;jomega) (05/07/91)

In a recent article by frerichs@adsl (dfRERICHS):

> Does anyone know the algorithm that would take a stream of sampled sound
> ,shift it 180 deg in phase and spit it back out again?
> 

Without giving this much thought :), how about a pair of cascaded Hilbert
transform filters? :)

Mike

mpurtell@IASTATE.EDU (Purtell Michael J) (05/07/91)

In article <7821@nst>, grayt@Software.Mitel.COM (Tom Gray) writes:
> In article <1991May5.233533.18783@ux1.cso.uiuc.edu>
frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
> >Does anyone know the algorithm that would take a stream of sampled
sound
> >,shift it 180 deg in phase and spit it back out again?
> >
> >ie   sound -> a/d -> dsp to shift phase -> d/a -> sound
> >
>  
> Invert the sign bit

Not if it's a 2's complement integer!!

--
-- Michael Purtell --  | "In a hundred years, | There's an Old Irish
Recipe for
mpurtell@iastate.edu   |  we'll all be dead." |   Longevity: Leave the
Table
Iowa State University  |  -- The January Man  |  Hungry.  Leave the Bed
Sleepy.
                "slow is real"                |    Leave the Tavern
Thirsty.

gibbonsj@iccgcc.decnet.ab.com (05/07/91)

In article <1991May5.233533.18783@ux1.cso.uiuc.edu>, frerichs@adsl (dfRERICHS) writes:
> Does anyone know the algorithm that would take a stream of sampled sound
> ,shift it 180 deg in phase and spit it back out again?
> 
> ie   sound -> a/d -> dsp to shift phase -> d/a -> sound
> 
> Thanks
> 
> djf

Its a no-brainer:  just reverse your speaker wires!  Instant 180 degree
phase inversion!    8-]


-- 
  John Gibbons             N8OBJ                     Macedonia, Ohio

           "Welcome My Son, Welcome To The Machine" - Pink Floyd

jfa0522@hertz.njit.edu (john f andrews ece) (05/07/91)

In article <1644@fs1.ee.ubc.ca> jthornto@ee.ubc.ca (Johan Thornton) writes:
>In article <1420@cameron.egr.duke.edu> wdp@ee.egr.duke.edu (William D. Palmer) writes:
>>How about an op-amp inverting amplifier?
>
>
>Sure... it's simple in the analog domain.  In a digital system, the solution
>is a bit more complex.  The transfer function is:
>
>      X =  -X
>
>
>-- 
>Johan Thornton
>(but my friends call me jthornto@ee.ubc.ca)

Well, sure, you all can say how easy it is, but you're stopping shy of the
hard part. Can't implement a transfer function without getting it into the
form of a difference equation! That's the challenge...


-----------------------------------------------------------------------------
john f andrews                SYSOP           The Biomedical Engineering BBS
    24 hrs             300/1200/2400/4800               (201) 596-5679
-----------------------------------------------------------------------------
INTERNET jfa0522@hertz.njit.edu                                CIS 73710,2600
-----------------------------------------------------------------------------

jim@fuji.eng.Yale.edu (James J. Szinger) (05/08/91)

In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl (dfRERICHS) writes:

   Does anyone know the algorithm that would take a stream of sampled sound
   ,shift it 180 deg in phase and spit it back out again?

   ie   sound -> a/d -> dsp to shift phase -> d/a -> sound

   (it would seem from the nature of the problem that a simplistic analog
    circuit to do this might be possible... some sort of RC net... if anyone
    know if this is possible, PLEASE make it known.)

   Thanks

   djf

I think what you are looking for is the Hilbert Transform.  A
Hilbert Xform shifts the phase of the signal by 90 degrees.  Just
cascade two of them together for a total of 180 degrees.  

There might be an easier way but I can't quite think of it.

Jim
--
James J. Szinger                  Becton Center
jim@fuji.eng.yale.edu             15 Prospect Street
Intelligent Sensors Lab.          Box 2157 Yale Station
Electrical Engineering            New Haven, Connecticut 06520
Yale University                   U.S.A.

todd@appmag.com (Todd Day) (05/08/91)

%Well, sure, you all can say how easy it is, but you're stopping shy of the
%hard part. Can't implement a transfer function without getting it into the
%form of a difference equation! That's the challenge...

Well, I can see you guys are having fun with this, but let me make a
few comments.

First of all, 180 deg phase shift is not the same as simply inverting
the signal.  A phase shift implies a time delay of some sort.

Second of all, he *may* have meant a 180 deg phase shift for each of the
frequencies that add up to his composite signal.  The output signal will
definitely NOT look much like the input signal.  You can prove this to your
self by drawing a time axis and delaying a 100 Hz and 50 Hz signal by 180
degrees.  What you can see is similar to what happens in a typical speaker
system when an impulse sound like a drum hit is reproduced.  Most of the
time, it doesn't sound quite right because of the "phase smearing" that
results...

-- 
Todd Day  |  todd@appmag.com

wilf@sce.carleton.ca (Wilf Leblanc) (05/08/91)

todd@appmag.com (Todd Day) writes:

>%Well, sure, you all can say how easy it is, but you're stopping shy of the
>%hard part. Can't implement a transfer function without getting it into the
>%form of a difference equation! That's the challenge...

Want a difference equation ??

y(n) = -x(n)

>[...]

>First of all, 180 deg phase shift is not the same as simply inverting
>the signal.  A phase shift implies a time delay of some sort.

Oh, it does does it ??

Does a transfer function H(z) = -1 imply a time delay ??

[...]

>-- 
>Todd Day  |  todd@appmag.com
--
Wilf LeBlanc, Carleton University, Systems & Comp. Eng. Ottawa, Canada, K1S 5B6
Internet: wilf@sce.carleton.ca   UUCP: ...!uunet!mitel!cunews!sce!wilf
                Oh, cruel fate! Why do you mock me so! (H. Simpson)

karsh@trifolium.esd.sgi.com (Bruce Karsh) (05/09/91)

In article <1991May8.022953.781@appmag.com> todd@appmag.com (Todd Day) writes:

>First of all, 180 deg phase shift is not the same as simply inverting
>the signal.  A phase shift implies a time delay of some sort.

Sorry, but a phase shift need not imply a time delay.  The amount of delay
is called the group delay and it is the slope of the graph of the delay
function.  It's really only meaningful to think of it as a delay if the
delay function is largely a straight line.

The problem is that sin waves are periodic, so you can't really say whether
on is delayed with respect to another, or advanced.  Since the signal
is composed of the sum of sin waves, if you delay (or advance) all the
sin waves by 180 degrees, then you've just inverted all their signs.  When
you sum them all together, you get -1 times the original signal.

			Bruce Karsh
			karsh@sgi.com

jbuck@janus.Berkeley.EDU (Joe Buck) (05/09/91)

In article <1991May8.022953.781@appmag.com> todd@appmag.com (Todd Day) writes:
>First of all, 180 deg phase shift is not the same as simply inverting
>the signal.  A phase shift implies a time delay of some sort.

Todd, you're too smart for your own good, and so are the people talking
about Hilbert transforms, even though they are, in a sense, right.

>Second of all, he *may* have meant a 180 deg phase shift for each of the
>frequencies that add up to his composite signal.

OK, this means that |H(j omega)| should be 1 and arg(H (j omega)) should
be pi for all omega (H is the transfer function).  That means that
H(j omega) should be -1 for all omega, so simply inverting the signal
really does shift by 180 degrees at all frequencies.

Now, for the Hilbert transform people.  The Hilber transform is a filter
whose response is -j for positive frequencies and j for negative frequencies,
and it causes a 90 degree phase shift.  Now let's cascade two of them.
We square the transfer function to obtain the total transfer function.
Note that j^2 = (-j)^2 = -1, so again we get a simple inversion.

>  The output signal will
>definitely NOT look much like the input signal.  You can prove this to your
>self by drawing a time axis and delaying a 100 Hz and 50 Hz signal by 180
>degrees.

You screwed up your plot, Todd.  Otherwise you'd find that the right
answer is an inversion.  Since each individual component is negated by
a 180 degree shift, clearly the sum is.

The original poster clearly had a homework problem with a trivial answer,
and all these "experts" screwed it up.  Embarrassing...

--
Joe Buck
jbuck@janus.berkeley.edu	 {uunet,ucbvax}!janus.berkeley.edu!jbuck	

steveq@syd.dms.CSIRO.AU (Stephen Quigg) (05/09/91)

In article <5781@media-lab.media.mit.edu.MEDIA.MIT.EDU> cas@media-lab.media.mit.edu (Scud) writes:
>In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
>>Does anyone know the algorithm that would take a stream of sampled sound
>>,shift it 180 deg in phase and spit it back out again?
>
>Use an op-amp as as inverter (ie with a gain of -1). One chip, one resistor,
>one pot.
>
>cas
 Inverting is NOT the same as 180 deg phase shift. For a symetric waveform
(eg a sine wave) it looks the same, but with something assymetric what you
will see is the waveform upside-down, which is not the same as shifted 180
deg. Phase shifting moves a waveform along the time axis: it stays the same
way up. Try it on an oscilloscope.

todd@appmag.com (Todd Day) (05/09/91)

I wrote:

%Second of all, he *may* have meant a 180 deg phase shift for each of the
%frequencies that add up to his composite signal.  The output signal will
%definitely NOT look much like the input signal.

Sorry about this.  "Phase smearing" does not occur at multiples of pi/2.
I had this visualized totally wrong.  After thinking about "the sum of
infinite sinewaves", I realized that at 180, this sum does align properly
and makes the inverse.  I had gotten it confused with an argument I had
previously discussing 90 degree phase shift in speakers, which definitely
DOES smear the output.

Sorry.

-- 
Todd Day  |  todd@appmag.com

todd@appmag.com (Todd Day) (05/09/91)

steveq@syd.dms.CSIRO.AU (Stephen Quigg) writes:

% Inverting is NOT the same as 180 deg phase shift.

See?  I'm not the only one who didn't do his homework... :-)

I gotta start reading my ASSPs again!

-- 
Todd Day  |  todd@appmag.com

mcmahan@netcom.COM (Dave Mc Mahan) (05/09/91)

 In a previous article, karsh@trifolium.sgi.com (Bruce Karsh) writes:
>In article <1991May8.022953.781@appmag.com> todd@appmag.com (Todd Day) writes:
>
>>First of all, 180 deg phase shift is not the same as simply inverting
>>the signal.  A phase shift implies a time delay of some sort.
>
>Sorry, but a phase shift need not imply a time delay.  The amount of delay
>is called the group delay and it is the slope of the graph of the delay
>function.  It's really only meaningful to think of it as a delay if the
>delay function is largely a straight line.
>
>The problem is that sine waves are periodic, so you can't really say whether
>on is delayed with respect to another, or advanced.  Since the signal
>is composed of the sum of sine waves, if you delay (or advance) all the
>sin waves by 180 degrees, then you've just inverted all their signs.  When
>you sum them all together, you get -1 times the original signal.

This works great for pure tones, but if you have a signal (such as that from
an ECG or a modem that uses phase or frequency shifting) then the input signal
will not be a pure tone, but rather a sum of sine waves that vary in
amplitude over time.  I think (just to add another voice to this mess) that
the correct 'theoretical' answer is to find a filter that actually does 
produce the proper time shift for each frequency.  The 'realistic' answer is
that this just negating the input signal (Y[n] = -X[n]) is probably what the
original poster needs to know.  Once again, I guess you have to know the
full needs of the application before you can provide the full answer.
(Is this another case where we engineers charge off to solve the wrong
 problem?  :-)

>			Bruce Karsh
>			karsh@sgi.com

  -dave

-- 
Dave McMahan                            mcmahan@netcom.com
					{apple,amdahl,claris}!netcom!mcmahan

heredia@enel.ucalgary.ca (Edwin Heredia) (05/09/91)

For those who can't believe that inverting the signal produces 
a 180 deg. phase shift and for those who think that this trick 
works only with "easy-to-work" signals as pure tones:

Given *ANY* signal  x(n)  with Fourier Transform  X(w)

Consider the transformation          y(n) = (-1) * x(n)

in the Fourier domain this gives     Y(w) = (-1) * X(w)

which is                         Y(w) = exp(j180) * X(w)

result: 180 deg. phase shift!

where *ANY* means really *any*, that is ECG's, speech, etc., and 
(-1)*x(n)  means really inverting the signal.

---------
If a 180 deg shift produced about 15 articles posted, how many 
would be produced by a 360 deg shift? Answer: 2*15 = 30

myhui@bnr.ca (Michael Hui) (05/10/91)

In article <1991May9.160115.3494@cpsc.ucalgary.ca> heredia@enel.ucalgary.ca (Edwin Heredia) writes:
>For those who can't believe that inverting the signal produces 
>a 180 deg. phase shift and for those who think that this trick 
>works only with "easy-to-work" signals as pure tones:
>
>Given *ANY* signal  x(n)  with Fourier Transform  X(w)
        ^^^

Really? You surely mean _periodic_ signal.

      Michael MY Hui      Ottawa Canada      myhui@bnr.ca

whit@milton.u.washington.edu (John Whitmore) (05/10/91)

In article <1991May8.222501.19572@syd.dms.CSIRO.AU> steveq@syd.dms.CSIRO.AU (Stephen Quigg) writes:
>In article <5781@media-lab.media.mit.edu.MEDIA.MIT.EDU> cas@media-lab.media.mit.edu (Scud) writes:
>>In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
>>>Does anyone know the algorithm that would take a stream of sampled sound
>>>,shift it 180 deg in phase and spit it back out again?
>>
>>Use an op-amp as as inverter (ie with a gain of -1). 

> Inverting is NOT the same as 180 deg phase shift. For a symetric waveform
>(eg a sine wave) it looks the same, but with something assymetric what you
>will see is the waveform upside-down, which is not the same as shifted 180
>deg. Phase shifting moves a waveform along the time axis: it stays the same
>way up. Try it on an oscilloscope.


	That's wrong.  The inverter is a perfectly good 180 degree
phase shifter, and if you test it at ANY frequency you will see
180 degrees of phase shift; the phase shift versus frequency is
EXACTLY what was asked for.
	Your 'assymmetric waveform' has a lot of Fourier components,
and time-shifting it as you seem to be describing is NOT a
well-defined operation.  You have to find some particular frequency,
derive a time delay from THAT ONE FREQUENCY COMPONENT, and apply
that time delay to get the time-shift, and that is NOT the correct
phase shift for any frequency component except the one you
chose as 'most significant'.

	John Whitmore

grayt@Software.Mitel.COM (Tom Gray) (05/10/91)

In article <1991May10.003817.5593@milton.u.washington.edu> whit@milton.u.washington.edu (John Whitmore) writes:
:In article <1991May8.222501.19572@syd.dms.CSIRO.AU> steveq@syd.dms.CSIRO.AU (Stephen Quigg) writes:
:>In article <5781@media-lab.media.mit.edu.MEDIA.MIT.EDU> cas@media-lab.media.mit.edu (Scud) writes:
:>>In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
:>>>Does anyone know the algorithm that would take a stream of sampled sound
:>>>,shift it 180 deg in phase and spit it back out again?
:>>

:>deg. Phase shifting moves a waveform along the time axis: it stays the same
:>way up. Try it on an oscilloscope.
:
:
:	That's wrong.  The inverter is a perfectly good 180 degree
:phase shifter, and if you test it at ANY frequency you will see
:180 degrees of phase shift; the phase shift versus frequency is
:EXACTLY what was asked for.
:	Your 'assymmetric waveform' has a lot of Fourier components,
:and time-shifting it as you seem to be describing is NOT a
:well-defined operation.  You have to find some particular frequency,

Not trying to be impudent but just trying to expand on the
idea which Mr. Whitmore put forward.

Time shifting is a well defined operation. A time shift in the
time domain is equivalent to multiplying the frequency domain
function by e**(-jwT) (where T is the magnitude of the time
shift). Remember the requirment in linear systems for a
linear phase response. Well this is where it comes from.

A time delay will not cause a constant phase change for all
frequencies. Instead the it will produce a linear relationship
betweem phase and frequency.


---------------------------------------------------------------
Tom Gray
-------------------------------------------------------------- 
:derive a time delay from THAT ONE FREQUENCY COMPONENT, and apply
:that time delay to get the time-shift, and that is NOT the correct
:phase shift for any frequency component except the one you
:chose as 'most significant'.

karsh@trifolium.esd.sgi.com (Bruce Karsh) (05/10/91)

>>Given *ANY* signal  x(n)  with Fourier Transform  X(w)
>Really? You surely mean _periodic_ signal.

A signal doesn't have to be periodic to have a Fourier transform.  Any
sequence x(n) that is absolutely summable (i.e., the sum of the absolute
values is bounded) has a Fourier transform given by:

	       inf	
	X(w) = sum	  x(n)e^(-jwn)
	       n = -inf

			Bruce Karsh
			karsh@sgi.com

jfa0522@hertz.njit.edu (john f andrews ece) (05/10/91)

In article <1991May09.192740.4165@bmerh2.bnr.ca> myhui@bnr.ca (Michael Hui) writes:
>In article <1991May9.160115.3494@cpsc.ucalgary.ca> heredia@enel.ucalgary.ca (Edwin Heredia) writes:
>>For those who can't believe that inverting the signal produces 
>>a 180 deg. phase shift and for those who think that this trick 
>>works only with "easy-to-work" signals as pure tones:
>>
>>Given *ANY* signal  x(n)  with Fourier Transform  X(w)
>        ^^^
>
>Really? You surely mean _periodic_ signal.
>
>      Michael MY Hui      Ottawa Canada      myhui@bnr.ca

Why do we keep tagging onto this thread? "any signal ..with a fourier
ransform" implies any periodic signal....so why the beef? Let it go!

ikw@genrad.UUCP (Isaac K. Wong) (05/11/91)

In article <1991May09.192740.4165@bmerh2.bnr.ca> myhui@bnr.ca (Michael Hui) writes:
=>In article <1991May9.160115.3494@cpsc.ucalgary.ca> heredia@enel.ucalgary.ca (Edwin Heredia) writes:
=>>
=>>Given *ANY* signal  x(n)  with Fourier Transform  X(w)
=>        ^^^
=>
=>Really? You surely mean _periodic_ signal.
=>

and a linear system too. and I am sure the ANY signal you mentioned doesn't
include DC. :)




-- 
Isaac Wong	     		||	There's no need to worry about death,
GenRad, Milpitas, CA		||	it will not happen in your lifetime.
wongi@topo.genrad.com 		||
wongi@topo.uucp 		||	-Raymond Smullyan

karsh@trifolium.esd.sgi.com (Bruce Karsh) (05/11/91)

In article jfa0522@hertz.njit.edu (john f andrews ece) writes:

>Why do we keep tagging onto this thread? "any signal ..with a fourier
>ransform" implies any periodic signal....so why the beef? Let it go!

Because what you said is wrong.  It is simply not the case that the
existence of a Fourier transform of a function or a series implies periodicity.

The existence of a Fourier sequence implies periodicity, but that is another
matter.  The Fourier transform exists for non-periodic functions which are
absolutely summable.

			Bruce Karsh
			karsh@sgi.com

jsorenso@thesis1.med.uth.tmc.edu (JEFFREY MARIUS SORENSON) (05/12/91)

In article <1991May8.222501.19572@syd.dms.CSIRO.AU> steveq@syd.dms.CSIRO.AU (Stephen Quigg) writes:
>In article <5781@media-lab.media.mit.edu.MEDIA.MIT.EDU> cas@media-lab.media.mit.edu (Scud) writes:
>>In article <1991May5.233533.18783@ux1.cso.uiuc.edu> frerichs@adsl.ece.uiuc.edu (dfRERICHS) writes:
>>>Does anyone know the algorithm that would take a stream of sampled sound
>>>,shift it 180 deg in phase and spit it back out again?
>>
>>Use an op-amp as as inverter (ie with a gain of -1). One chip, one resistor,
>>one pot.
>>
>>cas
> Inverting is NOT the same as 180 deg phase shift. For a symetric waveform
>(eg a sine wave) it looks the same, but with something assymetric what you
>will see is the waveform upside-down, which is not the same as shifted 180
>deg. Phase shifting moves a waveform along the time axis: it stays the same
>way up. Try it on an oscilloscope.



Are we talking about phase shifts or time shifts?  
Phase Shift:  Since the signal can be represented as a sum (or integral) of
complex exponetials, phase shifting can be done by simply multiplying the whole
sum (integral) by exp(  i*p ), where p is the value of the phase shift. This
can be visualized by rotating a vector (our signal) by 180 degrees in the 
complex plane. Since a phase shift of pi (180 degrees) for each component of 
the Fourier series gives that same component multiplied by -1 (e(i*180) = -1), 
the sum of the phase shifted (180 degrees) components gives the original signal
multiplied by -1.  So phase shifting by 180 degrees IS inverting.  This is
why signals that are 180 degrees out of phase are said to cancel eachother out

Time Shift:  A time shift is equivalent to phase shifting each component of
the signal by its frequency times the value of the time shift, not simply 
phase shifting each frequency component by the same phase. This is NOT 
the same thing as performing a simple phase shift on the entire signal.  (It
just happens that for a signal composed of a single frequency (a sine wave), 
a time shift of half the period is equivalent to a phase shift of 180 degrees)

As I understand it, a phase shift by 180 degrees IS inversion.
If I am not using the conventional definitions of the terms "phase shift" and 
"time shift", please let me know.
 






















-- 
-------------------------------------------------------------------------------
jsorenso@thesis1.med.uth.tmc.edu |
				 |
				 |

mcphail@dataco.UUCP (Alex McPhail) (05/14/91)

>> Inverting is NOT the same as 180 deg phase shift. For a symetric waveform
>>(eg a sine wave) it looks the same, but with something assymetric what you
>>will see is the waveform upside-down, which is not the same as shifted 180
>>deg. Phase shifting moves a waveform along the time axis: it stays the same
>>way up. Try it on an oscilloscope.

In article <1991May10.003817.5593@milton.u.washington.edu> whit@milton.u.washington.edu (John Whitmore) writes:

>	That's wrong.  The inverter is a perfectly good 180 degree
>phase shifter, and if you test it at ANY frequency you will see
>180 degrees of phase shift; the phase shift versus frequency is
>EXACTLY what was asked for.
>	Your 'assymmetric waveform' has a lot of Fourier components,
>and time-shifting it as you seem to be describing is NOT a
>well-defined operation.  You have to find some particular frequency,
>derive a time delay from THAT ONE FREQUENCY COMPONENT, and apply
>that time delay to get the time-shift, and that is NOT the correct
>phase shift for any frequency component except the one you
>chose as 'most significant'.
>
>	John Whitmore


Sorry, John.  I usually don't butt into other people's business here, but
you really are dead wrong.  The phase shift described above is indeed 
correct.  Since any periodic function is always measured against time, 
shifting the function's phase is also a time-related operation.  

In specific response to your article, frequency and Fourier components
have nothing to do with phase shifting.  The shift of a phase, in degrees,
can be expressed by:

dt
-- x 360
L

where:  dt is the shift of the function
        L is the wavelength of the function

Diagramatically, the following example shows the difference 
of a sawtooth wave shifted by 180 degrees, and an inverted sawtooth wave.

      .      .      .      .
     /|     /|     /|     /|
    / |    / |    / |    / |
   /  |   /  |   /  |   /  |
  /   |  /   |  /   |  /   |
 /    | /    | /    | /    |
/     |/     |/     |/     |          Normal sawtooth wave


         .      .      .      .
        /|     /|     /|     /|
       / |    / |    / |    / |
      /  |   /  |   /  |   /  |
     /   |  /   |  /   |  /   |
    /    | /    | /    | /    |
   /     |/     |/     |/     |       Shifted sawtooth wave


\     |\     |\     |\     |
 \    | \    | \    | \    |
  \   |  \   |  \   |  \   |
   \  |   \  |   \  |   \  |
    \ |    \ |    \ |    \ |
     \|     \|     \|     \|
      `      `      `      `         Inverted sawtooth wave
============================================================================
________
|\     /  Alex McPhail
| \   /
|  \ /    mail to mcphail@dataco              
|---X     (uunet!mitel!melair!dataco!mcphail)
|  / \
| /   \   "Wwwwwhat is the air speed of an average swallow?"
|/_____\   
  Alex


 

***--------------------------------------------------------------***
* DISCLAIMER:                                                      *
* ==========:                                                      *
*    The opinions expressed are solely of the author and do not    *
*    necessarily reflect the opinions of Canadian Marconi Company. *
***--------------------------------------------------------------***

myhui@bnr.ca (Michael Hui) (05/15/91)

In article <625@fudd.dataco.UUCP> mcphail@taarna.UUCP (Alex McPhail,DC ) writes:
>      .      .      .      .
>     /|     /|     /|     /|
>    / |    / |    / |    / |
>   /  |   /  |   /  |   /  |
>  /   |  /   |  /   |  /   |
> /    | /    | /    | /    |
>/     |/     |/     |/     |          Normal sawtooth wave
>
>         .      .      .      .
>        /|     /|     /|     /|
>       / |    / |    / |    / |
>      /  |   /  |   /  |   /  |
>     /   |  /   |  /   |  /   |
>    /    | /    | /    | /    |
>   /     |/     |/     |/     |       Shifted sawtooth wave
>
>\     |\     |\     |\     |
> \    | \    | \    | \    |
>  \   |  \   |  \   |  \   |
>   \  |   \  |   \  |   \  |
>    \ |    \ |    \ |    \ |
>     \|     \|     \|     \|
>      `      `      `      `         Inverted sawtooth wave
>============================================================================
>________
>|\     /  Alex McPhail
>| \   /
>|  \ /    mail to mcphail@dataco              
>|---X     (uunet!mitel!melair!dataco!mcphail)

Brilliant. Absolutely brilliant (!).

Now for my comments, IMHO: inverting shifts all frequency components by pi
degrees. That means, taken time-wise, high frequencies are shifted less in time
than low frequencies. That's how you get the inverted sawtooth above. Imagine
how the fundamental would look in the original wave. Invert it. Lo and behold,
it does fit the inverted sawtooth!!!

But the original question was to shift the phase of a signal by 180 degrees,
which implicitly means to delay the signal by pi degrees as referred to its
fundamental frequency.

      Michael MY Hui      Ottawa Canada      myhui@bnr.ca

jthornto@ee.ubc.ca (Johan Thornton) (05/15/91)

In article <1991May15.031706.15559@bmerh2.bnr.ca> myhui@bnr.ca (Michael Hui) writes:
>Now for my comments, IMHO: inverting shifts all frequency components by pi
>degrees. 

Pi degrees?  Ok, that's easy, pi^2/180 radians.

>But the original question was to shift the phase of a signal by 180 degrees,
>which implicitly means to delay the signal by pi degrees as referred to its
>fundamental frequency.

This shouldn't be too difficult.  I just finished my thesis on a device that
delays a signal by 360 degrees with respect to its fundamental.  It was
pretty complicated, but your device should be about half as complicated.

-- 
Johan Thornton
(but my friends call me jthornto@ee.ubc.ca)

whit@milton.u.washington.edu (John Whitmore) (05/15/91)

In article <625@fudd.dataco.UUCP> mcphail@taarna.UUCP (Alex McPhail,DC ) writes:
>  Since any periodic function is always measured against time, 
>shifting the function's phase is also a time-related operation.  
>
> .... frequency and Fourier components
>have nothing to do with phase shifting.

	I disagree.  In discussing networks (or filters), one usually
refers to the Bode plot of amplitude and of phase shift plotted
against frequency.  The normal meaning in the context of
filters of the phrase 'phase shift' is the phase part of that
representation, and 'constant 180 degree phase shift' is
clear and unambiguous.  It means amplitude inversion.

	What earthly use are 'degrees' in describing the phase
of something which is not a circular function?

	And, why do you refer to 'any periodic function' in
this discussion?  To the best of my recollection, there
was never any statement made that the function under discussion
was periodic.  Phase shifts are well-defined in the absence
of periodicity, though easier to measure and display in the
case of periodic test waveforms.

	John Whitmore

amr@egr.duke.edu (Anthony M. Richardson) (05/15/91)

I find it interesting that this thread has dragged on as long as
it has.  I assume that this is due to a tendency to respond
without taking time to think about the problem.

To phase shift a signal means to multiply its Fourier transform
by exp(j A) where A is the desired phase shift in radians.
The inverse Fourier transform of the signal exp(j A) X(w) is
exp(j A) x(t).  (We're just multiplying by a scalar here. There is
no time shift.  If we had multiplied by exp(j A w) instead of
exp(j A) the corresponding time signal would be x(t + A).)
If A is equal to pi (180 degrees) then exp(j A) = -1 and so we
are just inverting the signal.

Notice that there is no requirement for the signal to be periodic.
It just has to be Fourier transformable.

I suspect the problem is that many people are thinking in terms
of Fourier series and phase shifting each component of the series.
We still get the same result though. If x(t) is periodic
we can represent it in a Fourier series as
      x(t) = Sum a(k) exp(j k w0 t)
where the Sum is over all k and w0 is the fundamental frequency.
Now shift each component by A radians.  Call this new signal y(t).
      y(t) = Sum a(k) exp[j (k w0 t + A)]
(Notice again that if A is equal to pi, then y(t) = -x(t).)
What is the time shift of each component?  Rewrite as
      y(t) = Sum a(k) exp[j k w0 (t + A/(k w0))].
The time shift of each component depends upon the frequency of the
component,  so the time shift of each component waveform is not
the same.  (This is obvious if you sketch two harmonically related
sinusoids and then sketch their 180 degree phase shifted version.)

This has all been said by others.  I just that I would throw in my
$.02 because the argument seemed to be shifting to the wrong answer.

Regards,
Tony Richardson

amr@egr.duke.edu

jefft@phred.UUCP (Jeff Taylor) (05/21/91)

All the postings on 180 deg phase shifts reminds me of standard questions I
ask when interviewing for positions which require some knowledge of DSP.

	"WHEN WOULD YOU USE A FIR FILTER?"

	"If I wanted a linear phase linear phase characteristics."

	"HOW DO YOU GET A LINEAR PHASE CHARACTERISTIC? "

	"Have a symeterical time response."

	"WHERE ARE THE ZEROS?

	"On the unit circle."

	"DOESN'T THAT GIVE PHASE SHIFTS OF 180 DEG'S?

(it's kind of fun watching people sort through the dichotomy - everyone KNOWS
 symeterical fir filters have linear phase, but the zeros are on the unit
 circle - which does give a 180 deg phase shift)

I suppose it depends on how one wants to interperate signal inversion.



-- 
-----------------------------------------------------------------------------
 Jeff Taylor
 Physio Control Corp.
-----------------------------------------------------------------------------

wilf@sce.carleton.ca (Wilf Leblanc) (05/24/91)

jefft@phred.UUCP (Jeff Taylor) writes:

>: 30

>All the postings on 180 deg phase shifts reminds me of standard questions I
>ask when interviewing for positions which require some knowledge of DSP.

>	"WHEN WOULD YOU USE A FIR FILTER?"

>	"If I wanted a linear phase linear phase characteristics."

>	"HOW DO YOU GET A LINEAR PHASE CHARACTERISTIC? "

>	"Have a symeterical time response."

>	"WHERE ARE THE ZEROS?

>	"On the unit circle."

>	"DOESN'T THAT GIVE PHASE SHIFTS OF 180 DEG'S?

>(it's kind of fun watching people sort through the dichotomy - everyone KNOWS
> symeterical fir filters have linear phase, but the zeros are on the unit
> circle - which does give a 180 deg phase shift)

>I suppose it depends on how one wants to interperate signal inversion.

"... but the zeros are on the unit circle" ??????

O.K. smartass, I'll play your game:

    H(z) = (1+0.5 z^-1)(1+2z^-1)
         = 1 + 2.5z^-1 + z^-2

Looks symmetric, looks too me like either you are wrong or
0.5/1 = 2/1 = 1.


Nothing like interviewing someone, trying to screw them up, and
being completely wrong, eh ??

The zeros are not on the unit circle.

>-- 
>-----------------------------------------------------------------------------
> Jeff Taylor
> Physio Control Corp.
>-----------------------------------------------------------------------------
--
Wilf LeBlanc, Carleton University, Systems & Comp. Eng. Ottawa, Canada, K1S 5B6
Internet: wilf@sce.carleton.ca   UUCP: ...!uunet!mitel!cunews!sce!wilf
                Oh, cruel fate! Why do you mock me so! (H. Simpson)

jefft@phred.UUCP (Jeff Taylor) (05/29/91)

In article <wilf.675023233@rigel.sce.carleton.ca> wilf@sce.carleton.ca (Wilf Leblanc) writes:
>
>"... but the zeros are on the unit circle" ??????
>
>O.K. smartass, I'll play your game:
>
>    H(z) = (1+0.5 z^-1)(1+2z^-1)
>         = 1 + 2.5z^-1 + z^-2
>
>Looks symmetric, looks too me like either you are wrong or
>0.5/1 = 2/1 = 1.
>
>
>Nothing like interviewing someone, trying to screw them up, and
>being completely wrong, eh ??
>
>The zeros are not on the unit circle.
>

COMPLETELY wrong?  Half wrong perhaps, (and technically not even that).
Linear phase FIR filters have zeros either on the unit circle in complex
conj. pairs, or in pairs with a reciprocal magnitude (and their complex
conj's).  I ignored the second class (because I forgot about them :( ).
I *think* the remez exchange will generate filters with both kinds of zeros.

Using your filter as an example, changing the second coefficient to anything
less then two will generate complex zeros - which should be on the unit circle.
The time response is still symmetric, so it meets the necessary and sufficent
condition for linear phase, but it does have single zeros on the unit circle.

Example:

	H(z) = 1 + (2/sqrt[2])z^-1 + z^-2 
	H(z) = [(z^-1) - (e^j*pi/4)]*[(z^-1) - (e^-j*pi/4)]

(That's hard to read, should represent a zero an +- 45 deg on the unit circle,
 if I didn't make another mistake)

The point I was trying to make is there are filters which satisfy the
conditions for linear phase, but which place a zero on the unit circle.
I don't know what the significance of this is because I have never used
the linear phase property of FIR filters.  I expect it would give unexpected
results if a filtered signal was summed with one which was just delayed.

As for trying to screw someone up, I think it is important to know why you
know something.  The reason we know symmetric filters have linear phase is
the fourier transform of a symmetric signal is real.  But negative
numbers are real.  So if you plot |gain| and phase, there will be 180 deg
phase shifts.

As an example consider a rectangular pulse, symetric about 0.  It has a sinc
function as a transform - which is real, but bi-phasic.  It's real, so it has
no phase shift.  If it is the impulse response of a filter, does it just
invert some frequencies, or does it have 180 deg phase shift?

Does anyone use the linear phase property of FIR filters in practice?  Is it
necessary avoid zeros on the unit circle?

jt

-- 
-----------------------------------------------------------------------------
 Jeff Taylor
 Physio Control Corp.
-----------------------------------------------------------------------------