M
M. Hamed
Disclaimer: this may be a tiny bit off topic for this group.
Now DSP is one of the things that I'm planning to dive deep into at some point. So I know I'm going to get a bunch of those "Get a DSP book". But since I'm going to be working on an AM radio, I decided I would like to understand the mixing process better and demonstrate it in software in a burn before you learn way.
So I fired up Scilab and did the following:
1- create a time array
2- create a bunch of sinusoids at frequencies from 550khz o 1700 khz spacedby 20khz and random phase.
3- Sum all of these sinusoids to create a composite wave.
4- perform FFT on the composite wave.
5- Plot the results
The code is here, if anyone is interested.
https://docs.google.com/document/d/1EQp43CK_ooTF66am9pXCOu5k-vEK21wWJhsdSa6NvZQ/edit?usp=sharing
Now I have to tell you I was a bit surprised by the result. I started playing with both sampling rate and and found the results quite interesting.
This is a picture of the FFT plot with the sampling rate a bit above Nyquist at 4M samples/s (Max AM frequency is 1.7MHz)
https://docs.google.com/file/d/0B1hjUVk4ytmvdXBELTRwanBlcTA/edit?usp=sharing
Now you can see 58 sinusoids which is the correct number created in the time domain, but I expected them to have equal amplitudes. I assume the decreasing amplitude is an artifact of the low sampling rate.
When I increase the sampling rate 10 times more and decrease the time to account for memory shortage, I got what I wanted. 58 sin waves with equal amplitude.
https://docs.google.com/file/d/0B1hjUVk4ytmvMmdvb3JwOGpneDQ/edit?usp=sharing
So far my signal sampling time window was 1 ms. As I decrease this further,I start getting more noise in the amplitudes of the sin waves. For examplehere with a time of 100 us.
https://docs.google.com/file/d/0B1hjUVk4ytmvWGRTdzBfRllZeTQ/edit?usp=sharing
It eventually reaches a point where the sinusoids are completely messed up,even at only half the previous time window 50 us and even with a 400M samples per second rate, much higher than nyquist.
https://docs.google.com/file/d/0B1hjUVk4ytmvWFlvWHZqQ2VJWms/edit?usp=sharing
I am sure there is a DSP explanation for all this. It gives me some motivation to study further. One possibility with relatively short time windows isthat you don't have enough time to capture all the information in the signal that it can't yet be approximated with a sin wave in the discreet domain.. Another possibility is that may be there has to be some relation that needs to be maintained between time window and sampling rate. Don't know.
Next on my plate is to do actual mixing with a sinusoids then do some filtering then another step of down-conversion and demodulation. I have no idea how to do digital filtering in scilab yet but I'll find out.
It was interesting to me, thought It's worth sharing and may be I can get some hints.
Now DSP is one of the things that I'm planning to dive deep into at some point. So I know I'm going to get a bunch of those "Get a DSP book". But since I'm going to be working on an AM radio, I decided I would like to understand the mixing process better and demonstrate it in software in a burn before you learn way.
So I fired up Scilab and did the following:
1- create a time array
2- create a bunch of sinusoids at frequencies from 550khz o 1700 khz spacedby 20khz and random phase.
3- Sum all of these sinusoids to create a composite wave.
4- perform FFT on the composite wave.
5- Plot the results
The code is here, if anyone is interested.
https://docs.google.com/document/d/1EQp43CK_ooTF66am9pXCOu5k-vEK21wWJhsdSa6NvZQ/edit?usp=sharing
Now I have to tell you I was a bit surprised by the result. I started playing with both sampling rate and and found the results quite interesting.
This is a picture of the FFT plot with the sampling rate a bit above Nyquist at 4M samples/s (Max AM frequency is 1.7MHz)
https://docs.google.com/file/d/0B1hjUVk4ytmvdXBELTRwanBlcTA/edit?usp=sharing
Now you can see 58 sinusoids which is the correct number created in the time domain, but I expected them to have equal amplitudes. I assume the decreasing amplitude is an artifact of the low sampling rate.
When I increase the sampling rate 10 times more and decrease the time to account for memory shortage, I got what I wanted. 58 sin waves with equal amplitude.
https://docs.google.com/file/d/0B1hjUVk4ytmvMmdvb3JwOGpneDQ/edit?usp=sharing
So far my signal sampling time window was 1 ms. As I decrease this further,I start getting more noise in the amplitudes of the sin waves. For examplehere with a time of 100 us.
https://docs.google.com/file/d/0B1hjUVk4ytmvWGRTdzBfRllZeTQ/edit?usp=sharing
It eventually reaches a point where the sinusoids are completely messed up,even at only half the previous time window 50 us and even with a 400M samples per second rate, much higher than nyquist.
https://docs.google.com/file/d/0B1hjUVk4ytmvWFlvWHZqQ2VJWms/edit?usp=sharing
I am sure there is a DSP explanation for all this. It gives me some motivation to study further. One possibility with relatively short time windows isthat you don't have enough time to capture all the information in the signal that it can't yet be approximated with a sin wave in the discreet domain.. Another possibility is that may be there has to be some relation that needs to be maintained between time window and sampling rate. Don't know.
Next on my plate is to do actual mixing with a sinusoids then do some filtering then another step of down-conversion and demodulation. I have no idea how to do digital filtering in scilab yet but I'll find out.
It was interesting to me, thought It's worth sharing and may be I can get some hints.