FM simulation in Python

1

I studied the third semester of electrical engineering, my teacher commented that it is possible to simulate signal modulations programmatically, I had a brief introduction to the programming logic in the course, but I can not imagine how for example FM radio waves could be simulated within an algorithm, does anyone have experience with this type of subject?

    
asked by anonymous 20.04.2016 / 16:47

1 answer

2

I can try to help yes, I presume your teacher has talked about simulating demodulation modulation.

  

As for example FM radio waves could be simulated within a   algorithm

Let's make it clear, the physical laws governing the universe allow you to carry frequencies in the form of electromagnetic waves, the simplest way I can imagine to explain is that radio waves are just electromagnetic waves that propagate in a vacuum at the speed of light, these waves are created when an antenna disturbs free electrons to oscillate at a desired frequency (radio station frequency for example), so the current produced by the antenna will create a magnetic field propagating around the antenna, so the induction of an electric field promotes the variation of the magnetic field forming the electromagnetism, I said all this to say that this process is physical and therefore does not have much to simulate, but the thing changes of figure when we speak of the process of modulation and demodulation , when we speak of FM=Frequency Modulation we are using nature our favor to put information within a certain we can do this within a program, we can modulate a signal and then dump this signal into an antenna and it is also it is possible to make the inverse pick up the signal from an antenna and demodulate within an algorithm, we can also just modulate a signal within a carrier frequency and then demodulate to understand how the process works.

For transmission and reception of% commercial radios it has been defined that frequencies must be used between FM , there are some rules, the band used must be 150KHz (150,000 hertz), so the modulation will occur within this band, a radio transmitting at the frequency of 88 à 108 Mega Hertz modulates its frequencies between 88Mhertz

I can demonstrate these steps using matlab:

[m, fs, bits]=wavread('C:\Users\GTI\Desktop\Eder\Python26\tech.wav');

m=m(:,1);


portadora=88*10^6 %FM radio 88Mhz
fsm=((108*10^6)*2);
desvio=75000;


l = length(m);
t = 0:1./fsm:(l-1)./fsm;
int_m = cumsum(m)./fsm;
s = cos((2*pi.*portadora.*t)' + 2*pi.*desvio.*int_m); 

The variable (88-0.15)=87.85MHz à 88.15MHz=(88+0.15) contains its modulated signal within the carrier frequency, in this case s , we can now plot this modulated signal and check the signal in the frequency domain:

lolu=fft(s);
Nyquist = fsm / 2;
MinFrequency=Nyquist / (length(lolu) / 2);
Frequency=((MinFrequency):MinFrequency:Nyquist);
plot(Frequency, abs(lolu(1:length(lolu)/2)))

And every time I do this I find it incredible lol, OK the simulation is not perfect you can notice that the deviation overflowed the desired band 150Khz, but it's there 88MHz with the modulations around it.

But now to get the 88MHz signal and go back to the original signal (demodulation process), we can simulate again:

ini_phase = 0;
len = size(s,1);
if(len==1)
    s = s(:);
end


t = (0:1/fsm:((size(s,1)-1)/fsm))';
t = t(:,ones(1,size(s,2)));

yq = hilbert(s).*exp(-sqrt(-1)*2*pi*portadora*t-ini_phase);
z = (1/(2*pi*desvio))*[zeros(1,size(yq,2)); diff(unwrap(angle(yq)))*fsm];

% --- restore the output signal to the original orientation --- %
if(len == 1)
    z = z';
end

plot(z)

If all goes well you can give s to the variable play and listen to your signal back ...

This made me imagine that it would be possible to build a device that listens to the radio spectrum range and scans all radios available to your region in real time and being demonstrated in the frequency spectrum lol ...

    
21.04.2016 / 19:57