DaweiShen∗
August21,2005
Abstract
AdictionaryoftheGNURadioblocks.Thisarticletakesatouraroundthemostfrequentlyusedblocks,explainingthesyntaxandhowtousethem.
1Introduction
WhenweuseMatlabtodosimulation,itisbelievedthatinordertowritethecodecleanlyandefficiently,weneedtomemorizeanumberofMatlabbuilt-infunctionsandtoolboxeswellandusethemskillfully.ThesameappliestoGNURadio.About100frequentlyusedblockscomewithGNURadio.Foracertainnumberofapplications,wecancompletethedesigningusingtheseexistingblocks,programmingonlyonthePythonlevel,withouttheneedtowriteourownblocks.Sointhisarticle,wewilltakeatouraroundtheGNURadioblocks.
AgoodwaytogothroughtheblocksistostudythetwoGNURadiodocumentationsgeneratedbyDoxygen.Theywillbegeneratedwhenyouinstallgnuradio-coreandusrppackages,assumingyouhaveDoxygeninstalled.Theyarelocatedat:
/usr/local/share/doc/gnuradio-core-x.xcvs/html/index.html/usr/local/share/doc/usrp-x.xcvs/html/index.html
Youmayliketobookmarktheminyourwebbrowser.Thefirstoneisalsoavailableon-line.AblockisactuallyaclassimplementedinC++.Forexample,intheFMreceiverexample,weusetheblockgr.quadrature_demod_cf.Thisblockcorrespondstotheclassgr_quadrature_demod_cfimplementedinC++.TheSWIGcreatesitsinterfacetoPython.TheSWIGdoessomemagicworksothatfromPython’spointofview,theblockbecomesaclasscalledquadrature_demod_cfdefinedinthemodulegr,sothatwecanaccesstotheblockusinggr.quadrature_demod_cfinPython.WhenyoulookattheDoxygendocumentations,theprefixsuchasgr,qa,usrpcorrespondstothemodulenameinPythonandthepartaftertheprefixistherealnameoftheblockinthatmodule,suchasquadrature_demod_cf,fir_filter_fff.Soifwetalkaboutablocknamed‘A_B_C_...’,wewilluseitas‘A.B_C_...’inPython.
authorisaffiliatedwithNetworkingCommunicationsandInformationProcessing(NCIP)Laboratory,
DepartmentofElectricalEngineering,UniversityofNotreDame.Welcometosendmeyourcommentsorinquiries.Email:dshen@nd.edu
∗The
1
2Tutorial9-DictionaryofGNURadioblocks
2
2.1
SignalSources
Sinusoidalandconstantsources
Block:gr.sig_source_X.Usage:
gr.sig_source_c[f,i,s]
(doublesampling_freq,gr_waveform_twaveform,doublefrequency,doubleamplitude,
gr_complex[float,integer,short]offset)
Notes:ThesuffixXindicatesthedatatypeofthesignalsource.Itcanbec(complex),f(float),i(4byteinteger)ors(2byteshortinteger).Theoffsetargumentisthesametypeasthesignal.Thewaveformargumentindicatesthetypeofthewaveform.gr_waveform_tisanenumerationtypedefinedingr_sig_source_waveform.h.Itsvaluecanbe:
gr.GR_CONST_WAVEgr.GR_COS_WAVEgr.GR_SIN_WAVE
Whenyouusegr.GR_CONST_WAVE,theoutputwillbeaconstantvoltage,whichistheamplitudeplustheoffset.
2.2Noisesources
Block:gr.noise_source_X.Usage:
gr.noise_source_c[f,i,s](gr_noise_type_ttype,
floatamplitude,longseed)
Notes:ThesuffixXindicatesthedatatypeofthesignalsource.Itcanbec(complex),f(float),i(4byteinteger)ors(2byteshortinteger).Thetypeargumentindicatesthetypeofthenoise.gr_noise_type_tisanenumerationtypedefinedingr_noise_type.h.Itsvaluecanbe:
GR_UNIFORMGR_GAUSSIANGR_LAPLACIANGR_IMPULSE
ChoosingGR_UNIFORMgeneratesuniformlydistributedsignalbetween[-amplitude,amplitude].GR_GAUSSIANgivesusnormallydistributeddeviatewithzeromeanandvarianceamplitude2.Sim-ilarly,GR_LAPLACIANandGR_IMPLUSErepresentaLaplaciandistributionandaimpulsedistributionrespectively.Allthesenoisesourceblocksarebasedonthepseudorandomnumbergeneratorblockgr.random.Youmaytakealookat/gnuradio-core/src/lib/general/gr_random.h(cc)toseehowtogeneratearandomnumberfollowingvariousdistributions.
D.Shen3
2.3Nullsources
Block:gr.null_source.Usage:
gr.null_source(size_t
sizeof_stream_item)
Notes:gr.null_sourceproducesconstantzeros.Theargumentsizeof_stream_itemspecifiesthedatatypeofthezerostream,suchasgr_complex,float,integerandsoon.
2.4Vectorsources
Block:gr.vector_source_X.Usage:
gr.vector_source_c[f,i,s,b](conststd::vector boolrepeat=false)(gr_complexcanbereplacedbyfloat,integer,short,unsignedchar) Notes:ThesuffixXindicatesthedatatypeofthesignalsource.Itcanbec(complex),f(float), i(4byteinteger),s(2byteshortinteger),orb(1byteunsignedchar).Thesesourcesgettheirdatafromavector.Theargumentrepeatdecideswhetherthedatainthevectorissentrepeatedly.Asanexample,wecanusetheblockinthiswayinPython: src_data=(-3,4,-5.5,2,3) src=gr.vector_source_f(src_data) 2.5Filesources Block:gr.file_sourceUsage: gr.file_source(size_t constchar*bool itemsize,filename,repeat) Notes:gr.file_sourcereadsthedatastreamfromafile.Thenameofthefileisspecifiedbyfilename.Thefirstargumentitemsizedeterminesthedatatypeofthestream,suchasgr_complex,float,unsignedchar.Theargumentrepeatdecideswhetherthedatainthefileissentrepeatedly.Asanexample,wecanusetheblockinthiswayinPython: src=gr.file_source(gr.sizeof_char,\"/home/dshen/payload.dat\TRUE) 2.6Audiosource Block:gr.audio_sourceUsage: 4 gr.audio_source(intsampling_rate) Tutorial9-DictionaryofGNURadioblocks Notes:audio_sourcereadsdatafromtheaudioline-in.Theargumentsampling_ratespecifiesthedatarateofthesource,insamplespersecond. 2.7USRPsource Block:usrp.source_c[s]Usage: usrp.source_c(s)(int unsignedintintintint which_board,decim_rate,nchan=1,mux=-1,mode=0) Notes:whenyoudesignareceiverusingGNURadio,i.e.workingontheRXpath,probablyyouneedtheUSRPasthedatasource.Thesuffixc(complex),ors(short)specifiesthedatatypeofthestreamfromUSRP.Mostlikelythecomplexsource(I/Qquadraturefromthedigitaldownconverter(DDC))wouldbemorefrequentlyused.Someoftheargumentshavebeenintroducedintutorial4.which_boardspecifieswhichUSRPtoopen,whichisprobably0ifthereisonlyoneUSRPboard.decim_ratetellsthedigitaldownconverter(DDC)thedecimationfactorD.nchanspecifiesthenumberofchannels,1,2or4.muxsetsinputMUXconfiguration,whichdetermineswhichADC(orconstantzero)isconnectedtoeachDDCinput(seetutorial4fordetails).‘-1’meanswepreservethedefaultsettings.modesetstheFPGAmode,whichweseldomtouch.Thedefaultvalueis0,representingthenormalmode.Quiteoftenweonlyspecifythefirsttwoarguments,usingthedefaultvaluesfortheothers.Forexample:usrp_decim=250 src=usrp.source_c(0,usrp_decim) 3 3.1 SignalSinks Nullsinks Block:gr.null_sink.Usage: gr.null_sink(size_t sizeof_stream_item) Notes:gr.null_sinkdoesnothingbuteatupyourstream.Theargumentsizeof_stream_itemspecifiesthedatatypeofthezerostream,suchasgr_complex,float,integerandsoon. 3.2Vectorsinks Block:gr.vector_sink_X.Usage: D.Shen5 gr.vector_sink_c[f,i,s,b]() Notes:ThesuffixXindicatesthedatatypeofthesignalsink.Itcanbec(complex),f(float),i(4byteinteger),s(2byteshortinteger),orb(1byteunsignedchar).Thesesinkswritethedataintoavector.Asanexample,wecanusetheblockinthiswayinPython:dst=gr.vector_sink_f() 3.3Filesinks Block:gr.file_sinkUsage: gr.file_sink(size_t constchar* itemsize,filename) Notes:gr.file_sourcewritesthedatastreamtoafile.Thenameofthefileisspecifiedbyfilename.Thefirstargumentitemsizedeterminesthedatatypeoftheinputstream,suchasgr_complex,float,unsignedchar.Asanexample,wecanusetheblockinthiswayinPython:src=gr.file_source(gr.sizeof_char,\"/home/dshen/rx.dat\") 3.4Audiosink Block:gr.audio_sinkUsage: gr.audio_source(intsampling_rate) Notes:Whenyoufinishthesignalprocessingandwishtoplaythesignalthroughthespeaker,youshouldusetheaudiosink.audio_sinkwilloutputthedatatothesoundcardatthesamplingrateofsampling_rate. 3.5USRPsink Block:usrp.sink_c[s]Usage: usrp.sink_c(s)(int unsignedintintint which_board,interp_rate,nchan=1,mux=-1) Notes:whenyoudesignatransmitterusingGNURadio,i.e.workingontheTXpath,probablyyouneedtheUSRPasthedatasink.Thesuffixc(complex),ors(short)specifiesthedatatypeofthestreamgoingintoUSRP.Mostlikelythecomplexsinkwouldbemorefrequentlyused.Someof 6Tutorial9-DictionaryofGNURadioblocks theargumentshavebeenintroducedintutorial4.which_boardspecifieswhichUSRPtoopen,whichisprobably0ifthereisonlyoneUSRPboard.interp_ratetellstheinterpolatorontheFPGAtheinterpolationfactorI.NotethattheinterpolationrateImustbeintherange[4,512],andmustbeamultipleof4.nchanspecifiesthenumberofchannels,1or2.muxsetsoutputMUXconfiguration,whichdetermineswhichDACisconnectedtoeachinterpolatoroutput(ordisabled).‘-1’meanswepreservethedefaultsettings.Quiteoftenweonlyspecifythefirsttwoarguments,usingthedefaultvaluesfortheothers.Forexample:usrp_interp=256 src=usrp.sink_c(0,usrp_interp) 4 4.1 SimpleOperators Addingaconstant Block:gr.add_const_XXUsage: gr.add_const_cc[ff,ii,ss,sf](gr_complex[float,integer,short]k) Notes:ThesuffixXXcontainstwocharacters.Thefirstoneindicatesthedatatypeoftheinputstreamwhilethesecondonetellsthetypeoftheoutputstream.Itcanbecc(complextocomplex),ff(floattofloat),ii(4byteintegertointeger),ss(2byteshortintegertoshortinteger)orsf(shortintegertofloat).Thegr.add_const_XXblockaddsaconstanttotheinputstreamsothatthesignalhasadifferentoffset.Notethatforgr.add_const_sf,theargumentkisfloat.Weaddafloatconstanttoashortintegerstream,andtheoutputstreambecomesfloat. 4.2Adder Block:gr.add_XXUsage: gr.add_cc[ff,ii,ss]() Notes:ThesuffixXXindicatesthedatatypeoftheinputandoutputstreams.gr.add_XXaddsallinputstreamstogether.Thetypeofeachincomingstreamandmustbethesame.WhenweuseitinPython,multipleupstreamblockcouldbeconnectedtoit.Forexample:adder=gr.add_cc() fg.connect(stream1,(adder,0))fg.connect(stream2,(adder,1))fg.connect(stream3,(adder,2))fg.connect(adder,outputstream) Thentheoutputoftheadderisstream1+stream2+stream3. 4.3Subtractor Block:gr.sub_XX D.Shen7 Usage: gr.sub_cc[ff,ii,ss]() Notes:ThesuffixXXindicatesthedatatypeoftheinputandoutputstreams.gr.sub_XXsubtractsacrossallinputstreams.output=input_0-input_1-input_2....Thetypeofeachincomingstreamandmustbethesame.WhenweuseitinPython,multipleupstreamblockcouldbeconnectedtoit.Forexample:subtractorfg.connectfg.connectfg.connectfg.connect =gr.sub_cc() (stream1,(subtractor,0))(stream2,(subtractor,1))(stream3,(subtractor,2))(subtractor,outputstream) Thentheoutputofthesubtractorisstream1-stream2-stream3. 4.4Multiplyingaconstant Block:gr.multiply_const_XXUsage: gr.add_const_cc[ff,ii,ss](gr_complex[float,integer,short]k) Notes:ThesuffixXXindicatesthedatatypeoftheinputandoutputstreams.Thegr.multiply_const_XXblockmultipliestheinputstreambyaconstantk. 4.5Multiplier Block:gr.multiply_XXUsage: gr.multiply_cc[ff,ii,ss]() Notes:ThesuffixXXindicatesthedatatypeoftheinputandoutputstreams.gr.multiply_XXcomputestheproductofallinputstreams.Thetypeofeachincomingstreamandmustbethesame.WhenweuseitinPython,multipleupstreamblockcouldbeconnectedtoit.Forexample:multiplierfg.connectfg.connectfg.connectfg.connect =gr.multiply_cc() (stream1,(multiplier,0))(stream2,(multiplier,1))(stream3,(multiplier,2))(multiplier,outputstream) Thentheoutputofthemultiplierisstream1×stream2×stream3. 4.6Divider Block:gr.divide_XXUsage: 8 gr.divide_cc[ff,ii,ss]() Tutorial9-DictionaryofGNURadioblocks Notes:ThesuffixXXindicatesthedatatypeoftheinputandoutputstreams.gr.divide_XXdividesacrossallinputstreams.output=input_0/input_1/input_2....Thetypeofeachincomingstreamandmustbethesame.WhenweuseitinPython,multipleupstreamblockcouldbeconnectedtoit.Forexample:divider=gr.divide_cc() fg.connect(stream1,(divider,0))fg.connect(stream2,(divider,1))fg.connect(stream3,(divider,2))fg.connect(divider,outputstream) Thentheoutputofthesubtractorisstream1÷stream2÷stream3. 4.7Logfunction Block:gr.nlog10_ffUsage: gr.nlog10_ff(floatn, unsignedvlen) Notes:gr.nlog10_ffcomputesn×log10(input).Inputandoutputarebothfloatnumbers.Ignoretheargumentvlen,thevectorlength,usingitsdefaultvalue1. 5 5.1 TypeConversions ComplexConversions Block: gr.complex_to_floatgr.complex_to_realgr.complex_to_imaggr.complex_to_maggr.complex_to_argUsage: gr.complex_to_float(unsignedintvlen)gr.complex_to_real(unsignedintvlen)gr.complex_to_imag(unsignedintvlen)gr.complex_to_mag(unsignedintvlen)gr.complex_to_arg(unsignedintvlen) Notes:Theargumentvlenisthevectorlength,wealmostalwaysusethedefaultvalue1.Sojustignoretheargument.Theseblocksconvertacomplexsignaltoseparatereal&imaginaryfloatstreams,justtherealpart,justtheimaginarypart,themagnitudeofthecomplexsignalandthephaseangleofthecomplexsignal.Notethattheblockgr.complex_to_floatcouldhave1or2outputs.Ifitisconnectedtoonlyoneoutput,thentheoutputistherealpartofthecomplexsignal.Itseffectisequivalenttogr.complex_to_real. D.Shen9 5.2 Block: FloatConversions gr.float_to_complexgr.float_to_shortgr.short_to_floatUsage: gr.float_to_complex()gr.float_to_short()gr.short_to_float() Notes:Theseblocksarelike‘adapters’,usedtoprovidetheinterfacebetweentwoblockswithdifferenttypes.Notethattheblockgr.float_to_complexmayhave1or2inputs.Ifthereisonlyone,thentheinputsignalistherealpartoftheoutputsignal,whiletheimaginarypartisconstant0.Iftherearetwoinputs,theyserveastherealandimaginarypartsoftheoutputsignalrespectively. 6 6.1 Filters FIRDesigner Block:gr.firdes Notes:gr.firdeshasseveralstaticpublicmemberfunctionsusedtodesigndifferenttypesofFIRfilters.ThesefunctionsreturnavectorcontainingtheFIRcoefficients.ThereturnedvectorisoftenusedasanargumentofotherFIRfilterblocks. 6.1.1Usage: LowPassFilter vector doubledoubledoublewin_typedoublegain, sampling_freq,cutoff_freq, transition_width, window=WIN_HAMMING,beta=6.76)[static] Notes:low_passisastaticpublicmemberfunctionintheclassgr.firdes.ItdesignstheFIR filtercoefficients(taps)giventhefilterspecifications.HeretheargumentwindowisthetypeofthewindowusedintheFIRfilterdesign.Validvaluesinclude WIN_HAMMINGWIN_HANN WIN_BLACKMANWIN_RECTANGULAR 106.1.2Usage: vector doubledoubledoublewin_typedouble HighPassFilter Tutorial9-DictionaryofGNURadioblocks gain, sampling_freq,cutoff_freq, transition_width, window=WIN_HAMMING,beta=6.76)[static] 6.1.3Usage: BandPassFilter vector doubledoubledoubledoublewin_typedoublegain, sampling_freq,low_cutoff_freq,high_cutoff_freq,transition_width, window=WIN_HAMMING,beta=6.76)[static] 6.1.4Usage: BandRejectFilter vector doubledoubledoubledoublewin_typedoublegain, sampling_freq,low_cutoff_freq,high_cutoff_freq,transition_width, window=WIN_HAMMING,beta=6.76)[static] 6.1.5Usage: HilbertFilter vector win_typewindowtype=WIN_RECTANGULAR,doublebeta=6.76)[static]Notes:gr.firdes::hilbertdesignsaHilberttransformfilter.ntapsisthenumberoftaps,which mustbeodd.6.1.6Usage: RaisedCosineFilter D.Shen11 gain, sampling_freq,symbol_rate,alpha,ntaps)[static] vector doubledoubledoubleint Notes:gr.firdes::root_raised_cosinedesignsarootcosineFIRfilter.Theargumentalphaistheexcessbandwidthfactor.ntapsisthenumberoftaps. 6.1.7Usage: GaussianFilter vector doubledoubledoubleintgain, sampling_freq,symbol_rate,bt, ntaps)[static] Notes:gr.firdes::gaussiandesignsaGaussianfilter.Theargumentntapsisthenumberof taps. 6.2 Block: FIRDecimationFilters gr.fir_filter_cccgr.fir_filter_ccfgr.fir_filter_fccgr.fir_filter_fffgr.fir_filter_fsfgr.fir_filter_sccUsage: gr.fir_filter_ccc(intdecimation, conststd::vector< gr.fir_filter_ccf(intdecimation, conststd::vector< gr.fir_filter_fcc(intdecimation, conststd::vector< gr.fir_filter_fff(intdecimation, conststd::vector< gr.fir_filter_fsf(intdecimation, conststd::vector< gr.fir_filter_scc(intdecimation, conststd::vector< gr_complex>&taps)float>&taps)gr_complex>&taps)float>&taps)float>&taps)gr_complex>&taps) Notes:Theseblocksallhavea3-charactersuffix.Thefirstoneindicatesthedatatypeoftheinputstream,thesecondonetellsthetypeoftheoutputstream,andthelastonerepresentsforthedatatypeoftheFIRfiltertaps. 12Tutorial9-DictionaryofGNURadioblocks Eachblockhastwoarguments.ThefirstoneisthedecimationrateoftheFIRfilter.Ifitis1,thenit’sjustanormal1:1FIRfilter.ThesecondargumenttapsisthevectoroftheFIRcoefficients,whichwegetfromtheFIRfilterdesignerblockgr.firdes. 6.3 Block: FIRInterpolationFilters gr.interp_fir_filter_cccgr.interp_fir_filter_ccfgr.interp_fir_filter_fccgr.interp_fir_filter_fffgr.interp_fir_filter_fsfgr.interp_fir_filter_sccUsage: gr.interp_fir_filter_ccc(unsignedinterpolation, conststd::vector gr.interp_fir_filter_ccf(unsignedinterpolation, conststd::vector gr.interp_fir_filter_fcc(unsignedinterpolation, conststd::vector gr.interp_fir_filter_fff(unsignedinterpolation, conststd::vector gr.interp_fir_filter_fsf(unsignedinterpolation, conststd::vector gr.interp_fir_filter_scc(unsignedinterpolation, conststd::vector taps))taps)))taps) Notes:Theseblocksallhavea3-charactersuffix.Thefirstoneindicatesthedatatypeoftheinputstream,thesecondonetellsthetypeoftheoutputstream,andthelastonerepresentsforthedatatypeoftheFIRfiltertaps. Eachblockhastwoarguments.ThefirstoneistheinterpolationrateoftheFIRfilter.ThesecondargumenttapsisthevectoroftheFIRcoefficients,whichwegetfromtheFIRfilterdesignerblockgr.firdes. 6.4 Block: DigitalDownConverterwithFIRDecimationFilters gr.freq_xlating_fir_filter_cccgr.freq_xlating_fir_filter_ccfgr.freq_xlating_fir_filter_fccgr.freq_xlating_fir_filter_fcfgr.freq_xlating_fir_filter_sccgr.freq_xlating_fir_filter_scfUsage: gr.freq_xlating_fir_filter_ccc[ccf,fcc,fcf,scc,scf] D.Shen13 (intdecimation, conststd::vector taps, Notes:Theseblocksallhavea3-charactersuffix.Thefirstoneindicatesthedatatypeoftheinput stream,thesecondonetellsthetypeoftheoutputstream,andthelastonerepresentsforthedatatypeoftheFIRfiltertaps. TheseblocksareusedasFIRfilterscombinedwithfrequencytranslation.Recallthatintutorial4,intheFPGAtherearedigitaldownconverters(DDC)translatingthesignalfromIFtobaseband.Thenthefollowingdecimatordownsamplesthesignalandselectsanarrowerbandofthesignalbylow-passfilteringit.Theseblocksdothesamethingsexceptinsoftware.Theseclassesefficientlycombineafrequencytranslation(typicallydownconversion)withanFIRfilter(typicallylow-pass)anddecimation.Itisideallysuitedfora‘channelselectionfilter’andcanbeefficientlyusedtoselectanddecimateanarrowbandsignaloutofwidebandwidthinput. 6.5HilbertTransformFilter Block:gr.hilbert_fcUsage: gr.hilbert_fc(unsignedintntaps) Notes:gr.hilbert_fcisaHilberttransformer.Therealoutputisinputappropriatelydelayed.ImaginaryoutputisHilbertfiltered(90degreephaseshift)versionofinput.Weonlyneedtospecifythenumberoftapsntapswhenusingtheblock.TheHilbertfilterdesignergr.firdes::hilbertisusedimplicitlyintheimplementationoftheblockgr.hilbert_fc. 6.6Filter-DelayCombinationFilter Block:gr.filter_delay_fcUsage: gr.filter_delay_fc(conststd::vector taps) Notes:Thisisafilter-delaycombinationblock.Theblocktakesoneortwofloatstreamandoutputsacomplexstream.Ifonlyonefloatstreamisinput,therealoutputisadelayedversionofthisinputandtheimaginaryoutputisthefilteredoutput.Iftwofloatsareconnectedtotheinput,thentherealoutputisthedelayedversionofthefirstinput,andtheimaginaryoutputisthefilteredoutput.Thedelayintherealpathaccountsforthegroupdelayintroducedbythefilterintheimaginarypath.Thefiltertapsneedstobecalculatedusinggr.firdesbeforeinitializingthisblock. 6.7IIRFilter Block:gr.iir_filter_ffdUsage: gr.iir_filter_ffd(conststd::vector conststd::vector fftaps,fbtaps) 14Tutorial9-DictionaryofGNURadioblocks Notes:Thesuffixffdmeansfloatinput,floatoutputanddoubletaps.ThisIIRfilterusestheDirectFormIimplementation,wherefftapscontainsthefeed-forwardtaps,andfbtapsthefeedbackones.fftapsandfbtapsmusthaveequalnumbersoftaps.Theinputandoutputsatisfyadifferenceequationoftheform MN bkx[n−k]y[n]−aky[n−k]= k=1 k=0 withthecorrespondingrationalsystemfunction M H(z)= 1− −k k=0bkzN−k k=1akz Notethatsometextsdefinethesystemfunctionwitha‘+’inthedenominator.Ifyou’reusingthatconvention,you’llneedtonegatethefeedbacktaps. 6.8SinglePoleIIRFilter Block:gr.single_pole_iir_filter_ffUsage: gr.single_pole_iir_filter_ff(doublealpha, unsignedint vlen) Notes:ThisisasinglepoleIIRfilterwithfloatinput,floatoutput.Theinputandoutputsatisfyadifferenceequationoftheform: y[n]−(1−α)y[n−1]=αx[n] withthecorrespondingrationalsystemfunction H(z)= α 1−(1−α)z−1 Notethatsometextsdefinethesystemfunctionwitha+inthedenominator.Ifyou’reusingthatconvention,you’llneedtonegatethefeedbacktap.Theargumentvlenisthevectorlength.Weusuallyuseitsdefaultvalue1,sojustignoreit. 7FFT Block: gr.fft_vccgr.fft_vfcUsage: gr.fft_vcc(int boolbool gr.fft_vfc(int boolbool fft_size,forward,window)fft_size,forward,window) Notes:TheseblocksareusedtocomputethefastFouriertransformsoftheinputsequence.Forgr.fft_vcc,itcomputesforwardorreverseFFT,withcomplexvectorinandcomplexvectorout.Forgr.fft_vfcitcomputesforwardFFTwithfloatvectorinandcomplexvectorout. D.Shen15 8 8.1 Otherusefulblocks FMModulationandDemodulation Block: gr.frequency_modulator_fcgr.quadrature_demod_cfUsage: gr.frequency_modulator_fc(doublesensitivity)gr.quadrature_demod_cf(floatgain) Notes:Thegr.frequency_modulator_fcblockistheFMmodulator.Theinstantaneousfre-quencyoftheoutputcomplexsignalisproportionaltotheinputfloatsignal.Wehaveseengr.quadrature_demod_cfintheFMreceiverexample.Itcalculatestheinstantaneousfrequencyoftheinputsignal. 8.2NumericallyControlledOscillator Block:gr.fxpt_nco Usage:Thisblockisusedtogeneratesinusoidalwaves.Wecansetoradjustthephaseandfrequencyoftheoscillatorbyseveralpublicmemberfunctionsoftheclass.Thefunctionsinclude: voidvoidvoidvoidvoidvoidfloatfloatvoidfloatfloat set_phase(floatangle) adjust_phase(floatdelta_phase)set_freq(floatangle_rate) adjust_freq(floatdelta_angle_rate)step() step(intn) get_phase()constget_freq()const sincos(float*sinx,float*cosx)constcos()constsin()const Weusecos()orsin()functiontogetthesinusoidalsamples.Theycalculatesinandcosvaluesaccordingtothecurrentphase.Thefreqisactuallythephasedifferencebetweenconsecutivesamples.Whenwecallstep()method,thecurrentphasewillincreasebythefreq. 8.3 Block: Blocksfordigitaltransmission gr.bytes_to_symsgr.simple_framer gr.simple_correlatorUsage: 16 gr.bytes_to_syms() gr.simple_framer(intpayload_bytesize) gr.simple_correlator(intpayload_bytesize) Tutorial9-DictionaryofGNURadioblocks Notes:gr.bytes_to_syms()convertsabytesequence(forexample,aunsignedcharstream)toa±sequence,i.e.thedigitalbinarysymbols.gr.simple_framerpacksabytestreamintopackets,withthelengthofpayload_bytesize.Thennecessarysynchronizationandcommandbytesareaddedatthehead.gr.simple_correlatorisadigitaldetector,whichsynchronizesthesymbolandframe,finallydetectsthedigitalinformationcorrectly.Therealimplementationoftheseblocksisalittlebitcomplicated.PleasestudytheFSKexamplefsk_r[t]x.pyandthesourcecodeoftheseblocks.Theseblocksareveryhelpfulwhenwewanttodesigndigitaltransmissionschemes. 9Wrapup ThistutorialreviewssomeofthemostfrequentlyusedblocksinGNURadio.Usingtheseblocksskillfullywouldbeveryimportantanduseful.Certainlyweonlydiscussafractionoftheavailableblocks.Therearesomeothermoreadvanced,lessusedblocksthatwedidn’ttalkabout.AlsomoreandmoreblocksarecomingasGNURadiogetsmorepopular(maybeincludingyourblockoneday).Ourintroductionisverysimple.Ifyouwishtoknowallthedetailsaboutablock,pleasegotoitsdocumentationpageandthenreaditssourcecodedirectly.Thesourcecodeisthebestplacetounderstandwhat’sgoingoninablockthoroughly.Studyingsomeoftheexamplestoseehowablockausedisalsoaverygoodway. References [1]GNURadio2.xDocumentationhttp://www.gnu.org/software/gnuradio/doc/index.html 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- oldu.cn 版权所有 浙ICP备2024123271号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务