【正文】
s amount still want have another.The AT89C52 is a lowpower, highperformance CMOS 8bit microputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s highdensity nonvolatile memory technology and is patible with the industrystandard MCS51 instruction set and pin out. The onchip Flash allows the program memory to be reprogrammed insystem or by a conventional nonvolatile memory programmer. By bining a versatile 8bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microputer which provides a highlyflexible and costeffective solution to many embedded control applications.Function characteristicThe AT89C52 provides the。s, and the mon model number factory price drop into to USD 1, tallest carry of model number also only USD contemporary and single slice machine system has already no longer developed and used just under the naked machine environment, the in great quantities appropriative builtin operate system is applied extensively in the whole serieseses of the single slice is on board. But be the high level of handheld PC and cellular phone core processing single slice the machine even can use appropriative Windows and the Linux operate system directly.Single slice the machine ratio appropriation processor is the most suitable to match to apply in the builtin system, so it got the most applications. In fact the single slice machine is an amount the most calculators are in the world. The modern mankind are living medium use of assemble in almost each electronics and machine product have a single slice machine. All have 12 single slice machine in the puter accessories such as cellular phone, telephone, calculator, home appliances, electronics toy, handheld PC and mouse etc. And personal puter in would also capable number not a few single slice the machine be working. Provide with more than 40 departments a single slice machine generally on the car, plicated industry39。s, the single slice machine technique got a huge exaltation. Along with the extensive application of INTEL i 960 series especially later ARM series, the 32 single slice machine replaces 16 single slice the high level position of the machine quickly, and gets into an essential market. And traditional of 8 single slice the function of the machine also got to fly to raise soon, handling an ability to pare with to raise few a hundredfold in 8039。53附 錄 1單相數(shù)字電度表硬件原理圖附 錄 2 單相數(shù)字電度表PCB制板圖附 錄 3PCB3D視圖外文資料翻譯DescriptionThe single slice machine is also called tiny controller, is because it was used in the industry to control realm at the earliest stage. Single slice machine from inside chip have CPU appropriation processor to develop only since then. At the earliest stage of design the principle is to pass to integrate a great deal of peripherals and CPU in a chip, making calculator system smaller, integrating more easily into plicated of but to mention to request a strict control equipments in the middle. The INTEL Z80 is the processor which designed according to this kind of thought at the earliest stage, from now on, single slice the development of the machine and appropriation processor went by different roads then.The single slice of the earlier period all of machines are 8 or them, the INTEL is most successful of 8031, because of in brief dependable but the function was quite good to acquire very big good opinion. Henceforth at 8031 up developed MCS51 series a single slice machine system. According to the single slice of this system machine system is still in the extensive usage till now. Because the industry controls the exaltation of[with] realm request, starting appearing 16 single slice machine, but because sex price wanted to don39。當(dāng)然,限于學(xué)生的水平,設(shè)計(jì)中難免有不足和疏漏之處,歡迎老師們批評(píng)指正。在此我要深深感謝所有曾給予我關(guān)心和支持的老師和同學(xué)們。3. 提高系統(tǒng)的可靠性和抗干擾能力設(shè)計(jì)。對(duì)于今后在本課題基礎(chǔ)上進(jìn)行進(jìn)一步的研究和開發(fā)可以歸納為以下幾點(diǎn):1. 完善硬件功能,對(duì)于硬件的信號(hào)調(diào)理電路以及功能擴(kuò)展電路進(jìn)行設(shè)計(jì)與完善。 通過本設(shè)計(jì)使我學(xué)會(huì)了ADC0832和LCD1602的使用,并對(duì)電流和電壓的數(shù)據(jù)采集電路有了一定的了解,對(duì)C語言有了更進(jìn)一步的了解,但由于資金的限制本設(shè)計(jì)還有很多不足,比如本設(shè)計(jì)沒有使用專業(yè)的電流和電壓數(shù)據(jù)采集模塊,也沒有用內(nèi)部集成電能算法的AD芯片,這就使本設(shè)計(jì)的設(shè)計(jì)精度受到了影響,這些問題還需要再以后的學(xué)習(xí)和工作中得到完善和解決。為了解決錯(cuò)峰分段計(jì)費(fèi)問題本設(shè)計(jì)還編寫電子鐘程序,這就使電度表能在相應(yīng)的時(shí)間進(jìn)行相應(yīng)計(jì)費(fèi)。結(jié) 論本設(shè)計(jì)是基于STC89C52RC的單相數(shù)字電度表的設(shè)計(jì),本電度表能夠?qū)彝ビ秒娺M(jìn)行計(jì)費(fèi),也解決了錯(cuò)峰分段計(jì)費(fèi)問題,以及體現(xiàn)出節(jié)約用電的思想。而本程序在到11個(gè)脈沖時(shí)接收的是最低數(shù)據(jù),剛好相反使數(shù)據(jù)計(jì)算錯(cuò)誤。直到第11個(gè)脈沖時(shí)發(fā)出最低位數(shù)據(jù)DATA0[17],一個(gè)字節(jié)的數(shù)據(jù)輸出完成。 2. 中斷初始化錯(cuò)誤:在起初初始化中斷時(shí),我把TMOD設(shè)了兩次分別問0x01和0x10,這樣的話只能使定時(shí)器1工作,應(yīng)該為0x11才行。從而是錯(cuò)誤一點(diǎn)一點(diǎn)出現(xiàn)再解決,這樣是程序調(diào)試變得簡(jiǎn)單。167。 (7)飛線。 (6)有條件的可以用示波器。 (4)用萬用表檢查是否有虛焊,引腳短路現(xiàn)象。 2. 如果在調(diào)試按功能劃分的器件上出現(xiàn)問題,可以按以下步驟進(jìn)行:(1)檢查原理圖連接是否正確 (2)檢查原理圖與PCB圖是否一致。第5章 系統(tǒng)調(diào)試167。 時(shí)間程序流程圖圖45 時(shí)間程序流程圖每次數(shù)字鐘中斷程序完成10次,代表時(shí)間過了一秒,就需要運(yùn)行時(shí)鐘程序,使秒鐘加一;如果秒鐘為60就代表是一分鐘,這樣分鐘加一秒鐘清零;如果分鐘為60就代表是一小時(shí),這樣小時(shí)加一分鐘清零;如果時(shí)鐘為24就代表一天,這樣時(shí)鐘清零。數(shù)字鐘中斷程序流程圖如44所示。 程序流程圖如43所示:圖42 按鍵程序流程圖圖43 數(shù)據(jù)采集中斷程序流程圖167。 數(shù)據(jù)采集中斷程序流程圖由于本次采集數(shù)據(jù)的頻率是50HZ,根據(jù)奈奎斯特采樣定律選擇采樣頻率為200HZ。程序流程圖如42所示。 由于按鍵有可能在非自愿的情況下被按到,所以按鍵按下后有一個(gè)防抖動(dòng)程序使程序延時(shí)5ms后再判斷鍵盤連接的單片機(jī)管腳是否為低電平,這樣防止鍵盤被意外按下,如果按鍵真的被按下,程序要判斷是那個(gè)鍵被按下;如果調(diào)時(shí)鍵被按下,程序會(huì)計(jì)數(shù)一次并且關(guān)閉中斷使時(shí)間計(jì)數(shù)停止,這時(shí)如果時(shí)鐘鍵被按下,先要運(yùn)行防抖動(dòng)程序,判斷按鍵是否真的按下,要是按下時(shí)鐘加一;如果分鐘鍵被按下,也要先運(yùn)行防抖動(dòng)程序,判斷按鍵是否真的按下,要是按下分鐘加一。 按鍵程序流程圖本設(shè)計(jì)的鍵盤采用的是獨(dú)立式鍵盤鏈接,一端接單片機(jī)管腳,一端接地,所以每當(dāng)按鍵摁下單片機(jī)就會(huì)有低電平信號(hào)送入。 應(yīng)注意的是LCD1602的程序[15]寫入(void wcmd)和數(shù)據(jù)寫入(void wdata)要分兩步進(jìn)行,也就是說先要選第幾行第幾位顯示數(shù)據(jù)再把要顯示的數(shù)據(jù)輸入進(jìn)去。 主程序流程圖41如下:圖41 主程序流程圖 167。 主程序流程圖主程序首先對(duì)數(shù)字鐘的時(shí)鐘分鐘秒鐘清零,再對(duì)LCD1602初始化和中斷初始化,兩個(gè)中斷為定時(shí)器T0和T1,分別控制數(shù)字鐘和數(shù)據(jù)采集的程序。 本程序采用兩個(gè)計(jì)數(shù)器終端,分別進(jìn)行時(shí)間的計(jì)算和采樣時(shí)間的計(jì)算,外設(shè)三個(gè)按鍵,一個(gè)按鍵表示開始設(shè)置時(shí)間,一個(gè)表示時(shí)鐘加一,最后一個(gè)表示分鐘加一。 軟件介紹本設(shè)計(jì)是基于STC89C52RC的單向電度表的設(shè)計(jì),用于單相度數(shù)的計(jì)費(fèi)。 第16腳:背光源負(fù)極。 第7~14腳:D0~D7為8位雙向數(shù)據(jù)線。當(dāng)RS和R/W共同為低電平時(shí)可以寫入指令或者顯示地址,當(dāng)RS為低電平R/W為高電平時(shí)可以讀忙信號(hào),當(dāng)RS為高電平R/W為低電平時(shí)可以寫入數(shù)據(jù)。 第4腳:RS為寄存器選擇,高電平時(shí)選擇數(shù)據(jù)寄存器、低電平時(shí)選擇指令寄存器。 第2腳:VDD接5V正電源。 4. 功耗低:相對(duì)而言,液晶顯示器的功耗主要消耗在其內(nèi)部的電極和驅(qū)動(dòng)IC上,因而耗電量比其它顯示器要少得多。 2. 數(shù)字式接口:液晶顯示器都是數(shù)字式的,和單片機(jī)系統(tǒng)的接口更加簡(jiǎn)單可靠,操作更加方便。本次設(shè)計(jì)的顯示器選的是LCD1602(162)[14]如圖39所示,它具有以下優(yōu)點(diǎn):1. 顯示質(zhì)量高:由于液晶顯示器每一個(gè)點(diǎn)在收到信號(hào)后就一直保持那種色彩和亮度,恒定發(fā)光,而不像陰極射線管顯示器(CRT)那樣需要不斷刷新新亮點(diǎn)。167。圖38 獨(dú)立式鍵盤接法本設(shè)計(jì)采用獨(dú)立式鍵盤接法如圖38所示,三個(gè)按鍵的一端分別接單片機(jī)的三個(gè)管腳,另一端接地,這樣就使的每當(dāng)按鍵按下就會(huì)使單片機(jī)的相應(yīng)管腳個(gè)到一個(gè)低電平。 2. 44行列式鍵盤模塊:這