Demodulating a filtered signal

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
I was running some tests with signal carrying and noticed that whenever you use a FIR filter on a modulated signal, all the information is gone!

Since at any given point in time the filtered signal is the weighed average of many previous points, whatever change the amplitude of a constant frequency signal is irrevocably lost.

For instance, if I filter a simple sine wive that is within my passbound limits, I still get the same wave as a result. Okay. But if the signal is, say, one period with amplitude A1 then another with amplitude A2, alternating over and over, the filtered signal has a CONSTANT amplitude, even if A2 = 0. And worse, suppose I have a signal that is |sin wt|. This wave has a period of PI instead of 2.PI, and as a result it is eliminated in the filter because the real frequency lies in the stopband. As a result, no 180o phase shifting survives the filter either.

So, what am I doing wrong? There certainly MUST be a way out of this. Either that or it seems that demodulating a filtered signal is impossible.
 

MrChips

Joined Oct 2, 2009
30,806
When you create a very narrow band-pass filter it becomes a resonance circuit. Any input similar to an impulse function will cause the filter to oscillate. Hence you end up with y = sin(ωt) as output.

What you need is a phase-locked loop (PLL) to demodulate the signal.
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
Thanks a lot, MrChips! And sorry for the multi-posting.

I guess that's exactly the piece of information I needed. I'm already reading about it... at least what I learned about filters wont go to waste, since I see there is a lowpass inside a PLL. Now, I have to implement it over software, are here any online sources you would recommend?
 

MrChips

Joined Oct 2, 2009
30,806
In the past this was done in hardware using LM567 tone decoder.
I am not sure how you would do this in software except by auto-correlation.

How many cycles of the tone signal are you planning on transmitting?
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
For starters, the real data would be only around 20 bits, maybe a little more if everything goes right in the future. So 10 cycles would be enough, right? And I was wondering if it would be nice to add standard beginning and end-message bits so I could recognize the exact point of beginning and end of message, so we could add, I don't know... two or three extra cycles in the beginning and then in the end again? That would make 16 cycles total. Make it 20...
 

MrChips

Joined Oct 2, 2009
30,806
What is your method of encoding?

It would be a good idea to tell us overall what you are attempting to do.

What is the big picture?
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
Well, since there is such a small amount of data, I thought that any encoding system would do the trick. I suppose the easiest way would be to create a "base" sinusoidal signal and then multiply every half wave by the bit I am trying to relay.

The signal that would transmit 001001, for instance, would look like this:

- Starts with 2 full waves as a beginning marker (is this a good idea? I thought so),
- then, the next 6 half waves would have their amplitudes multiplied by 0, 0, 1, 0, 0, 1 (Maybe taken in absolute value also, to make it more unlike beginning and end signals or any other noises)
- finally, 2 full waves again as an ending marker.

This seemed the easiest way to implement because I just have to roll the number I have to relay bit by bit in the same loop I create the sine wave, no other hassles.

That's all I have figured out so far! I'm not sure there is any other thing to it or a larger picture.
 

MrChips

Joined Oct 2, 2009
30,806
For continuity, I post your info from your other thread here:
I am trying to carry some data over sound in environments that have a relevant amount of background noise, so my first step was to design a passband filter (algebraically, not on a circuit). There is a very convenient FIR filter design tool athttp://t-filter.engineerjs.com/, which provided my with an 89 taps filter, given my specs (stopbands 0-4000Hz and 6000 to 22050, passband between 4700 and 5300Hz, sampling 44100Hz).

I implemented the calculations on a spreadsheet and they worked beautifully in several tests with a few simultaneous sinusoidal noises. Now, modulating the data into sound is easy and there are several good alternatives. But when the modulated signal comes out of the filter, the signal is virtually gone, once each filtered signal intensity is a weighted average of 89 previous intensities!

So, for instance, if the unfiltered signal is a full sine wave period alternated with a zero intensity signal ( y = sin wt for 0<wt<2pi and y = 0 for 2pi<wt<4pi), over and over again (simulating an infinite stream of 0s and 1s), the filtered signal is just y = sin wt, all the way through! No matter how I change the amplitude or the phase from one period to the other, the massive data averaging that occurs at the filter erases the whole thing.

Now, I suppose that exactly the same thing happens when you are carrying data over electromagnetic waves. So, what is the solution for this? A filter must always be used, right? And filters always average out signals, so how come the data is not lost? What am I doing wrong here?

Best
Pedro
I still don't know what is your big picture. As far as I can tell, you want to transmit digital information on a 5kHz carrier.

Have you considered using two frequencies also known as frequency-shift keying?
You may want to look at Bell 103 and Bell 202 modems.
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
I'm not sure there is a big picture! I'm just trying to make it happen... I have been recently fired, so I got a lot of time on my hands.

I am trying 5kHz because it has to be high enough to be away from most environmental noise and at the same time far away enough from the sampling rate which is 44100Hz in most mobile devices. At 5kHz, I get some 9 samples per wave, which seems a reasonable number. But of course I could change it.

Yes, I thought of two frequencies, but would it help the demodulation? A single one is definitely easier on the modulation side, given that you want to avoid discontinuities in the signal function.
 

MrChips

Joined Oct 2, 2009
30,806
What is the environmental noise that you anticipate?
5kHz is in the audio range. If you transmit this via a non-acoustic medium, where is the environmental noise?
Why are you transmitting this on a mobile device?

You must have a transmitting device and a receiving device. What are they?
If you cannot reveal the big picture it would be very difficult to provide further advice.

If you have a lot of time on your hands then IOT is the way to go.
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
I was hoping to transmit across a room. I know it would be nicer to be farther away from usual environmental sounds, I was just afraid the signal would be too grainy. I was going for a mobile device because, quite frankly, it would be cool to communicate two cell phones over sound!

Mobile phones would be in both ends. I'm sorry I didn't say that before, it didn't seem relevant and I know that too much details could turn off possible helpers.

Yes, I have a lot of time on my hands but I still would like to perform the task with as little work as possible. I'm an Engineer! :D
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
Yes, I'm quite aware of that. There's a good reason all of our communication at home uses those waves. I'm into sound for the challenge of it, and for the coolness effect.
 

MrAl

Joined Jun 17, 2014
11,474
Hi,

Just a quick note...

The filter is designed according to your spec. If it does not work as expected then you have to redesign it. However, almost every filter will respond to amplitude changes so it is hard to believe that you have a filter that wont. There should also be phase change because of the step change in amplitude.

Maybe you could post your filter and test signal so we know exactly what you are dealing with.
 

LesJones

Joined Jan 8, 2017
4,190
I think MrChips suggestion of frequency shift keying is the best. That method was used over very noisy short wave radio links for radio telytype communications the tone frequencies used were 2125 and 2295 hz. You should find more information on this if you Google "amateur radio RTTY" Using cell phones seems a very expensive way to comunicate across a room.

Les.
 

MrAl

Joined Jun 17, 2014
11,474
Yes, I'm quite aware of that. There's a good reason all of our communication at home uses those waves. I'm into sound for the challenge of it, and for the coolness effect.
Hi,

What is the coolness effect?

Maybe you can use higher frequency sound.

Years and years ago i worked on filters for FSK communications. I remember the boxes these were in. They were something like 4x7x2 inch tin boxes but that was just ONE filter. They were passive L and C filters. That was maybe 1975 ish.
 

Janis59

Joined Aug 21, 2017
1,849
RE""In the past this was done in hardware using LM567 tone decoder.""
567 has three ways how it may be used - one of feet shows a FM demodulated output, other shows AM modulated output, and third is showing yes/no at capture of by hardware chosen frequency. Very nice IC, cost small and work well at just any TV IR remote system. Its only bad habits are that linearity is far from ideal, and input signal level must be rather stabilized. Under 20 mV it will fail and over 200 mV it will fail even more. Ah yes, the frequency is much limited. 455/465 kHz is OK, but with 6,5 MHz is more than hard if at all.
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
Hi,

Just a quick note...

The filter is designed according to your spec. If it does not work as expected then you have to redesign it. However, almost every filter will respond to amplitude changes so it is hard to believe that you have a filter that wont. There should also be phase change because of the step change in amplitude.

Maybe you could post your filter and test signal so we know exactly what you are dealing with.
Well, maybe my expectations are wrong! And according to some experts I've consulted with, I actually was wrong. I expected that the filter removed unwanted frequencies AND left the signal intact. I tested it and it does remove all the freqs it should remove. But the signal does not remain intact.

I tested a FIR bandpass filter with 89 poles and also a very simple lowpass filter based on the integration of first order differential equation of the filter. Both removed unwanted frequencies and messed around with the carrier signal. But I'm sending the spreadsheet anyway.

The FIR is on the first tab. The columns are:
A - time
B - Noise, calculated as the sum of 5 different sines whose frequencies and amplitudes you may change on a table to the right (columns M:S)
C - a pristine sine to be the "base" of the carrrier signal, which you can modulate in the next columns
D - The number of full periods of the carrier signal that have been relayed since t = 0
E - The "modulator factor", which multiplies column C to create the modulation. For instance, you can set the factor to alternate between 1 and -1 at each new period in order to simulate a 180o phase shift (and that is why column D is quite handy). If you do not wish to apply any modulation, just set all lines to 1.
F - The carrier signal, being the "base" sine times the modulator factor.
G - The full input, signal+noise
H - The filtered signal

The second tab has the FIR coefficients and the third one is a lowpass filter.

You will notice that whatever modulation you put into the signal is lost in the filter, even in the absence of noise. Of course if the signal is a thousand periods with amplitude A and then another thousand with amplitude B, then the filter output will show that change. But if you alternate 3 periods with one frequency and then 3 with a different one, then it gets all mixed up. In other words: the filter mixes a number of recent periods in order to create the output signal. For instance, If I want to convey a 01 signal in FM then I have to use, say, 500 periods in one frequency, then 500 in another. The same goes for AM or phase modulation.


https://www.dropbox.com/s/cg6rc3r50rqpbux/Teste filtro BandPass.xlsx?dl=0
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
I think MrChips suggestion of frequency shift keying is the best. That method was used over very noisy short wave radio links for radio telytype communications the tone frequencies used were 2125 and 2295 hz. You should find more information on this if you Google "amateur radio RTTY" Using cell phones seems a very expensive way to comunicate across a room.

Les.
Yes, I'm aware it is not the best engineering solution.
I'm gonna check on the rtty, thanks! The thing is in that situation they probably have very little noise, right? So there would be no need of a filter. My problem is that I have a quite noisy signal, athough the noise is mostly in far away frequencies.
 

Thread Starter

Pedro Malabarte

Joined Dec 27, 2017
13
Hi,

What is the coolness effect?

Maybe you can use higher frequency sound.

Years and years ago i worked on filters for FSK communications. I remember the boxes these were in. They were something like 4x7x2 inch tin boxes but that was just ONE filter. They were passive L and C filters. That was maybe 1975 ish.
The coolness effect is scientifically measured as the answer to the question "But how cool is THIS?" :D

Yes, maybe I could go to 6k or even higher. I'm not sure yet, I guess only real condition tests could tell me the best number. For now, I just wanted to avoid generating a grainy signal.
 
Top