基于單片機(jī)的電子秤設(shè)計(jì) 畢業(yè)設(shè)計(jì)_第1頁
基于單片機(jī)的電子秤設(shè)計(jì) 畢業(yè)設(shè)計(jì)_第2頁
基于單片機(jī)的電子秤設(shè)計(jì) 畢業(yè)設(shè)計(jì)_第3頁
基于單片機(jī)的電子秤設(shè)計(jì) 畢業(yè)設(shè)計(jì)_第4頁
基于單片機(jī)的電子秤設(shè)計(jì) 畢業(yè)設(shè)計(jì)_第5頁
已閱讀5頁,還剩65頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

基單的子計(jì)畢設(shè)論文題目:基單片機(jī)電子秤設(shè)計(jì)基于單片機(jī)的電子秤計(jì)姓名:張延海

專業(yè):電氣工程及其自動(dòng)化

指導(dǎo)老師:馬惠蘭要

衡是們常活不缺的要器,器發(fā)是系計(jì)生鍵一。衡的用遍到民濟(jì)各領(lǐng),并得顯的濟(jì)益近來隨電科的速展桿已來難滿人們?nèi)丈?,電秤?yīng)也漸來重本重介了于單機(jī)簡電秤一基構(gòu)原和能本計(jì)AT89C51單機(jī)控芯附傳器路調(diào)放電,模數(shù)換路盤路顯電等然利編語進(jìn)編實(shí),并4x4矩鍵實(shí)簡的作,后晶示實(shí)此統(tǒng)以現(xiàn)本稱顯,價(jià)入及金計(jì)。上物即感受力,當(dāng)入價(jià),統(tǒng)自計(jì)貨價(jià)。電秤單機(jī)AT89C51LCDanindispensableinstrumentourlife.ofhasakeyfactorinlife.TheapplicationapparatushasalreadyspreadtoeconomyinallhavegotInrecentwiththerapiddevelopmenttechnology,thehasdifficulttomeetlife,applicationofelectronicscalesmoreandmoremainlysomeofbasicprincipleandfunctionThisdesignAT89C51controlchipAttachedwithsensor,regulatecircuit,conversioncircuit,circuitdisplaycircuit.thelanguageand4x4matrixkeyboardforATlast,weLCDmonitortotheresult.systemthebasicweighingdisplaying,priceinput,amount.Whentheelectronicscales(thestressed),ifyouintheunitprice,systemwillcalculatetotalofthe

Electronic,Single-chipmicrocomputer,AT89C51,LCD目

錄第1章論······························01.重和衡器技的發(fā)展·······················1.2選題背景和意··························1.3設(shè)計(jì)目的·····························1.4設(shè)計(jì)要求·····························1.5電子秤簡介····························

0111.5.1子基本構(gòu)························1.5.2電子的工作理·······················2第2章

系統(tǒng)方的設(shè)計(jì)·························32.1系統(tǒng)整體設(shè)計(jì)···························32.2各模塊設(shè)計(jì)與擇·························32.2.12.2.22.2.32.2.42.2.52.2.6

控器部分·························傳器模塊·························4調(diào)放大?!ぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁぁ?/轉(zhuǎn)換模························7鍵模塊··························9顯模塊···························第3章

電子秤統(tǒng)設(shè)計(jì)·························123.1硬件系統(tǒng)設(shè)計(jì)···························123.1.1制123.1.2傳感···························123.1.3A/D轉(zhuǎn)··························133.1.4鍵盤····························143.1.5顯示···························3.2軟件系統(tǒng)設(shè)計(jì)···························163.2.13.2.23.2.33.2.4第4章

單顯示程設(shè)計(jì)16重顯示程設(shè)計(jì)·······················金顯示程設(shè)計(jì)·······················運(yùn)模塊···························19系統(tǒng)調(diào)與仿真·························204.14.24.34.4

系統(tǒng)軟調(diào)試···························20仿真·······························21仿真程·····························21調(diào)試過中遇到的問·······················21結(jié)

論·································23參考文································25附致

錄································26謝································36第1章緒論1.1重和衡技術(shù)的發(fā)展稱作計(jì)的種段在計(jì)生各領(lǐng)被泛應(yīng)而器發(fā)水大度影了行的代水和會(huì)經(jīng)效。人由初等交,漸展利簡的來為量標(biāo)并開普。著會(huì)發(fā),統(tǒng)機(jī)秤越越以足們需。在子術(shù)速展帶下電秤運(yùn)生大方了們需。50年代中電技的入動(dòng)衡制業(yè)發(fā)。60年代初,機(jī)結(jié)式子器步成經(jīng)多的斷進(jìn)完,國子衡從初機(jī)結(jié)型展現(xiàn)的電型數(shù)智型我電衡器技裝和測驗(yàn)段基達(dá)國90代期水,子器造術(shù)應(yīng)得了的展??傔^,子重術(shù)靜稱向動(dòng)稱發(fā);計(jì)方從擬量數(shù)測發(fā)測特從參測量多數(shù)量展,特別對速重動(dòng)稱的究應(yīng)。過析些電衡產(chǎn)的展況國外場需電衡總發(fā)趨是型、塊、成、能;術(shù)能趨于率、確度、定高可性;能趨于重量控信和控信息重“能”能其用能向綜性組性衡是家法計(jì)器,國民、防設(shè)科研、外易可少計(jì)量備衡產(chǎn)技水的低將接響行業(yè)現(xiàn)化平社會(huì)濟(jì)益提。21紀(jì)電電技飛發(fā),得子品變十豐,人們來極的便。作為們活不缺的部電秤發(fā)也0十重。類富功多的子為們省時(shí),高工效率1.2

選題背景和義電秤日生中用電衡,泛用大超、場物流送心但在些遠(yuǎn)區(qū)電秤難普,統(tǒng)杠機(jī)秤仍據(jù)主地。前場使的量具或是構(gòu)雜或運(yùn)行可,成高精穩(wěn)性好,調(diào)時(shí)長,損多維困,裝容大,源耗,生產(chǎn)成高各因?qū)枰挥杏弥档淖酉?,能足常求克上諸缺,能好普,具十重的實(shí)義1.3

設(shè)計(jì)目的通所知和關(guān)料完基單機(jī)簡的子的計(jì)掌握單機(jī)核的制路LCD顯示術(shù)并過計(jì)了電秤基工原,將論識現(xiàn)實(shí)問相合提自對學(xué)識應(yīng)能。1.4

設(shè)計(jì)要求有物CD顯示量開時(shí)單”示“P:0當(dāng)入價(jià),片自將價(jià)重兩數(shù)進(jìn)乘運(yùn),果示“”里。當(dāng)下清”時(shí)單自清,以新入當(dāng)果出(結(jié)大SUM將示后次價(jià)入前值11.5

電子秤簡介1.5.1電秤本構(gòu)電秤利物的力用確物質(zhì)量(量的量器,也可來定質(zhì)相的它大、數(shù)或性不根什原制成電秤由下部組:承、力位統(tǒng)稱傳器測顯和據(jù)出載測裝1.5.2

電秤工原當(dāng)稱體置秤的盤時(shí)重便過盤遞稱傳器傳器之生-效將體重轉(zhuǎn)成被物重成定數(shù)系般正關(guān)電號(電或流此號調(diào)放電進(jìn)放濾后由/數(shù)A/D器行換數(shù)信再到C行理CPU根據(jù)收的據(jù)由示來再據(jù)盤入容行要判、析運(yùn)。算果到存器并CPU出令從存器讀送顯器示2第2

系統(tǒng)方案的設(shè)計(jì)2.1

系統(tǒng)整體設(shè)按本計(jì)能要,統(tǒng):感模、理大塊A/D轉(zhuǎn)模、盤塊現(xiàn)模組,統(tǒng)整設(shè)框如2-1所:圖2-1系統(tǒng)整體圖測部是用重感去測力號并得的弱電號本計(jì)電信)處電(設(shè)為理大路處后送給A/D換,將模量化數(shù)量出。控制部接來轉(zhuǎn)換器出數(shù)信,過算將字號換物的際量號并將存到儲(chǔ)元。制還以過擴(kuò)控,描盤對個(gè)統(tǒng)行制。數(shù)據(jù)示分據(jù)要現(xiàn)示能如價(jià)總額。2.2

各模塊設(shè)計(jì)選擇32.2.1

控器分本計(jì)于求須用片作系的控器,且單機(jī)為控器設(shè),以易將算技和量制術(shù)合一,組新的需改軟程就以新代的“智化量制統(tǒng)。4K字節(jié)FPEROM—FlashandErasableReadOnlyMemory的電、性8位微理,于多能8位和爍儲(chǔ)組在個(gè)片,ATMELAT89C51是一高微制。且AT89C51是一比應(yīng)比較泛單機(jī)AT89C51單片機(jī)引腳結(jié)圖圖2-2示紹2.2.2

圖-2AT89C51單片機(jī)引腳構(gòu)單機(jī)主特及引功特已學(xué)過在里再傳器塊4在計(jì),感是個(gè)分要元此傳器選也的特的要,僅注其程參數(shù),還考到其配的種路的計(jì)難程和計(jì)價(jià)等.設(shè)采應(yīng)片橋量路為傳器塊由變電R1和另外3個(gè)電R2、R4構(gòu)成橋電圖圖示圖2-3應(yīng)變片電橋測量理圖電輸為當(dāng),V0=0,橋于衡態(tài)當(dāng)變受后電差動(dòng)作R1=R-△△R,R4=R-△R,應(yīng)片傳器如特:(1應(yīng)和量圍,變可成種械傳器(2分率靈度,度高5(3結(jié)小適性,應(yīng)于種殊合頻響好(4經(jīng)性,用便2.2.3

調(diào)放模經(jīng)傳器感件換輸?shù)奶柊闫降徒?jīng)電變后的號難直用顯、錄控或號換因需對感的輸信進(jìn)處,要用理大路對感輸?shù)淖?,電平號行理才做一的用本?jì)I計(jì)的理大路圖2-4示圖調(diào)理放模塊本路有下點(diǎn)1.

前采運(yùn)兩組并型動(dòng)大在算大器理的況,并型動(dòng)大的入抗無大共抑比為窮。62阻耦電放并型動(dòng)大構(gòu)的級大和放大構(gòu)的級大之,樣僅后儀放器高增還高電的模制。而由前放器輸阻較,又用模動(dòng)術(shù),避免阻耦電中阻、容件數(shù)匹導(dǎo)共干轉(zhuǎn)成模擾況生3.

后電采經(jīng)的器大,雙信轉(zhuǎn)為端號出由于阻容耦合路隔作后的器大可做很的益進(jìn)得很的模制。2.2.4

模/數(shù)換塊本計(jì)用ADC0832/轉(zhuǎn)器放后信轉(zhuǎn)為字送單片,后LCD液晶顯器示來即所物的量。是美國半體司產(chǎn)一8位辨、通道A/D轉(zhuǎn)換芯。于體小兼性,價(jià)高深單機(jī)好及業(yè)迎其前經(jīng)有高普率ADC0832的腳構(gòu)圖2所示圖-5ADC0832引腳結(jié)構(gòu)特:7·8分率·雙道A/D轉(zhuǎn)換·輸輸電與TTL/CMOS兼;·5V源電輸電在之間·工頻為轉(zhuǎn)時(shí)為S·一功僅15mW·8P14P雙直多封;·商級片寬to工級片寬to芯接說:·CS_片使,電芯使?!H0模輸通或?yàn)槭褂谩H1模輸通或?yàn)槭褂谩ND芯參0電(·DI數(shù)信輸,擇道制·DO數(shù)信輸,換據(jù)出·CLK芯時(shí)輸。·電輸及考壓入復(fù)是位分率A/D換片其高辨達(dá),能應(yīng)般模量換求其部源入?yún)㈦姷挠檬沟闷k娸斣?~5V間。片換間32S具雙據(jù)出作數(shù)校,減數(shù)誤,換度,且定能強(qiáng)獨(dú)的片能入使器掛和理控變更方。8通據(jù)入,以易實(shí)通功的擇2.2.5

鍵模方一采獨(dú)式鍵為入塊這鍵的件較易現(xiàn)直用口構(gòu)成個(gè)鍵路接電配靈,鍵別軟結(jié)簡但一按就用個(gè)口非常浪單機(jī)I/O口資。其理如2-6示圖獨(dú)立功能按方二采陣鍵作輸模。采用矩式盤為入電,特:路軟稍雜但比下當(dāng)鍵越時(shí)節(jié)I/O,約資。種盤硬結(jié)簡,且種盤編方比成。原圖圖2-7示圖2-74x4矩陣式鍵盤原理由本計(jì)盤入置于算清等按較,是用立鍵按麻,軟設(shè)增負(fù);是用陣按,可節(jié)9約I/O資,入值方,且操界更人化通對,故用案作系的入塊2.2.6

顯模方一采用LED碼靜顯。用碼串靜顯,種示式口編容且理單雖其示度,是果示器位較,要加存,而態(tài)示用I/O線多CPU開較。圖所。圖4位碼管靜顯示方二采用LED碼動(dòng)顯。用碼動(dòng)顯,示度及態(tài)示但電簡,合顯位較的況如圖2-9所示圖2-94位數(shù)碼管的態(tài)顯示方三采LM016L液顯。為個(gè)熟產(chǎn),用簡,式定便移到種型程,是注結(jié)合CD身時(shí)圖完初化序又其功、積、示容富超輕10巧可調(diào)其光度這顯方接,程然些煩但理較便占的口源也多在算運(yùn)中需示數(shù)、號多通對,據(jù)方的點(diǎn)故用M016L晶示顯輸。11第3章

電子秤系設(shè)計(jì)3.1

硬件系統(tǒng)設(shè)3.1.1控器本計(jì)用片作控器其小統(tǒng)圖3-1示圖3-1

單片機(jī)小系統(tǒng)本計(jì)片的件配P2:為入,鍵連,現(xiàn)據(jù)輸;P1:為出,制LCD晶示顯數(shù)的果口:作控端,制晶示顯輸數(shù)。3.1.2

傳器本計(jì)用公的MPX4250系傳器MPX4250感器生信可直送轉(zhuǎn)器行/數(shù)轉(zhuǎn)將收的力號電信送A/D轉(zhuǎn)器模量入道CH0,經(jīng)處的號可送單機(jī)。MPX4250A/D換的接圖所示12圖3-23.1.3A/D換

傳感器口線路本計(jì)ADC0832數(shù)輸口單機(jī)串輸口P3.1時(shí)輸接片的部斷0腳,常況ADC0832與片的口應(yīng)4條數(shù)線即CLK、DO、DI。但由于DO與DI端在信并同有,且單機(jī)接是向,以計(jì)路可將DODI聯(lián)一數(shù)線使。ADC0832未工作,入應(yīng)為電,時(shí)片用CLK和DO/DI的平任。要行A/D轉(zhuǎn)時(shí)須將CS使端于電,且持電直轉(zhuǎn)完結(jié)。與片的腳接圖3-3所示13圖3-3A/D轉(zhuǎn)換與單片機(jī)接電路3.1.4

鍵本設(shè)所的X4矩陣鍵盤用條I/O線為線條I/O線為列組。用種盤構(gòu)夠高片系中I/O口利率本設(shè)矩鍵與片的1相作輸。鍵包數(shù)鍵(9)和清零鍵。次計(jì)算鍵布及單機(jī)口路圖所。圖仿真中矩陣鍵按鍵布局實(shí)實(shí)的能圖示14圖3-5實(shí)際鍵功能矩陣鍵布局比由本計(jì)鍵功比簡,4x4陣盤有充利,要考到真程布方而用。實(shí)應(yīng)中若能單為了省料以當(dāng)少個(gè)鍵電秤用4x4陣盤其功還待發(fā)3.1.5

顯器由液顯器以段示鑒設(shè)要顯三數(shù)“量“價(jià)金,以設(shè)采液顯器口為晶示數(shù)端口,P3.5-P3.7作其制口控LCD晶示顯輸數(shù)。樣實(shí)了的又濟(jì)便與單機(jī)接電如3-6所示圖3-6LCD接口線路153.2

軟件系統(tǒng)設(shè)程設(shè)比復(fù),把雜工條化就有應(yīng)步和方。致概為下點(diǎn)分系控要,后定法并復(fù)的題行體分析找合的算法適的據(jù)構(gòu)從確編程的驟由法流圖畫序程以算和題驟步體,從減出。編程:據(jù)序程所示算和驟,選用適的令列來即寫序編的想法是構(gòu)程設(shè)法構(gòu)程設(shè)是所到控結(jié)類序適的制尤是制向句指的用控了程的雜,使序上下順與行程持致,程更易,少邏錯(cuò),且于改調(diào)。3.2.1價(jià)示序計(jì)開啟時(shí)示上價(jià)塊示“P:需輸價(jià)方顯示系中接是列按鍵,其“0-9為字;“”為能(零,數(shù)鍵下將應(yīng)數(shù)送數(shù)緩區(qū)功鍵按則行應(yīng)程;終行算,合果送結(jié)緩區(qū)并在LCD晶示上示來其序程如-7示16圖

單價(jià)顯程序流程圖3.2.2

重顯程設(shè)生信送給ADC0832進(jìn)行模轉(zhuǎn)然通單機(jī)串輸口外中接,制示在LCD晶示上其序程如3-8示17圖3

稱程流圖3.2.3

金顯程設(shè)對金顯“SUM其理先測否重即感是受,然再斷價(jià)入況當(dāng)個(gè)示不空,兩數(shù)傳單機(jī)進(jìn)乘運(yùn),果給示沖,由LCD液晶顯器示來其序流圖圖-9示18圖-9

計(jì)價(jià)程流程圖3.2.4

運(yùn)模本設(shè)應(yīng)了法算其算序程如3-10所:圖3-10

運(yùn)算模程序流程圖19第4章

系統(tǒng)調(diào)試仿真4.1

系統(tǒng)軟件調(diào)軟調(diào)方與選的件編的序關(guān)。由于次計(jì)用塊程設(shè),先逐模進(jìn)調(diào),后行件能試調(diào)模塊序,符現(xiàn)環(huán),定入條和口態(tài)各序塊試完后應(yīng)個(gè)能塊合來行序合試全軟調(diào)完后應(yīng)復(fù)行,察統(tǒng)穩(wěn)性系的能否到計(jì)要在件調(diào)過中,出的誤行真分和改能好達(dá)既的計(jì)果本計(jì)調(diào)是用eiluVision4件行序編調(diào),沒錯(cuò)后生一擴(kuò)名.hex十進(jìn)文,調(diào)試結(jié)如-1示圖4-1

程序調(diào)圖如所,調(diào)結(jié)沒錯(cuò)時(shí)才以文加入片進(jìn)仿真204.2

仿真打P真件將建的真塊開然鼠左雙單機(jī)在出對框加調(diào)程時(shí)成的“”文件然運(yùn),即實(shí)簡的子。統(tǒng)體真構(gòu)及真果圖-2圖4所:圖4-2

系統(tǒng)仿全圖圖4-3

仿真結(jié)圖4.3

仿真程序4.4

見錄調(diào)試過程中到的問題在計(jì)程,先找到適信輸模,傳器因21沒輸信仿無談通查大的感資再”元庫選合的號經(jīng)篩,現(xiàn)MPX4250比適本計(jì)它時(shí)以變?nèi)胄牛ㄖ刈?。MPX4250一硅導(dǎo)壓傳器輸?shù)哪P吞柺袘?yīng)也較泛比適本設(shè)。次是A/D換的型也到困,設(shè)之,選主要因我在堂學(xué)過ADC0809引功和性對比了。但在件試程,好程無使LCD液晶顯器傳器信顯出,不進(jìn)模轉(zhuǎn)。先想的程出問,是過檢發(fā),序正的然我仔的查ADC0809單機(jī)引連,然能示據(jù)有學(xué)議換個(gè)/D換,是嘗了和ADC0832,最發(fā)ADC0832能好滿本設(shè)的的還一問就在寫法算序,就是LCD顯函SUM時(shí)在數(shù)拆問上到麻如將個(gè)位拆,在一上整再求,者先余整,這算上惑我久我閱一資料但然能決后我去精C言學(xué)教經(jīng)一討和研,于這問弄白。于人力限本所計(jì)電秤功單,市上際用電秤比能夠善,不之還見諒以幾問是計(jì)程比突的題,還一其小題,在老和學(xué)幫下迎而了在不一述22結(jié)

論本設(shè)使了了子的些本工原也我白理與際差還很的比在真?zhèn)髌鬟x上,現(xiàn)中使的電秤傳器須過號大能行模/數(shù)轉(zhuǎn)換。計(jì)應(yīng)了件單機(jī)片塊合件序助軟調(diào)實(shí)顯功在計(jì)程由所知的缺導(dǎo)設(shè)無快的成單機(jī)類多,功能種樣本計(jì)用片,因一我對系的單機(jī)較悉而51單片機(jī)功比齊,場用泛編語言是用們學(xué)的C語編方由言能大,便于?;l(fā)所庫數(shù)富,編的序于植諸優(yōu)使成單機(jī)應(yīng)系開最速效程設(shè)語。采言充體了構(gòu)的想當(dāng)個(gè)塊完時(shí)將功加一就成整的計(jì)但是僅行單疊無真的現(xiàn)件硬的一而還要斷地行試此設(shè)過中到許困,本因自所知不全,對識掌也夠?qū)嵆鰡柡笪蚁扰フ翌}所,然用己掌的識試分問盡能通查資來立決題但個(gè)能有,些題在決了,去教學(xué)老師特是在C語言的程面非感老和學(xué)的助在分問解問的程不鞏了前學(xué)知,通過閱料掌了些的識使個(gè)能得了高專水也了步這設(shè)是學(xué)年一總,僅對己學(xué)業(yè)識考核也煉將學(xué)業(yè)論識用實(shí)問中能。過次23設(shè),驗(yàn)我理應(yīng)于踐獨(dú)解問的力也強(qiáng)我老同一協(xié)的力更我識自在識面在不,明了后學(xué)方,為來的業(yè)前了堅(jiān)的礎(chǔ)我會(huì)好惜次計(jì)程所歷一,將我生一寶的財(cái)。24[1][2][3][4][5][6][7][8][9]

參考文獻(xiàn)李朝青《單片機(jī)理及接技術(shù)》,北京天航空學(xué)出版社,2005第譚浩強(qiáng)《C程序計(jì)》,華大出版社2005第3賈石峰《傳感器原理傳感器技術(shù),機(jī)械工出版社,李移倫《單片機(jī)原理應(yīng)用,南大學(xué)出版于軍勝《顯示器技術(shù)》國防工業(yè)出社,2010.7楊居義《單片機(jī)程設(shè)計(jì)導(dǎo)》,清華大學(xué)出版社,2009樓然苗51列單片設(shè)計(jì)實(shí)例北京航天空出版,2003.3李全利遲榮強(qiáng)單片機(jī)原理及接口術(shù)M]北京:教育出版2004.1張毅剛單片機(jī)應(yīng)用設(shè)計(jì),哈工大版2004二版25附

錄程清#include<reg51.h>#include<math.h>#include<intrins.h>#include<absacc.h>#defineunsigned#defineunsignedint//*********義變量*******************sbitlcden=P3^7;//LCD能信號sbitlcdrs=P3^5;//LCD據(jù)/命選擇號sbit=P3^3;sbitCLK=P3^2;sbitDIO=P3^1;uchartab_key[50];ucharlongintmoney,money1;uchartab[]="0123456789";uchartab0[]="p:";uchartab1[]="w:";uchartab2[]="SUM:";ucharn=0,temp,key;unsignedCH=0x02;//*********時(shí)函數(shù)始**************voiddelay(uintk){uintfor(i=k;i>0;i--)for(j=50;j>0;j--);}unsignedADconv(void){uchari,dat1=0,dat2=0;CS=0;=0;=1;_nop_();_nop_();26CLK1;_nop_();_nop_();CLK0;DIO1;_nop_();_nop_();CLK1;_nop_();_nop_();CLK0;DIO1;_nop_();_nop_();CLK1;DIO1;_nop_();_nop_();CLK0;DIO1;_nop_();_nop_();for(i=0;i<8;i++){CLK1;_nop_();_nop_();CLK0;_nop_();_nop_();dat1=dat11|DIO;}/*for(i=0;i<8;i++){dat2=dat2((uchar)(DIO)<<i);CLK1;_nop_();_nop_();CLK0;_nop_();_nop_();}*/CS=1;//return==dat2)?dat1:0;return;}//**********命令函數(shù)開***********voidwrite_com(ucharcom){lcdrs=0;//電平寫令P1=com;//寫命令delay(3);//時(shí)約lcden=1;//LCD使能端高電平delay(5);//時(shí)約lcden=0;//LCD使能端低電平}//**********數(shù)據(jù)函數(shù)開************voidwrite_data(uchardat){lcdrs=1;//電平寫據(jù)P1=dat;//入命令delay(3);//時(shí)約3mslcden=1;//LCD能端置電平delay(5);//時(shí)約5mslcden=0;//LCD能端拉電平}//**********LCD初始函數(shù)開*********27voidlcd_init(){lcden=0;write_com(0x38);//置顯示式:16X2,5X7,8數(shù)據(jù)接write_com(0x0c);//顯示顯示光,光標(biāo)閃爍write_com(0x06);//寫一個(gè)符后,地址針及光加一,且光標(biāo)一整屏示不移write_com(0x80);//設(shè)置光指針}//******鍵盤功能分配數(shù)群開*voidkey_manage1(){tab_key[n]=0;if(n<4)n++;}voidkey_manage2(){tab_key[n]=1;if(n<4)n++;}voidkey_manage3(){tab_key[n]=2;if(n<4)n++;}voidkey_manage4(){tab_key[n]=3;if(n<4)n++;}voidkey_manage5(){tab_key[n]=4;if(n<4)n++;}voidkey_manage6()28{tab_key[n]=5;if(n<4)n++;}voidkey_manage7(){tab_key[n]=6;if(n<4)n++;}voidkey_manage8(){tab_key[n]=7;if(n<4)n++;}voidkey_manage9(){tab_key[n]=8;if(n<3)n++;}voidkey_manage10(){tab_key[n]=9;if(n<4)n++;}voidkey_manage11(){ucharn=0;tab_key[50]=0;money=0;money1=0;write_com(0x01);write_com(0x0c);write_com(0x80);for(i=0;i<2;i++){write_data(tab0[i]);}write_data(0+'0');write_com(0x89);29for(i=0;i<2;i++){write_data(tab1[i]);}write_data(0+'0');write_com(0xc0);for(i=0;i<4;i++){write_data(tab2[i]);}write_data(0+'0');write_com(0xcf);write_data('$');}//**********盤掃描函數(shù)始****voidkey_scan(){//**********描第一行*********P2=0xfe;temp=P2;temp=temp&0xf0;if(temp!=0xf0){delay(100);if(temp!=0xf0){temp=P2;switch(temp){casekey_manage8();break;casekey_manage9();break;casekey_manage10();break;casebreak;}while(temp!=0xf0){temp=P2;30temp=temp&0xf0;}}}//**********描第二行*********P2=0xfd;temp=P2;temp=temp&0xf0;if(temp!=0xf0){delay(100);if(temp!=0xf0){temp=P2;switch(temp){casekey_manage5();break;casekey_manage6();break;casekey_manage7();break;casebreak;}while(temp!=0xf0){temp=P2;temp=temp&0xf0;}}}//**********描第三行*********P2=0xfb;temp=P2;temp=temp&0xf0;if(temp!=0xf0){delay(100);if(temp!=0xf0){31temp=P2;switch(temp){casekey_manage2();break;casekey_manage3();break;casekey_manage4();break;casebreak;}while(temp!=0xf0){temp=P2;temp=temp&0xf0;}}}//**********描第四行*********P2=0xf7;temp=P2;temp=temp&0xf0;if(temp!=0xf0){delay(100);if(temp!=0xf0){temp=P2;switch(temp){casekey_manage11();break;casekey_manage1();break;casebreak;casebreak;32}while(temp!=0xf0){temp=P2;temp=temp&0xf0;}}}}//**********LCD顯示數(shù)開始***********voidlcd_disp(){ucharif(n==1)money1=tab_key[0];if(n==2)money1=tab_key[0]*10+tab_key[1];if(n==3)money1=tab_key[0]*100+tab_key[1]*10+tab_key[2];if(n==4)money1=tab_key[0]*1000+tab_key[1]*100+tab_key[2]*10+tab_key[3];weight=ADconv()*500.0/255+1;money=money1*weight;write_com(0x82);for(i=0;i<n;i++){a=tab_key[i];write_data(tab[a]);}write_com(0x8c);write_data(weight/100+'0');write_data(weight%100/10+'0');write_data(weight

溫馨提示

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

評論

0/150

提交評論