2023年電子競(jìng)賽簡(jiǎn)易頻率測(cè)試儀_第1頁(yè)
2023年電子競(jìng)賽簡(jiǎn)易頻率測(cè)試儀_第2頁(yè)
2023年電子競(jìng)賽簡(jiǎn)易頻率測(cè)試儀_第3頁(yè)
2023年電子競(jìng)賽簡(jiǎn)易頻率測(cè)試儀_第4頁(yè)
2023年電子競(jìng)賽簡(jiǎn)易頻率測(cè)試儀_第5頁(yè)
已閱讀5頁(yè),還剩25頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

簡(jiǎn)易頻率特性測(cè)試儀(E題)摘要:該簡(jiǎn)易頻率特性測(cè)試儀采用STM32F103ZET6核心板,重要由自制正交掃描信號(hào)源、RLC被測(cè)網(wǎng)絡(luò)、乘法器、低通濾波等功能模塊組成;測(cè)試數(shù)據(jù)包含信號(hào)的幅頻特性及相頻特性,于彩屏TFT上顯示。本系統(tǒng)運(yùn)用高速DDS(AD9854)模塊實(shí)現(xiàn)信號(hào)發(fā)生電路,能輸出雙端口的正交信號(hào),并可控制設(shè)立其幅值與頻率。被測(cè)網(wǎng)絡(luò)采用RLC串聯(lián)諧振電路,達(dá)成規(guī)定的網(wǎng)絡(luò)通帶中心頻率。將DDS產(chǎn)生的正交信號(hào)和被測(cè)網(wǎng)絡(luò)信號(hào)通過(guò)乘法器AD835模塊,經(jīng)LTC1564低通濾波,運(yùn)用單片機(jī)上的片上AD進(jìn)行采樣,最終在彩屏上顯示輸出,完畢對(duì)信號(hào)的幅頻和相頻的簡(jiǎn)樸測(cè)試。關(guān)鍵詞:STM32;DDS;乘法器;濾波;TFTAbstract:Thesimplefrequencytesterisbasedonhigh-performanceSTM32F103ZET6controller,anditmainlyconsistsofself-maidsignalgenerator,RLCnetwork,multipliers,low-passfilterandotherfunctionblocks.Thetestdatacontainsamplitude-frequencycharacteristicsandphase-frequencycharacteristics,andwillbedisplayedonTFT.Thesystemuseshigh-speedDDS(AD9854)blockassignalcircuit,generatingthedual-portquadrat(yī)uresignals,whoseamplitudeandfrequencycanbecontrolledandset.ThetestnetworkismadeofRLCcircuit,whichisabletoachievethestandardizedcenterfrequency.ThequadraturesignalsgeneratedbyDDSandthesignalsundertestpassthroughthemultiplierAD835andtheLTC1564low-passfilter,andwillbesampledbythe12-biton-chipADC.ThefinaloutputisdisplayedontheTFTtocompletethetestofamplitude-frequencyandphase-frequency.Keyword:STM32;DDS;multiplier;filter;TFT一、方案選擇與論證·······································31.1正交掃頻信號(hào)源的設(shè)計(jì)與選擇·································31.2乘法器模塊的設(shè)計(jì)與選擇·····································31.3低通濾波器的設(shè)計(jì)與選擇·····································31.4ADC模塊的設(shè)計(jì)與選擇·······································31.5被測(cè)網(wǎng)絡(luò)的設(shè)計(jì)與選擇·······································4二、電路設(shè)計(jì)·············································42.1正交掃描信號(hào)源設(shè)計(jì)電路·····································42.2模擬乘法器設(shè)計(jì)電路·········································42.3低通濾波器設(shè)計(jì)電路·········································42.4末級(jí)電壓抬升設(shè)計(jì)電路·······································5三、系統(tǒng)設(shè)計(jì)·············································53.1方案總體設(shè)計(jì)描述···········································53.2理論分析與計(jì)算·············································63.2.1正交掃描信號(hào)發(fā)生器的設(shè)計(jì)·······························63.2.2低通濾波器的設(shè)計(jì)·······································63.2.3RLC被測(cè)網(wǎng)絡(luò)的設(shè)計(jì)·····································63.2.4特性曲線顯示···········································7四、軟件設(shè)計(jì)·············································7五、系統(tǒng)測(cè)試·············································85.1測(cè)試方法··················································85.2測(cè)試工具··················································85.3各模塊測(cè)試過(guò)程············································85.3.1掃頻信號(hào)發(fā)生器的測(cè)試··································85.3.2乘法器模塊的測(cè)試······································95.3.3輸入輸出阻抗的測(cè)試····································95.3.4RLC被測(cè)網(wǎng)絡(luò)的測(cè)試····································9六、結(jié)論················································10參考文獻(xiàn)·················································10附錄·····················································10附錄一:元件清單··················································10附錄二:AD9854掃描信號(hào)發(fā)生器設(shè)計(jì)電路······························11附錄三:系統(tǒng)總體設(shè)計(jì)電路···········································11附錄四:重要程序清單···············································12方案選擇與論證1.1正交掃頻信號(hào)源的設(shè)計(jì)與選擇方案一:采用程控鎖相環(huán)頻率合成方案。方案說(shuō)明:鎖相環(huán)頻率合成是將高穩(wěn)定度和高精度的標(biāo)準(zhǔn)頻率通過(guò)算術(shù)運(yùn)算產(chǎn)生同樣穩(wěn)定度和精確度的大量離散頻率,在一定限度上解決了既要頻率穩(wěn)定精確,又要頻率在較大范圍內(nèi)可變的問(wèn)題。但該方案采用多次積分電路,這種具有惰性特性的電路誤差大,不能滿足幅頻曲線和相頻曲線的輸出規(guī)定。方案二:采用AD9854芯片搭建DDS模塊電路,通過(guò)控制AD9854寄存器可產(chǎn)生編程控制的、高精度的頻率信號(hào)。方案說(shuō)明:AD9854是AD公司生產(chǎn)的DDS專用芯片,其擁有300MHz的內(nèi)部時(shí)鐘頻率,可以進(jìn)行FSK、BPSK、PSK、chirp、AM等的操作。AD9854數(shù)字合成器是一個(gè)運(yùn)用DDS技術(shù)、兩個(gè)內(nèi)部高速高性能正交DACs控制數(shù)字可編程輸入輸出的綜合器件。當(dāng)給AD9854加上一個(gè)擬定期鐘時(shí),它可以生成高度穩(wěn)定、頻率-相位-幅度可編程的正弦信號(hào),頻率分辨率很高、抗干擾能力強(qiáng)、靈敏度高、實(shí)用性強(qiáng)。綜上論證比較,我們選用方案二作為正交掃頻信號(hào)源的實(shí)現(xiàn)方式。1.2乘法器模塊的設(shè)計(jì)與選擇方案一:采用晶體管等分立元件搭建差分對(duì)模擬乘法器電路,通過(guò)兩個(gè)晶體管輸出的電壓乘積項(xiàng)達(dá)成頻率變換作用。方案說(shuō)明:電路結(jié)構(gòu)冗繁復(fù)雜,穩(wěn)定性差,不易調(diào)節(jié)。方案二:直接采用模擬乘法器AD835芯片。方案說(shuō)明:AD835是一款電壓輸出型四象限模擬乘法器,帶寬高達(dá)250MHz,很適合寬帶調(diào)制和解調(diào)應(yīng)用。且AD835需要的外圍電路非常少,配置方便。綜上論證比較,我們選用方案二作為模擬乘法器的實(shí)現(xiàn)方法。1.3低通濾波器的設(shè)計(jì)與選擇方案一:采用分立元件,搭建LC低通濾波器。方案說(shuō)明:雖然電路結(jié)構(gòu)簡(jiǎn)樸,但精度不高,穩(wěn)定性差。方案二:采用高精低噪運(yùn)算放大器OP07搭建截止頻率為5KHz的二階有源低通濾波器。方案說(shuō)明:可運(yùn)用濾波器專用設(shè)計(jì)軟件FilterSolutions設(shè)計(jì),得到二階低通有源濾波器電路的連接圖和頻率響應(yīng)曲線。方案三:采用LTC1564芯片搭建截止頻率為10KHz的十階低通濾波器。方案說(shuō)明:LTC1564是凌力爾特公司的數(shù)控濾波器芯片,可采用經(jīng)典10KHz的十階低通濾波器電路結(jié)構(gòu),設(shè)計(jì)簡(jiǎn)樸,濾波效果非常好,穩(wěn)定性高。綜上論證比較,我們選用方案三作為低通濾波器的實(shí)現(xiàn)方法。1.4ADC模塊的設(shè)計(jì)與選擇方案一:采用ADC芯片搭建模數(shù)轉(zhuǎn)換電路。方案說(shuō)明:可選取合適的ADC芯片,采用經(jīng)典模塊電路搭建。方案二:直接運(yùn)用STM32片上的12位高速ADC模塊。方案說(shuō)明:本系統(tǒng)選用的核心板STM32F103ZET6上,自帶3個(gè)12位模數(shù)轉(zhuǎn)換器,且轉(zhuǎn)換時(shí)間可達(dá)1us,多達(dá)21個(gè)輸入通道。由于單片機(jī)上的ADC已可以達(dá)成實(shí)驗(yàn)采樣規(guī)定,故我們選用方案二作為ADC模塊的設(shè)計(jì)方法,可減少外部電路的焊接。1.5被測(cè)網(wǎng)絡(luò)的設(shè)計(jì)與選擇被測(cè)網(wǎng)絡(luò)按照實(shí)驗(yàn)規(guī)定采用RLC串聯(lián)諧振網(wǎng)絡(luò)設(shè)計(jì),圖示如下:圖1.1 RLC被測(cè)網(wǎng)絡(luò)電路圖RLC被測(cè)網(wǎng)絡(luò)的元器件值詳見(jiàn)電路理論分析。電路設(shè)計(jì)2.1正交掃描信號(hào)源設(shè)計(jì)電路正交掃描信號(hào)源采用AD9854芯片設(shè)計(jì),電路詳見(jiàn)附圖。2.2模擬乘法器設(shè)計(jì)電路模擬乘法器采用AD835芯片設(shè)計(jì),電路如下:圖2.1?乘法器電路2.3低通濾波器設(shè)計(jì)電路低通濾波器采用LTC1564芯片設(shè)計(jì),搭建構(gòu)成十階的可達(dá)10KHz截止頻率的電路,圖示如下:圖2.2 低通濾波器電路2.4末級(jí)電壓抬升設(shè)計(jì)電路由于本系統(tǒng)設(shè)計(jì)檢測(cè)被測(cè)網(wǎng)絡(luò)信號(hào)為正弦波形,電壓有負(fù)值,接入ADC采樣前設(shè)計(jì)一電壓抬升電路,圖示如下:圖2.3 末級(jí)電壓抬升電路系統(tǒng)設(shè)計(jì)3.1方案總體設(shè)計(jì)描述本方案一方面設(shè)計(jì)一個(gè)正交掃描信號(hào)源,可產(chǎn)生相位互為正交的雙端口正弦信號(hào),可設(shè)立信號(hào)頻率的步進(jìn)單位。制作一個(gè)RLC串聯(lián)諧振電路作為被測(cè)網(wǎng)絡(luò),且網(wǎng)絡(luò)通帶中心頻率為20Mhz。自制信號(hào)源產(chǎn)生的兩路正弦信號(hào)和被測(cè)網(wǎng)絡(luò)信號(hào)通過(guò)乘法器模塊,由低通濾波模塊濾除高頻分量,得到被測(cè)網(wǎng)絡(luò)的頻率,由ADC采樣信號(hào)并輸出顯示。圖3.1簡(jiǎn)易頻率特性測(cè)試儀系統(tǒng)原理示意圖該方案在硬件電路設(shè)計(jì)上重要包含了AD9854正交掃描信號(hào)發(fā)生器、AD835模擬乘法器、LTC1564低通濾波器、末級(jí)抬升電壓電路及RLC串聯(lián)諧振被測(cè)網(wǎng)絡(luò)五個(gè)模塊,通過(guò)逐個(gè)模塊調(diào)試至整個(gè)系統(tǒng)電路連貫調(diào)試,完畢基本測(cè)試實(shí)驗(yàn)規(guī)定。在軟件設(shè)計(jì)上運(yùn)用了ARM編程工具和STM32核心開(kāi)發(fā)板,軟件重要包含了對(duì)AD9854、串口通信、片上ADC采樣及彩屏控制部分。其中,ADC模塊采用STM32板上自帶12位高速ADC,減少了部分硬件電路的設(shè)計(jì),容易實(shí)現(xiàn)。3.2理論分析與計(jì)算3.2.1正交掃描信號(hào)發(fā)生器的設(shè)計(jì)本設(shè)計(jì)的掃描信號(hào)發(fā)生器以AD9854芯片采用DDS技術(shù),結(jié)合單片機(jī)程控,以產(chǎn)生兩路正交正弦信號(hào)。設(shè)計(jì)中設(shè)立AD9854為單音模式,不僅可以調(diào)制所需頻率的頻率源信號(hào),并且可根據(jù)需要設(shè)立輸出信號(hào)的幅度、頻率和相位等,即通過(guò)改變ROM表輸出的幅度控制字實(shí)現(xiàn)幅度控制,通過(guò)改變相位累加器輸入端的頻率控制字實(shí)現(xiàn)頻率控制,通過(guò)改變相位累加器輸出端的相位控制字實(shí)現(xiàn)相位控制,從而完畢相應(yīng)的幅度、頻率和相位的調(diào)制。設(shè)相位累加器的位數(shù)為N,相位控制字的值為FN,頻率控制字的位數(shù)為M,頻率控制字的值為FM,AD9854內(nèi)部工作時(shí)鐘為FC,則最終合成信號(hào)的頻率可由式(3-1)來(lái)決定,合成信號(hào)的相位由式(3-2)來(lái)決定。F=FMFC/2θ=2πFN/2當(dāng)AD9854的參考時(shí)鐘頻率為270MHz時(shí),其頻率分辨率計(jì)算:270×相位控制精度計(jì)算:360幅度控制范圍計(jì)算:20得到頻率分辨率接近10-3.2.2低通濾波器的設(shè)計(jì)設(shè)計(jì)中為得到被測(cè)網(wǎng)絡(luò)信號(hào)的頻率特性,需要將通過(guò)乘法器后的高頻分量濾除,由于被測(cè)網(wǎng)絡(luò)中心頻率在20MHz,故我們選用凌力爾特公司的LTC1564芯片,采用經(jīng)典電路,通過(guò)Multisim軟件搭建電路并進(jìn)行仿真調(diào)試,設(shè)計(jì)截止頻率為10KHz的低通濾波器。3.2.3RLC被測(cè)網(wǎng)絡(luò)的設(shè)計(jì)RLC串聯(lián)電路由電阻R、電感L及電容C串聯(lián)構(gòu)成,運(yùn)用Multisim軟件設(shè)計(jì)被測(cè)網(wǎng)絡(luò)電路。反映RLC電路頻率特性的參數(shù)有諧振頻率f0、通頻帶寬BW和品質(zhì)因數(shù)Q,其定義如下:f0=12πRCBW=fH-fQ=ω0其中,計(jì)算通頻帶式(3-4)中的fH和fL分別是回路電流由最大值增長(zhǎng)和減少3dB時(shí)所相應(yīng)的上限頻率和下限頻率;計(jì)算品質(zhì)因數(shù)式(3-5)中的ω0=3.2.4特性曲線顯示1)幅頻特性曲線采用STM32片上ADC芯片,通過(guò)DMA通道測(cè)量信號(hào)電壓值,當(dāng)ADC轉(zhuǎn)換結(jié)束以后,讀取ADC_DR寄存器中的結(jié)果,通過(guò)下面的公式轉(zhuǎn)換電壓:Vtempsensor=設(shè)系統(tǒng)輸出的兩路正交信號(hào)為:Ua=U1sinφ ? Ub=U2cosφ? ??經(jīng)ADC雙通道采樣后,電壓幅值計(jì)算:U=|U1|2+|據(jù)經(jīng)電壓轉(zhuǎn)換后,計(jì)算電壓增益,公式如下:AV=20lg?|u012us|? 在彩屏上顯示幅頻特性曲線,以線性頻率(Hz)為橫坐標(biāo),以電壓增益(dB)為縱坐標(biāo),顯示出被測(cè)信號(hào)的幅頻特性曲線。2)相頻特性曲線兩路正交信號(hào)經(jīng)ADC雙通道采樣后,相位計(jì)算:Arg=arctan|U由于信號(hào)相位計(jì)算需要函數(shù)算法,比較復(fù)雜,故采用查表法程序。在彩屏上顯示相頻特性曲線,以線性頻率(Hz)為橫坐標(biāo),以相移(℃)為縱坐標(biāo),顯示出被測(cè)信號(hào)的相頻特性曲線。軟件設(shè)計(jì)在本設(shè)計(jì)中,由STM32F103ZET6核心板實(shí)現(xiàn)程序的控制。其中,軟件重要完畢了AD9854的信號(hào)發(fā)生控制、Usart串口通信、ADC雙通道采樣、彩屏TFT顯示的功能。系統(tǒng)框圖及流程如下:開(kāi)始開(kāi)始STM2初始化STM2初始化STM1初始化彩屏初始化顯示開(kāi)機(jī)界面控制AD9854掃描信號(hào)發(fā)生器彩屏初始化顯示開(kāi)機(jī)界面控制AD9854掃描信號(hào)發(fā)生器UasrtUasrt串口通信ADCADC雙通道采樣結(jié)束彩屏TFT顯示特性曲線結(jié)束彩屏TFT顯示特性曲線圖4.1 系統(tǒng)軟件流程框圖系統(tǒng)測(cè)試5.1測(cè)試方法本系統(tǒng)的測(cè)試過(guò)程中,模擬電路采用由前端到后端,數(shù)字電路采用先仿真再調(diào)試的方法,從逐個(gè)模塊測(cè)試完畢再到模塊連接調(diào)試,直至整個(gè)系統(tǒng)電路完畢測(cè)試規(guī)定。5.2測(cè)試工具1)直流穩(wěn)壓源2)安捷倫數(shù)字示波器3)函數(shù)信號(hào)發(fā)生器4)數(shù)字頻譜儀5)數(shù)字萬(wàn)用表5.3各模塊測(cè)試過(guò)程5.3.1掃頻信號(hào)發(fā)生器的測(cè)試使用直流穩(wěn)壓源對(duì)AD9854制成的掃描信號(hào)發(fā)生器進(jìn)行正負(fù)5V供電,可承載電流不超過(guò)1A,將掃描信號(hào)發(fā)生器連接單片機(jī),下載控制程序,通過(guò)數(shù)字示波器顯示輸出的I路及Q路信號(hào),現(xiàn)列出一組典型實(shí)驗(yàn)數(shù)據(jù)。表5.1?掃描信號(hào)發(fā)生器測(cè)試結(jié)果

理論電壓(Vpp/V)實(shí)際電壓(Vpp/V)理論頻率(f/MHz)實(shí)際頻率(f/MHz)I路信號(hào)2.001.9820.020.0Q路信號(hào)2.001.9620.020.0I、Q兩路正弦信號(hào)呈正交關(guān)系,示波器上測(cè)量計(jì)算兩路信號(hào)相位呈90度。輸出電壓和頻率誤差小于5%。通過(guò)頻譜儀接入電路輸出信號(hào),掃描信號(hào)發(fā)生器完全可產(chǎn)生1M-40MHz范圍的信號(hào),精度可達(dá)10-4;且頻率步進(jìn)可調(diào),達(dá)100KHz精度。5.3.2乘法器模塊的測(cè)試運(yùn)用數(shù)字函數(shù)發(fā)生器產(chǎn)生兩路正交正弦信號(hào),接入乘法器模擬電路,現(xiàn)列出一組典型信號(hào)測(cè)試結(jié)果:兩路輸入電壓峰峰值均為Vp-p=2.00V,頻率均為F=20MHz。表5.2?乘法器測(cè)試結(jié)果

理論電壓(Vpp/V)實(shí)際電壓(Vpp/V)理論頻率(f/MHz)實(shí)際頻率(f/MHz)I路信號(hào)2.001.9820.020.0Q路信號(hào)2.002.0020.020.0輸出信號(hào)1.000.9840.039.9綜上數(shù)據(jù)可看出,模擬乘法器模塊工作正常,輸出信號(hào)誤差小于2%。5.3.3輸入輸出阻抗的測(cè)試運(yùn)用數(shù)字萬(wàn)用表測(cè)試該系統(tǒng)的輸入阻抗和輸出阻抗,即測(cè)量被測(cè)網(wǎng)絡(luò)兩端的Ri和RO,可達(dá)50Ω。5.3.4RLC被測(cè)網(wǎng)絡(luò)的測(cè)試連接RLC被測(cè)網(wǎng)絡(luò),運(yùn)用調(diào)節(jié)頻率法測(cè)量電路的諧振頻率。電路輸入端接入數(shù)字函數(shù)發(fā)生器,保持信號(hào)源輸出電壓US不變,改變信號(hào)發(fā)生器的頻率,將電路輸出端接入數(shù)字頻譜儀觀測(cè)其輸出的電壓值。當(dāng)輸出電壓UR的讀數(shù)達(dá)成最大值(即電流達(dá)成最大值)時(shí),其所相應(yīng)的頻率值即為諧振頻率或中心頻率。設(shè)立數(shù)字函數(shù)發(fā)生器輸出電壓為2.0V,調(diào)節(jié)信號(hào)頻率,取一組調(diào)節(jié)頻率法測(cè)試結(jié)果列示如下:表5.3 RLC被測(cè)網(wǎng)絡(luò)測(cè)試結(jié)果信號(hào)源頻率(f/MHz)

17.018.019.020.021.022.023.0測(cè)量電壓(U0/V)1.321.581.801.981.781.541.30由上表數(shù)據(jù)可得,RLC網(wǎng)絡(luò)的中心頻率為20MHz,誤差小于5%;且其通頻帶寬約在17.5MHz-22.5MHz范圍內(nèi),品質(zhì)因數(shù)約4。結(jié)論本設(shè)計(jì)很好的滿足了題目規(guī)定,對(duì)各模塊和整體系統(tǒng)的測(cè)試基本完畢。在設(shè)計(jì)中對(duì)于由AD9854搭建的掃描信號(hào)發(fā)生器花費(fèi)了很多調(diào)試時(shí)間。通過(guò)本次設(shè)計(jì),我們不僅純熟掌握各種儀器設(shè)備的使用調(diào)節(jié),同時(shí)很大限度上提高了動(dòng)手能力和解決問(wèn)題的能力,受益匪淺!參考文獻(xiàn)黃智偉全國(guó)大學(xué)生電子設(shè)計(jì)競(jìng)賽制作實(shí)訓(xùn)北京航空航天大學(xué)出版社黃智偉全國(guó)大學(xué)生電子設(shè)計(jì)競(jìng)賽技能訓(xùn)練北京航空航天大學(xué)出版社謝嘉奎,宣月清.電子線路(非線性部分)高等教育出版社童詩(shī)白,華成英.模擬電子技術(shù)基礎(chǔ)(第四版)高等教育出版社附錄附錄一:元件清單本設(shè)計(jì)系統(tǒng)所用的重要元件清單如下所示:序號(hào)?? 型號(hào)? ?器件封裝 ? 說(shuō)明1???AD835 ?DIP???乘法器2? LTC1564?? SSOP ??8階低通濾波器3 ??REF3033???SSOP ??3.3V基準(zhǔn)電壓4? ?ua741 ?DIP???通用運(yùn)放5?? OPA727?? SSOP?? 通用運(yùn)放6? ?若干電阻電容表7.1? 系統(tǒng)元件清單列表附錄二:AD9854掃描信號(hào)發(fā)生器設(shè)計(jì)電路AD9854的高速DDS模塊硬件原理圖如下所示:圖7.1 ?AD9854掃描信號(hào)發(fā)生器硬件原理圖附錄三:系統(tǒng)總體設(shè)計(jì)電路本系統(tǒng)總體硬件設(shè)計(jì)原理圖如下所示:圖7.2? 系統(tǒng)總體硬件原理圖附錄四:重要程序清單/******************************************************************************AD9854控制程序:******************************************************************************/voidSetAD9854Frequency(ucharucFreWordAdd,ulongulFreqVal){?ucharFreqWord[6]; ucharCount=6,Adress; ulongFreqBuf;?Adress=ucFreWordAdd; FreqBuf=(ulFreqVal*FRETMP_Low); FreqWord[0]=(FreqBuf%0x100)&0xff;?FreqBuf/=0x100; FreqBuf+=(ulFreqVal*FRETMP_MIDDLE); FreqWord[1]=(FreqBuf%0x100)&0xff; FreqBuf/=0x100; FreqBuf+=(ulFreqVal*FRETMP_HIGH); FreqWord[2]=(FreqBuf%0x100)&0xff; FreqBuf/=0x100;?FreqWord[3]=(FreqBuf%0x100)&0xff;?FreqBuf/=0x100;?FreqWord[4]=(FreqBuf%0x100)&0xff;?FreqWord[5]=(FreqBuf/0x100)&0xff; for(Count=6;Count;)?{AD9854_WriteByte(Adress++,FreqWord[--Count]);??AD9854_WR_0; AD9854_WR_1; }?AD9854_UDCLK_1;?AD9854_UDCLK_0;}voidSetAD9854Amplitude(ucharucChannel,uintuiAmpVal){?ucharAmpWo(hù)rd[2];?uintAmpB(yǎng)uf;?AmpWord[0]=(u8)(((u16)(uiAmpVal*4096/5))%256);?AmpWord[1]=(u8)(((u16)(uiAmpVal*4096/5))/256); if(ucChannel==I) {??AD9854_WR_0; ?AD9854_WR_1; AD9854_WR_0; AD9854_WR(shí)_1; }?if(ucChannel==Q) { AD9854_WR_0;? AD9854_WR_1;???AD9854_WR_0; ?? ? ? AD9854_WR_1;?} AD9854_UDCLK_1; AD9854_UDCLK_0;}voidSetAD9854Phase(ucharucPhaAdjRegAdd,uintuiPhaVal){?ucharPhaWord[2]; uintPhaBuf; PhaBuf=(uiPhaVal*0x2d);?PhaWord[0]=(PhaBuf%0x100)&0xff; PhaWord[1]=(PhaBuf/0x100)&0xff;? ?AD9854_WriteByte(ucPhaAdjRegAdd,PhaWord[1]);?AD9854_WR_0; AD9854_WR_1;?? AD9854_WriteByte(ucPhaAdjRegAdd+1,PhaWord[0]);?AD9854_WR(shí)_0;?AD9854_WR_1;? AD9854_UDCLK_1;?AD9854_UDCLK_0;}/******************************************************************************Uarst串口初始化程序:******************************************************************************/voidUSART1_Configuration(void){USART_InitTypeDefUSART_InitStructure;USART_ClockInitTypeDefUSART_ClockInitStructure;USART_InitStructure.USART_BaudRate=115200;USART_InitStructure.USART_WordLength=USART_WordLength_8b;USART_InitStructure.USART_StopB(yǎng)its=USART_StopBits_1;USART_InitStructure.USART_Parity=USART_Parity_No;USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;USART_InitStructure.USART_M(jìn)ode=USART_Mode_Rx|USART_Mode_Tx;/*ConfiguretheUSART1*/USART_Init(USART1,&USART_InitStructure);USART_ClockInitStructure.USART_Clock=USART_Clock_Disable;USART_ClockInitStructure.USART_CPOL=USART_CPOL_Low;USART_ClockInitStructure.USART_CPHA=USART_CPHA_2Edge;USART_ClockInitStructure.USART_LastBit=USART_LastBit_Disable;USART_ClockStructInit(&USART_ClockInitStructure);}/******************************************************************************ADC采樣程序:******************************************************************************/voidDAC_Configuration(void){DAC_InitTypeDefDAC_InitStructure;DAC_Cmd(DAC_Channel_1,ENABLE);DAC_StructInit(&DAC_InitStructure);?DAC_InitStructure.DAC_Trigger=DAC_Trigger_Software; DAC_InitStructure.DAC_WaveGenerat(yī)ion=DAC_WaveGeneration_None;DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude=DAC_TriangleAmplitude_4095;?DAC_InitStructure.DAC_OutputBuffer=DAC_OutputBuffer_Enable; DAC_Init(DAC_Channel_1,&DAC_InitStructure);?DAC_Cmd(DAC_Channel_1,ENABLE);//DAC_SetChannel1Data(DAC_Align_12b_R,0x0000); DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);}voidADC_Configuration(void){ADC_InitTypeDefADC_InitStructure;/*ConfiguretheADC1*/ADC_InitStructure.ADC_Mode=ADC_Mode_Independent;ADC_InitStructure.ADC_ScanConvMode=ENABLE;ADC_InitStructure.ADC_ContinuousConvMode=ENABLE;ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_None;ADC_InitStructure.ADC_DataAlign=ADC_DataAlign_Right;ADC_InitStructure.ADC_NbrOfChannel=1;ADC_Init(ADC1,&ADC_InitStructure);/*ADC2regularchannel5configuration*/ADC_RegularChannelConfig(ADC1,ADC_Channel_3,1,ADC_SampleTime_1Cycles5);ADC_DMACmd(ADC1,ENABLE);/*EnableADC2*/ADC_Cmd(ADC1,ENABLE);/*EnableADC2resetcalibarationregister*/ADC_ResetCalibration(ADC1);/*ChecktheendofADC2resetcalibrationregister*/while(ADC_GetResetCalibrationStatus(ADC1));/*StartADC2calibaration*/ADC_StartCalibrat(yī)ion(ADC1);/*ChecktheendofADC2calibration*/while(ADC_GetCalibrationStatus(ADC1));/*StartADC2SoftwareConversion*/ADC_SoftwareStartConvCmd(ADC1,ENABLE);}voidDMA_Configuration(void){DMA_InitTypeDefDMA_InitStructure;DMA_DeInit(DMA1_Channel1);?DMA_InitStructure.DMA_PeripheralBaseAddr=ADC1_DR_Address;?DMA_InitStructure.DMA_MemoryBaseAddr=(u32)&ADCConvertedValue;?DMA_InitStructure.DMA_DIR=DMA_DIR_PeripheralSRC;?DMA_InitStructure.DMA_BufferSize=1024;?DMA_InitStructure.DMA_PeripheralInc=DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc=DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize=DMA_PeripheralDataSize_HalfWo(hù)rd;?DMA_InitStructure.DMA_MemoryDataSize=DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode=DMA_Mode_Circular;?DMA_InitStructure.DMA_Priority=DMA_Priority_High; DMA_InitStructure.DMA_M2M=DMA_M2M_Disable;?DMA_Init(DMA1_Channel1,&DMA_InitStructure); DMA_ITConfig(DMA1_Channel1,DMA_IT_TC,ENABLE); /*EnableDMA1channel1*/?DMA_Cmd(DMA1_Channel1,ENABLE); }/******************************************************************************TFT彩屏部分算法程序:******************************************************************************/voidLCD_Writ_Bus(charVH,charVL)//并行數(shù)據(jù)寫入函數(shù){datah_change(VH);//LCD_DataPortH=VH; datal_change(VL);//LCD_DataPortL=VL; GPIO_ResetBits(LCD_GRP,LCD_WR);//LCD_WR=0;?GPIO_SetBits(LCD_GRP,LCD_WR(shí));//LCD_WR=1;}voidLcd_Write_Com(charVH,charVL) //發(fā)送命令-8位參數(shù){ GPIO_ResetBits(LCD_RS_GRP,LCD_RS);//LCD_RS=0;?LCD_Writ_Bus(VH,VL);}voidLcd_Write_Dat(yī)a(charVH,charVL)//發(fā)送數(shù)據(jù)-8位參數(shù){GPIO_SetBits(LCD_RS_GRP,LCD_RS);//LCD_RS=1;?LCD_Writ_Bus(VH,VL);}voidLcd_Write_Com_Data(intcom,intval)??//發(fā)送數(shù)據(jù)命令{?Lcd_Write_Com(com>>8,com);Lcd_Write_Data(val>>8,val);}voidAddress_set(unsignedintx1,unsignedinty1,unsignedintx2,unsignedinty2){ Lcd_Write_Com(0x00,0x46);Lcd_Write_Data(x2,x1); Lcd_Write_Com(0x00,0x47);Lcd_Write_Data(y2>>8,y2);Lcd_Write_Com(0x00,0x48);Lcd_Write_Data(y1>>8,y1); Lcd_Write_Com(0x00,0x20);Lcd_Write_Data(x1>>8,x1); Lcd_Write_Com(0x00,0x21);Lcd_Write_Data(y1>>8,y1);Lcd_Write_Com(0x00,0x22);???? ?}//畫(huà)點(diǎn)//POINT_COLOR:此點(diǎn)的顏色voidLCD_DrawPoint(unsignedintx,unsignedinty,unsignedintPOINT_COLOR)??//把函數(shù)體內(nèi)的xy調(diào)換{if(x>319)x=319;elseif(x<0)x=0;if(y>239)y=239;elseif(y<0)y=0; Address_set(y,x,y,x);//設(shè)立光標(biāo)位置 Lcd_Write_Dat(yī)a(POINT_COLOR>>8,POINT_COLOR);?}//畫(huà)線//x1,y1:起點(diǎn)坐標(biāo)//x2,y2:終點(diǎn)坐標(biāo)voidLCD_DrawLine(unsignedintx1,unsignedinty1,unsignedintx2,unsignedinty2,iu16color){ u16t; intxerr=0,yerr=0,delta_x,delta_y,distance; intincx,incy,uRow,uCol;?delta_x=x2-x1;//計(jì)算坐標(biāo)增量 delta_y=y2-y1; uRow=x1;?uCol=y1;?if(delta_x>0)incx=1;//設(shè)立單步方向 elseif(delta_x==0)incx=0;//垂直線?else{incx=-1;delta_x=-delta_x;} if(delta_y>0)incy=1; elseif(delta_y==0)incy=0;//水平線 else{incy=-1;delta_y=-delta_y;}?if(delta_x>delta_y)distance=delta_x;//選取基本增量坐標(biāo)軸 elsedistance=delta_y;?for(t=0;t<=distance+1;t++)//畫(huà)線輸出?{? LCD_DrawPoint(uRow,uCol,color);//畫(huà)點(diǎn)??xerr+=delta_x; ?yerr+=delta_y;

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論