2021年電子競賽簡易頻率測試儀_第1頁
2021年電子競賽簡易頻率測試儀_第2頁
2021年電子競賽簡易頻率測試儀_第3頁
2021年電子競賽簡易頻率測試儀_第4頁
2021年電子競賽簡易頻率測試儀_第5頁
已閱讀5頁,還剩25頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

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

理論電壓(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)系,示波器上測量計(jì)算兩路信號(hào)相位呈90度。輸出電壓和頻率誤差不大于5%。通過頻譜儀接入電路輸出信號(hào),掃描信號(hào)發(fā)生器完全可產(chǎn)生1M-40MHz范疇信號(hào),精度可達(dá)10-4;且頻率步進(jìn)可調(diào),達(dá)100KHz精度。5.3.2乘法器模塊測試運(yùn)用數(shù)字函數(shù)發(fā)生器產(chǎn)生兩路正交正弦信號(hào),接入乘法器模仿電路,現(xiàn)列出一組典型信號(hào)測試成果:兩路輸入電壓峰峰值均為Vp-p=2.00V,頻率均為F=20MHz。表5.2 乘法器測試成果

理論電壓(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輸入輸出阻抗測試運(yùn)用數(shù)字萬用表測試該系統(tǒng)輸入阻抗和輸出阻抗,即測量被測網(wǎng)絡(luò)兩端Ri和RO,可達(dá)50Ω。5.3.4RLC被測網(wǎng)絡(luò)測試連接RLC被測網(wǎng)絡(luò),運(yùn)用調(diào)節(jié)頻率法測量電路諧振頻率。電路輸入端接入數(shù)字函數(shù)發(fā)生器,保持信號(hào)源輸出電壓US不變,變化信號(hào)發(fā)生器頻率,將電路輸出端接入數(shù)字頻譜儀觀測其輸出電壓值。當(dāng)輸出電壓UR讀數(shù)達(dá)到最大值(即電流達(dá)到最大值)時(shí),其所相應(yīng)頻率值即為諧振頻率或中心頻率。設(shè)立數(shù)字函數(shù)發(fā)生器輸出電壓為2.0V,調(diào)節(jié)信號(hào)頻率,取一組調(diào)節(jié)頻率法測試成果列示如下:表5.3 RLC被測網(wǎng)絡(luò)測試成果信號(hào)源頻率(f/MHz)

17.018.019.020.021.022.023.0測量電壓(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)測試基本完畢。在設(shè)計(jì)中對(duì)于由AD9854搭建掃描信號(hào)發(fā)生器耗費(fèi)了諸多調(diào)試時(shí)間。通過本次設(shè)計(jì),咱們不但純熟掌握各種儀器設(shè)備使用調(diào)節(jié),同步很大限度上提高了動(dòng)手能力和解決問題能力,受益匪淺!參照文獻(xiàn)黃智偉全國大學(xué)生電子設(shè)計(jì)競賽制作實(shí)訓(xùn)北京航空航天大學(xué)出版社黃智偉全國大學(xué)生電子設(shè)計(jì)競賽技能訓(xùn)練北京航空航天大學(xué)出版社謝嘉奎,宣月清.電子線路(非線性某些)高等教誨出版社童詩白,華成英.模仿電子技術(shù)基本(第四版)高等教誨出版社附錄附錄一:元件清單本設(shè)計(jì)系統(tǒng)所用重要元件清單如下所示:序號(hào) 型號(hào) 器件封裝 闡明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){ ucharAmpWord[2]; uintAmpBuf; 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_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_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_StopBits=USART_StopBits_1;USART_InitStructure.USART_Parity=USART_Parity_No;USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;USART_InitStructure.USART_Mode=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_WaveGeneration=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_StartCalibration(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_HalfWord; 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);//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_Data(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); }//畫點(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_Data(POINT_COLOR>>8,POINT_COLOR); }//畫線//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++)//畫線輸出 { LCD_DrawPoint(uRow,uCol,color);//畫點(diǎn) xerr+=delta_x; yerr+=delta_y; if(xerr>d

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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)論