電容測(cè)量報(bào)告_第1頁(yè)
電容測(cè)量報(bào)告_第2頁(yè)
電容測(cè)量報(bào)告_第3頁(yè)
電容測(cè)量報(bào)告_第4頁(yè)
電容測(cè)量報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩14頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

評(píng)閱成績(jī)2014年湖南省大學(xué)生電子設(shè)計(jì)競(jìng)賽設(shè)計(jì)報(bào)告題號(hào):A)競(jìng)賽題名稱(chēng): 基于LM3S811實(shí)現(xiàn)的電容參數(shù)測(cè)量?jī)x參賽隊(duì)編號(hào): 0908 評(píng)閱人簽名: 2014年8月24日基于LM3S811實(shí)現(xiàn)的電容參數(shù)測(cè)試儀摘要本系統(tǒng)采用鍵盤(pán)和CD4052模擬開(kāi)關(guān)聯(lián)合控制的方法實(shí)現(xiàn)對(duì)電容參數(shù)的測(cè)量。同時(shí)系統(tǒng)以TI公司的LM3S811為核心,使用TLV7211產(chǎn)生方波,由控制器對(duì)方波數(shù)據(jù)進(jìn)行處理并顯示。在達(dá)到基本要求的基礎(chǔ)上,系統(tǒng)還能夠測(cè)量一定范圍電容的ESR。一、 設(shè)計(jì)思路描述總體方案系統(tǒng)包括:電壓轉(zhuǎn)化模塊、顯示模塊、按鍵模塊、控制模塊等。系統(tǒng)總體框圖如圖1所示。圖1總體方案圖方波產(chǎn)生模塊方案一:采用555定時(shí)器及外接RC電路產(chǎn)生方波,但是在仿真中發(fā)現(xiàn)該方案僅適用于中檔大小的電容,對(duì)于較大或較小的電容無(wú)法產(chǎn)生準(zhǔn)確的波形,故舍棄此方案。方案二:采用TLV7211產(chǎn)生方波,由輸出端向電容進(jìn)行充電,當(dāng)電容電壓高于某一值時(shí),輸出端電壓產(chǎn)生翻轉(zhuǎn),從而產(chǎn)生方波。所產(chǎn)生方波的頻率由R和Cx共同決定,即f=1/(2*ln2*R*Cx),通過(guò)模擬開(kāi)關(guān)切換電阻來(lái)產(chǎn)生不同的檔位,經(jīng)過(guò)仿真,此法可以測(cè)量題目要求的電容范圍,故采用之。電壓轉(zhuǎn)化模塊方案一:通過(guò)電阻分壓來(lái)獲得+5V電壓,此法電路簡(jiǎn)單,但由于功率較低,帶動(dòng)負(fù)載能力相對(duì)較差,不能滿(mǎn)足系統(tǒng)要求,故舍之。方案二:采用三端穩(wěn)壓芯片加電容濾波,此法電壓值穩(wěn)定帶負(fù)載能力強(qiáng),可以滿(mǎn)足系統(tǒng)的需求,故采用之。二、 硬件系統(tǒng)設(shè)計(jì)方波產(chǎn)生電路利用TLV7211制作比較器,產(chǎn)生方波,原理圖如下:

100們50kQ1MQ100們50kQ1MQ10kQ圖2方波產(chǎn)生電路圖控制器通過(guò)I/O口采集到輸出端輸出的方波,通過(guò)計(jì)算得到電容值電壓轉(zhuǎn)化電路5VGND5VGND3.ESR測(cè)量電路三、 算法數(shù)學(xué)描述1.檔位電阻的選擇待測(cè)電容Cx=l/(2*ln2*R*f),首先,選定待測(cè)電容Cx的范圍,通過(guò)調(diào)節(jié)單位電阻R的值,使頻率f滿(mǎn)足一個(gè)合適的測(cè)量范圍。2.頻率的測(cè)量使用定時(shí)器0定時(shí)200ms,定時(shí)器1A設(shè)置為輸入計(jì)數(shù)模式用來(lái)計(jì)錄上升沿個(gè)數(shù),當(dāng)定時(shí)器0記

時(shí)完畢,假設(shè)定時(shí)器A1所記上升沿個(gè)數(shù)為n,若n〉2000,則說(shuō)明此頻率較高,適合輸入計(jì)時(shí)模式,從而直接計(jì)算頻率。若n〈=2000,則說(shuō)明頻率較低,記錄上升沿個(gè)數(shù)可能導(dǎo)致誤差較大,故設(shè)置定時(shí)器1A為輸入計(jì)時(shí)模式,計(jì)算兩個(gè)上升沿之間的時(shí)間,從而測(cè)得頻率。ESR測(cè)量原理使用單片機(jī)PWM模塊產(chǎn)生lOOKHz方波,利用電容節(jié)濾波,電阻分壓產(chǎn)生峰峰值為250V方波,將待測(cè)電容視為電阻,通過(guò)放大器加直流偏置并放大信號(hào),后又濾去直流電壓,再一次加直流偏置并進(jìn)行峰值檢測(cè),最后與一電阻分壓,通過(guò)讀取分壓值可以算得電容阻值。四、 系統(tǒng)軟件流程圖 如下圖所示。部分源程序見(jiàn)附錄E.開(kāi)始主函數(shù)框圖啟動(dòng)timerO啟動(dòng)timerlA電容測(cè)試函數(shù)框圖開(kāi)始主函數(shù)框圖啟動(dòng)timerO啟動(dòng)timerlA電容測(cè)試函數(shù)框圖五、 測(cè)試方法測(cè)試使用的儀器EM1716型三路直流穩(wěn)定電源、TektronixTDS1012100MHz示波器、萬(wàn)用表、M8電容測(cè)試儀測(cè)試方法(1) 記錄標(biāo)注電容、對(duì)應(yīng)電阻、計(jì)算頻率、測(cè)量頻率、測(cè)算電容并計(jì)算電容誤差。(2) 記錄加模擬開(kāi)關(guān)后的對(duì)應(yīng)電阻、計(jì)算頻率、測(cè)算電容及誤差。(3) 進(jìn)行軟件調(diào)試,記錄電容標(biāo)注值、電容測(cè)試儀測(cè)量值、系統(tǒng)顯示值、測(cè)試誤差。以上測(cè)試結(jié)果分別由表1、表2、表3記錄,詳見(jiàn)附錄A。六、 指標(biāo)測(cè)試和測(cè)試結(jié)果表1標(biāo)注電容電阻計(jì)算頻率測(cè)量頻率測(cè)算電容測(cè)量誤差1.00E-0910000009.72163E-10721.3445863742-0.0278374852.20E-0910000002.19254E-09327.8839029329-0.003392392

3.30E-0910000003.08267E-09218.5892686234-0.065857827表2標(biāo)注電容電阻(加模擬開(kāi)關(guān))測(cè)量頻率計(jì)算頻率測(cè)算電容測(cè)試誤差1.00E-091000300714721.12824781.00998E-090.009983542.20E-091000300326327.78556722.21205E-090.00547723.30E-091000300233218.52371153.09497E-09-0.062129994表3標(biāo)注電容電容測(cè)試儀測(cè)量值系統(tǒng)顯示值測(cè)試誤差(相對(duì)測(cè)試儀)誤差(相對(duì)標(biāo)注值)4.70E-084.83E-084.61E-08-0.045548654-0.0191489366.80E-087.02E-086.75E-08-0.038324548-0.0073529411.00E-071.07E-071.03E-07-0.0337078650.032七、 數(shù)據(jù)分析與結(jié)論經(jīng)實(shí)際測(cè)試,本系統(tǒng)可以在33pF-470uF的范圍內(nèi)實(shí)現(xiàn)電容參數(shù)的測(cè)量,而且測(cè)量結(jié)果較準(zhǔn)確,同時(shí)可以在一定范圍內(nèi)實(shí)現(xiàn)ESR的測(cè)量。系統(tǒng)通過(guò)鍵盤(pán)進(jìn)行人機(jī)交互,具備LCD顯示功能。采用供電電壓3.3v的LCD液晶顯示測(cè)量數(shù)據(jù)。系統(tǒng)較好地實(shí)現(xiàn)了題目的基本要求和部分提高要求。附錄A:表1標(biāo)注電容F電阻Q測(cè)算電容F計(jì)算頻率Hz測(cè)量頻率Hz電容誤差%l.OOE-1110000002.67165E-1172134.45863270001.6716466162.20E-1110000004.02986E-1132788.39029179000.8317536473.30E-1110000005.09784E-1121858.92686141500.5448004851.00E-1010000001.16534E-117213.44586361900-0.8834661412.20E-1010000002.40448E-103278.83902930000.0929463433.30E-1010000003.60672E-102185.89268620000.0929463434.70E-1010000004.89047E-101534.77571614750.0405259096.80E-1010000007.21345E-101060.80086210000.0608008621.00E-0910000009.72163E-10721.3445863742-0.0278374852.20E-0910000002.19254E-09327.8839029329-0.0033923923.30E-0910000003.08267E-09218.5892686234-0.0658578274.70E-0910000004.80896E-09153.47757161500.023183815.60E-0910000006.38358E-09128.81153331130.1399250731.00E-0810000001.0117E-0872.1344586371.30.0117034872.20E-0810000002.4874E-0832.78839029290.1306341483.30E-0810000001.20425E-0921.85892686599-0.9635076353.30E-08496002.42792E-08440.7041705599-0.2642668274.70E-08496004.60229E-08309.4305878316-0.0207892796.80E-08496006.7643E-08213.8711416215-0.0052505041.00E-07496001.03144E-07145.43237631410.0314352932.20E-07496002.08655E-0766.1056255869.7-0.0515692173.30E-07496003.23183E-0744.0704170545-0.0206573994.70E-07496004.19113E-0730.9430587834.7-0.1082691996.80E-07496006.61056E-0721.3871141622-0.0278584476.80E-0797306.56072E-07109.0237268113-0.0351882581.00E-0697319.50366E-0774.128515778-0.0496344141.00E-0597301.11316E-057.4136134266.660.1131551691.00E-051001.17674E-05721.34458636130.1767448391.00E-041000.00010766372076633711

2.20E-041000.0002487432.78839029290.1306341484.70E-041000.00042937215.3477571616.8-0.086443026表2標(biāo)注電容F電阻(加模擬開(kāi)關(guān))測(cè)量頻率計(jì)算頻率測(cè)算電容測(cè)試誤差1.00E-1110003002.20E-1110003003.30E-1110003001006021852.371157.16827E-111.1722038911.00E-10100030052707211.2824781.36836E-100.3683647972.20E-10100030027833277.8556722.59119E-100.1778137523.30E-10100030018822185.2371153.83171E-100.1611249284.70E-10100030014091534.3154215.11801E-100.0889392636.80E-1010003009761060.4827177.38861E-100.0865601611.00E-091000300714721.12824781.00998E-090.009983542.20E-091000300326327.78556722.21205E-090.00547723.30E-091000300233218.52371153.09497E-09-0.0621299944.70E-091000300150153.43154214.80752E-090.0228769476.50E-091000300113110.94280746.38167E-09-0.0182052451.00E-08100030068.372.112824781.05582E-080.0558246672.20E-08100030026.732.778556722.70085E-080.22766133.30E-08100030019.921.852371153.62376E-080.0981091033.30E-0849900398438.05464643.63211E-080.1006398154.70E-0849900314307.57028374.60376E-08-0.0204768046.80E-0849900226212.58534316.39637E-08-0.0593568891.00E-0749900143144.55803331.0109E-070.0108953382.20E-074990066.165.708196972.18696E-07-0.0059274293.30E-074990044.643.805464643.24121E-07-0.0178146944.70E-074990034.330.757028374.21452E-07-0.1032936346.80E-074990021.921.258534316.60082E-07-0.0292906716.80E-0710030108105.76279786.65914E-07-0.0207148351.00E-06100307471.918702529.71874E-07-0.0281256421.00E-05100306.47.1918702521.12373E-050.1237297271.00E-05400167.8180.33614661.07471E-050.0747088591.00E-0440018.318.033614669.85443E-05-0.0145565762.20E-0440088.1970975720.000225420.0246371964.70E-0440043.8369392890.00045084-0.040765178

表3標(biāo)注電容FM8測(cè)試值F系統(tǒng)顯示值測(cè)試誤差(相對(duì)測(cè)試儀)誤差(相對(duì)標(biāo)注)3.30E-113.50E-117.20E-111.0571428571.1818181821.00E-101.01E-101.73E-100.7128712870.732.20E-102.24E-102.58E-100.1517857140.1727272733.30E-103.52E-103.81E-100.0823863640.1545454554.70E-104.83E-105.08E-100.0517598340.0808510646.80E-107.13E-107.30E-100.0235624120.0732352941.00E-091.01E-091.02E-090.0049358340.0182.20E-092.25E-092.21E-09-0.018633540.0054545453.30E-093.39E-093.32E-09-0.0194747710.0069696974.70E-094.88E-094.78E-09-0.0215163930.0159574475.60E-096.59E-096.44E-09-0.0232134730.1496428571.00E-081.05E-081.02E-08-0.0290630980.01562.20E-082.79E-082.77E-08-0.0044867190.2606818183.30E-083.44E-083.43E-08-0.0011925540.0405757584.70E-084.83E-084.61E-08-0.045548654-0.0191489366.80E-087.02E-086.75E-08-0.038324548-0.0073529411.00E-071.07E-071.03E-07-0.0337078650.0322.20E-072.19E-072.13E-07-0.028793419-0.0340909093.30E-073.41E-073.29E-07-0.036656891-0.0045454554.70E-074.58E-074.52E-07-0.014185945-0.038936176.80E-077.09E-076.88E-07-0.0290591060.0122058821.00E-061.00E-069.64E-07-0.038223553-0.03632.20E-062.22E-062.12E-06-0.047297297-0.0386363643.30E-063.35E-063.27E-06-0.024179104-0.0093939391.00E-051.12E-051.20E-050.0682709450.19862.20E-052.48E-052.40E-05-0.0325706210.0896772733.30E-053.68E-053.35E-05-0.0901683870.0151515154.70E-054.80E-054.76E-05-0.0089527380.0127659571.00E-041.03E-041.07E-040.0309777350.0652.20E-042.31E-042.26E-04-0.01949740.0286363643.30E-043.40E-043.62E-040.065921130.0975757584.70E-044.72E-046.03E-040.2780839340.282978723附錄B:頻率測(cè)量程序//頻率測(cè)量//范圍200hz到2.5Mhz#include"frequence.h"#include"inc/hw_types.h"#include"driverlib/debug.h"#include"driverlib/sysctl.h"#include"drivers/display96x16x1.h"#include"driverlib/gpio.h"#include"driverlib/pin_map.h"#include"inc/hw_memmap.h"#include"inc/hw_gpio.h"#include"utils/uartstdio.h"#include"driverlib/timer.h"#include"math.h"http://用來(lái)記錄TimerlA溢出的次數(shù)unsignedlongg_ulTimer1ATimeoutCount=0;//初始化與測(cè)頻相關(guān)的外設(shè)voidFreqMeasureInit(void){//將PD5設(shè)為CCP引腳CCP2SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_5);//ccp2//使能TimerO,設(shè)為32位單次觸發(fā)模式,TimerO用于定時(shí)SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);TimerConfigure(TIMERO_BASE,TIMER_CFG_32_BIT_OS);//使能Timer1ASysCtlPeripheralEnable(SYSCTL_PERIPH_TIMERl);//Timer1A捕捉上升沿即ccp2TimerControlEvent(TIMER1_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);//測(cè)量ulMS毫秒內(nèi)輸入的信號(hào)上升沿?cái)?shù)unsignedlongGetEdgeCount(unsignedlongulMS){unsignedlongulValue;//設(shè)置Timer0定時(shí)器,定時(shí)ulMS毫秒TimerLoadSet(TIMER0_BASE,TIMER_A,(SysCtlClockGet()/1000)*ulMS-1);//配置Timerl,將TimerlA設(shè)置為輸入計(jì)數(shù)模式TimerConfigure(TIMER1_BASE,TIMER_CFG_16_BIT_PAIR|TIMER_CFG_A_CAP_COUNT);TimerLoadSet(TIMERl_BASE,TIMER_A,0xfffe);//裝載初值65534//將匹配寄存器設(shè)置為比裝載寄存器大的值//這樣就不會(huì)產(chǎn)生匹配中斷,Timer1A對(duì)輸入信號(hào)上升沿循環(huán)計(jì)數(shù)TimerMatchSet(TIMERl_BASE,TIMER_A,0xffff);g_ulTimerlATimeoutCount=0;//使能兩個(gè)TimerTimerEnable(TIMERl_BASE,TIMER_A);TimerEnable(TIMER0_BASE,TIMER_A);//檢測(cè)Timer。是否溢出while(!(TimerIntStatus(TIMER0_BASE,false)&TIMER_TIMA_TIMEOUT)){//檢測(cè)TimerlA是否溢出if((TimerIntStatus(TIMERl_BASE,false)&TIMER_TIMA_TIMEOUT)){//若TimerlA溢出,清除溢出標(biāo)志位,g_ulTimer1ATimeoutCount++TimerIntClear(TIMERl_BASE,TIMER_TIMA_TIMEOUT);g_ulTimerlATimeoutCount++;}}//定時(shí)結(jié)束,禁能TimerlATimerDisable(TIMERl_BASE,TIMER_A);ulValue=TimerValueGet(TIMERl_BASE,TIMER_A); //讀取TimerlA計(jì)數(shù)值TimerintClear(TIMERO_BASE,TIMER_TIMA_TIMEOUT);//清除TimerO溢出標(biāo)志位//計(jì)算ulMS毫秒內(nèi)輸入上升沿個(gè)數(shù)并返回g_ulTimer1ATimeoutCount++;returng_ulTimer1ATimeoutCount*65535-ulValue;}//測(cè)量?jī)蓚€(gè)輸入信號(hào)上升沿的時(shí)間間隔(系統(tǒng)時(shí)鐘個(gè)數(shù))unsignedlongGetEdgePeriod(void){unsignedlongulFirstEdgeTime; //第一個(gè)上升沿到達(dá)時(shí)TimerlA的計(jì)數(shù)值unsignedlongulSecondEdgeTime; //第二個(gè)上升沿到達(dá)時(shí)Timer1A的計(jì)數(shù)值//配置Timer1A為輸入定時(shí)模式TimerConfigure(TiMERl_BASE,TiMER_CFG_l6_BiT_PAiR|TiMER_CFG_A_CAP_TiME);TimerLoadSet(TIMER1_BASE,TIMER_A,0xffff);//裝載值設(shè)為0xffffTimerEnable(TIMER1_BASE,TIMER_A);//使能Timer1AUARTprintf("ll\r");//當(dāng)?shù)谝粋€(gè)輸入事件到達(dá)時(shí),將計(jì)數(shù)器計(jì)數(shù)值存入ulFirstEdgeTimewhile(!(TimerintStatus(TiMERl_BASE,false)&TiMER_CAPA_EVENT));UARTprintf("22\r");ulFirstEdgeTime=TimerValueGet(TiMERl_BASE,TiMER_A);g_ulTimer1ATimeoutCount二0; //清零g_ulTimer1ATimeoutCount//清除溢出以及輸入捕捉中斷標(biāo)志位TimerintClear(TiMERl_BASE,TiMER_CAPA_EVENT|TiMER_TiMA_TiMEOUT);//等待下一個(gè)輸入事件到達(dá)while(!(TimerintStatus(TiMERl_BASE,false)&TiMER_CAPA_EVENT)){//如果Timer1A產(chǎn)生溢出,g_ulTimer1ATimeoutCount++并清除Timer1A溢出標(biāo)志位if((TimerintStatus(TiMERl_BASE,false)&TiMER_TiMA_TiMEOUT)){TimerintClear(TiMERl_BASE,TiMER_TiMA_TiMEOUT);g_ulTimerlATimeoutCount++;}}//禁能Timer1ATimerDisable(TiMERl_BASE,TiMER_A);//記錄第二個(gè)時(shí)間發(fā)生時(shí)間ulSecondEdgeTime=TimerValueGet(TiMERl_BASE,TiMER_A);TimerIntClear(TIMER1_BASE,TIMER_CAPA_EVENT);//返回兩個(gè)輸入事件的時(shí)間間隔(系統(tǒng)時(shí)鐘數(shù)目)return(g_ulTimer1ATimeoutCount*65536+ulFirstEdgeTime-ulSecondEdgeTime);}//測(cè)量輸入信號(hào)頻率//unsignedlong*Int指向頻率整數(shù)部分的指針//unsignedlong*Frac指向頻率小數(shù)部分的指針voidFreqMeasure(unsignedlong*Int,unsignedlong*Frac){unsignedlongulCount;ulCount=GetEdgeCount(200);//測(cè)量200ms內(nèi)輸入的事件數(shù)if(ulCount<2000)//如果輸入事件數(shù)小于2000個(gè),則測(cè)量?jī)蓚€(gè)輸入事件的時(shí)間間隔{ulCount=GetEdgePeriod();//記錄時(shí)間間隔*Int=(SysCtlClockGet()*1000.0)/ulCount/1000;//計(jì)算頻率(低頻)*Frac=(unsignedlong)((SysCtlClockGet()*1000.0)/ulCount)%1;}else{*Int=ulCount*5;//計(jì)算頻率(高頻)*Frac=0;}}檔位切換程序#include"inc/hw_types.h"#include"driverlib/debug.h"#include"driverlib/sysctl.h"#include"drivers/display96x16x1.h"#include"driverlib/gpio.h"#include"driverlib/pin_map.h"#include"inc/hw_memmap.h"#include"inc/hw_gpio.h"#include"utils/uartstdio.h"#include"lcd12864s.h"#include"driverlib/timer.h"#include"inc/hw_ints.h"#include"driverlib/interrupt.h"#include"stdio.h"#include"frequence.h"#include"math.h"#include"TLV5616DA.h"http:/// /^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js^js//#defineKEY_PERIPHSYSCTL_PERIPH_GPIOC#defineKEY_PORTGPIO_PORTC_BASE#defineKEY_PINGPIO_PIN_4#defineR3300#defineR2300#defineR1300#defineR0300//防止jtag接口死鎖voidjtagWait(){SysCtlPeripheralEnable(KEY_PERIPH);GPIOPinTypeGPIOInput(KEY_PORT,KEY_PIN);if(GPIOPinRead(KEY_PORT,KEY_PIN)==0x00){while(1);}SysCtlPeripheralDisable(KEY_PERIPH);}unsignedlongTheSysClock=12000000UL;unsignedlongInt;//指向頻率整數(shù)部分的指針unsignedlongFrac;//指向頻率小數(shù)部分的指針doublef=0; //測(cè)量頻率doublec_val=0.0;//測(cè)量電容值intflag=0; //檔位標(biāo)志doublecal(doublefre,intfla){/*計(jì)算電容的函數(shù)*/doublec;if(fla==3){c=l/(2*fre*log(2)*(1000000+R3)); //計(jì)算公式c=/(2*f*R*ln2)//此處為1M電阻c=c*1000000000000; //換算成pf級(jí)Show_LCD12864(0x98,〃檔位為3");}if(fla==2){c=1/(2*fre*(49600+R2)*log(2)); //此處為50k電阻c=c*1000000000; //換算成nf級(jí)Show_LCD12864(0x98,〃檔位為2〃);}if(fla==1){c=l/(2*fre*(9730+Rl)*log(2)); //此處為lk電阻c=c*1000000000; //換算成nf級(jí)Show_LCD12864(0x98,〃檔位為1");}if(flag==0){c=1/(2*fre*(98.3+R0)*log(2)); //計(jì)算出的單位為mfc=c*100000; //換算成ufShow_LCD12864(0x98,〃檔位為0");}returnc;}voiddisplay(doubleval){ /*串口顯示函數(shù)*/inti;charcval[10];i=val;sprintf(cval,"%d",i);UARTprintf(cval);WriteCmd_LCD12864s(0x01); //清除顯示SysCtlDelay(10*(TheSysClock/3000));Show_LCD12864(0x90,cval);i=(val-i)*100;sprintf(cval,".%d",i);UARTprintf(cval);Show_LCD12864(0x92,cval);if(flag==3){UARTprintf("pf\r");TOC\o"1-5"\h\zShow_LCD12864(0x93,"pf"); }if(flag==1|flag==2){UARTprintf("nf\r");Show_LCD12864(0x93,"nf"); }if(flag==0){UARTprintf("uf\r");Show_LCD12864(0x93,"uf"); }}

voidchange1(doublef1){/**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X* //if(flag==2&&f1<15){//使用2通道GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0Xff);//A=1,B=0GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0X00);flag=1;}if(flag==2&&f1>350){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0|GPIO_PIN_1,0Xff);//A=1,B=1flag=3;}if(flag==3&&f1<17){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0X00);//A=0,B=1GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0Xff);flag=2;}if(flag==1&&f1>115){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0X00);//A=0,B=1GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0Xff);flag=2;}if(flag==1&&f1<50){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0|GPIO_PIN_1,0X00);//使用0通道flag=0;}if(flag==0&&f1>180){//使用1通道//A=0,B=1擋函GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0Xff);//A=0,B=1擋函GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0X00);flag=1;}}voidchange2(doublef1){/*換*X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**X**i**i**i**i**i**i**i**i**i**i**i**i**i**i**i**i**i**i**i**i*//if(flag==2&&f1<15){//使用2通道GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0Xff);//A=1,B=0GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0X00);flag=1;if(flag==2&&f1>350){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0|GPIO_PIN_1,0Xff);//A=1,B=1flag=3;}if(flag==3&&f1<17){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0X00);//A=0,B=1GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0Xff);flag=2;}if(flag==1&&f1>115){GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0,0X00);//A=0,B=1GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_1,0Xff);flag=2;}}doubleensure(doublec,doublef){/*修正誤差函數(shù)*///change(f);if(flag==0){if(f>9000)c=c-24;if(f>1400&&f<=9000)c=c-30;}returnc;}voidGPIOinit(void){GPIOPadConfigSet(GPIO_PORTC_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);//設(shè)置PC4為2MA,上拉輸入GPIODirModeSet(GPIO_PORTC_BASE,GPI0_PIN_4,GPI0_DIR_M0DE_IN);//設(shè)置GPIO輸入模式GPIOIntTypeSet(GPIO_PORTC_BASE,GPI0_PIN_4,GPIO_LOW_LEVEL);//設(shè)置GPIO中斷GPIOPinIntEnable(GPIO_PORTC_BASE,GPIO_PIN_4);//使能KEY所在管腳的中斷IntEnable(

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 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ì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論