#!/usr/bin/env python # coding: utf-8 # Frekvenční modulace # ====================== # # Modulační a nosný signál # --------------------------- # In[1]: import matplotlib.patches as mpp # Konstanty fs=96000 Ts=1./fs length=1 # modulační vlna fm=100. Tm=1./fm # nosná vlna B=15 fc=3000. Tc=1./fc Uc=3 # časová osa t = arange(0,length,1./fs) # modulační signál um = 1*sin(2*pi*fm*t) # převod do frekvenční oblasti from scipy.fftpack import fft, ifft Ck= fft(um) absCk = 2./len(um) * numpy.abs(Ck)[:len(Ck)/2] f = arange(0,fs/2,float(fs)/len(Ck)) # Modulační signá fig=figure(figsize=(10,6)) subplot(211) plot(t,um) title(u'Modulační signál') grid('on') xlabel(r't\,[s] $\rightarrow$', x=0.9) ylabel('$\mathrm u_m$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([-1.1*max(um), 1.1*max(um)]) xlim([0,1.5*Tm]) subplot(212) title(ur'Modulační signál -- amplitudové spektrum') plot(f,absCk,'.-') xlabel(r'f\,[Hz] $\rightarrow$', x=0.9) ylabel('$\mathrm U_m$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([0,1.1*Uc]); xlim([0,6e3]) grid(1) text(100,-0.34 , '$\mathbf{f_m}$', size=16) #figtext(0,1 , '$\mathrm f_m$', size=16) tight_layout() # In[2]: # Nosná vlna před modulací uc = Uc*cos(2*pi*fc*t) Ck= fft(uc) absCk = 2./len(uc) * abs(Ck)[:len(Ck)/2] f = arange(0,fs/2,float(fs)/len(Ck)) figure(figsize=(10,6)) subplot(211) plot(t,uc,'-') title(u'Nosný signál') grid('on') xlabel(r't\,[s] $\rightarrow$', x=0.9) ylabel('$\mathrm u_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([-1.1*max(uc), 1.1*max(uc)]) xlim([0,1.5*Tm]) subplot(212) title(u'Nosný signál -- amplitudové spektrum') plot(f,absCk,'.-') xlabel(r'f\,[Hz] $\rightarrow$', x=0.9) ylabel('$\mathrm U_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([0,1.1*Uc]); xlim([0,6e3]) text(3000,-0.6 , '$\mathbf{f_c}$', size=16) grid(1) tight_layout() # In[3]: # Nosná vlna po modulací B=15 uc = Uc*cos(2*pi*fc*t+B*um) Ck= fft(uc) absCk = 2./len(uc) * abs(Ck)[:len(Ck)/2] f = arange(0,fs/2,float(fs)/len(Ck)) figure(figsize=(10,8)) subplot(311) plot(t,um) title(u'Modulační signál') grid('on') xlabel(r't\,[s] $\rightarrow$', x=0.9) ylabel('$\mathrm u_m$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([-1.1*max(um), 1.1*max(um)]) xlim([0,1.5*Tm]) subplot(312) plot(t,uc) title(ur'Modulovaný signál $\beta={}, \Delta f={}\,\mathrm{{kHz}}$'.format(B,B*fm/100.)) grid('on') xlabel(r't\,[s] $\rightarrow$', x=0.9) ylabel('$\mathrm u_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([-1.1*max(uc), 1.1*max(uc)]) xlim([0,1*Tm]) subplot(313) title(ur'Modulovaný signál $\beta={}, \Delta f={}\,\mathrm{{kHz}}$ -- amplitudové spektrum'.format(B,B*fm/1000.)) plot(f,absCk,'.-') xlabel(r'f\,[Hz] $\rightarrow$', x=0.9) ylabel('$\mathrm U_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([0,1.5*max(absCk)]); xlim([0,6e3]) text(3000,-0.3 , '$\mathbf{f_c}$', size=16) grid(1) annotate('$\mathbf{f_c+f_m}$', xy=(3100,0),size=16, xytext=(3100,-0.6), arrowprops=dict(arrowstyle="->",connectionstyle="arc3,rad=0", ),) annotate('$\mathbf{f_c+2f_m}$', xy=(3200,0),size=16, xytext=(3500,-0.4), arrowprops=dict(arrowstyle="->",connectionstyle="arc3,rad=0", ),) tight_layout() # In[4]: # Nosná vlna po modulací B=8 uc = Uc*cos(2*pi*fc*t+B*um) Ck= fft(uc) absCk = 2./len(uc) * abs(Ck)[:len(Ck)/2] f = arange(0,fs/2,float(fs)/len(Ck)) figure(figsize=(10,8)) subplot(311) plot(t,um) title(u'Modulační signál') grid('on') xlabel(r't\,[s] $\rightarrow$', x=0.9) ylabel('$\mathrm u_m$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([-1.1*max(um), 1.1*max(um)]) xlim([0,1.5*Tm]) subplot(312) plot(t,uc) title(ur'Modulovaný signál $\beta={}, \Delta f={}\,\mathrm{{kHz}}$'.format(B,B*fm/100.)) grid('on') xlabel(r't\,[s] $\rightarrow$', x=0.9) ylabel('$\mathrm u_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([-1.1*max(uc), 1.1*max(uc)]) xlim([0,1*Tm]) subplot(313) title(ur'Modulovaný signál $\beta={}, \Delta f={}\,\mathrm{{kHz}}$ -- amplitudové spektrum'.format(B,B*fm/1000.)) plot(f,absCk,'.-') xlabel(r'f\,[Hz] $\rightarrow$', x=0.9) ylabel('$\mathrm U_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([0,1.5*max(absCk)]); xlim([0,6e3]) text(3000,-0.4 , '$\mathbf{f_c}$', size=16) grid(1) tight_layout() # In[5]: figure(figsize=(10,4)) ax=subplot(111) title(ur'Modulovaný signál $\beta={}, \Delta f={}\,\mathrm{{kHz}}$ -- amplitudové spektrum'.format(B,B*fm/1000.)) plot(f,absCk,'.-') xlabel(r'f\,[Hz] $\rightarrow$', x=0.9) ylabel('$\mathrm U_c$\,[V] $\uparrow$', y=0.9, rotation=0) ylim([0,1.5*max(absCk)]); xlim([0,6e3]) text(3000,-0.25 , '$\mathbf{f_c}$', size=16) grid(1) ax.add_patch( mpp.FancyArrowPatch((2100,1.2), (3900,1.2), arrowstyle='<->', lw=2, linestyle='solid', mutation_scale=25, color='green', alpha=0.9, shrinkA=0, shrinkB=0 ), ) axvspan(2100, 3900, facecolor='g', alpha=0.2, ymax=0.78) text(2500,1.22, r'$2(\Delta f+f_{max})$',size=16) bbox_props = dict(boxstyle="round,pad=0.3", fc=".9", ec="b", lw=2) t=annotate(u'Carsonův odhad', xy=(2400,1.3),size=16, xytext=(400,1.2),bbox=bbox_props, arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=-0.2", fc="w") )