【正文】
分析:DELAY: MOV R4,08H 延時1秒主程序 DE2: LCALL DELAY1 DJNZ R4, DE2 RETDELAY1:MOV R4,00H ;延時125us 子程序 D1: MOV R5,00H D2: DJNE R5,DL2 DJNE R4,D1 RET DELAY1為一個雙重循壞 循環(huán)次數(shù)為256*256=65536 所以延時時間=65536*2=131072us 約為125us DELAY R4設(shè)置的初值為8 主延時程序循環(huán)8次,所以125us*8= 1秒由于單片機(jī)的運(yùn)行速度很快其他的指令執(zhí)行時間可以忽略不計(jì)。在方式0時M為213 ;在方式1時M的值為216;在方式2和3為28 ; 算法公式:T=(M-TC)T計(jì)數(shù) 或TC=M-T/T計(jì)數(shù)T計(jì)數(shù)是單片機(jī)時鐘周期TCLK的12倍;TC為定時初值如單片機(jī)的主脈沖頻率為TCLK12MHZ ,經(jīng)過12分頻方式0 TMAX=213?。蔽⒚耄椒绞剑薄 MAX=216?。蔽⒚耄斤@然1秒鐘已經(jīng)超過了計(jì)數(shù)器的最大定時間,所以我們只有采用定時器和軟件相結(jié)合的辦法才能解決這個問題.實(shí)現(xiàn)1秒的方法:我們采用在主程序中設(shè)定一個初值為20的軟件計(jì)數(shù)器和使T1定時50毫秒。 交通燈控制線路圖 4 交通燈軟件設(shè)計(jì) 程序設(shè)計(jì)流程圖 (1) 程序設(shè)計(jì)總框圖:如圖4 開 始鍵盤事件處理等 待 鍵 盤 事 件初始化顯示程序處理圖4 程序設(shè)計(jì)框圖(2)程序詳細(xì)流程圖:如圖5開始設(shè)置定時器開中斷賦初值F0=1R0,R1分別送A。注意:當(dāng)LED顯示器超過8個時,我們采用74HC244芯片驅(qū)動。在寫信號有效時,相隔 一個機(jī)器周期后發(fā)送控制端SEND有效,即允許RXD發(fā)送數(shù)據(jù),同時,允許從TXD端輸出移位脈沖。:INT1,外部中斷1輸入。PORT2(~):端口2是具有內(nèi)部提升電路的雙向I/O端口,每一個引腳可以推動4個LS的TTL負(fù)載,若將端口2的輸出設(shè)為高電平時,此端口便能當(dāng)成輸入端口來使用。平時在程序執(zhí)行時ALE引腳的輸出頻率約是系統(tǒng)工作頻率的1/6,因此可以用來驅(qū)動其他周邊晶片的時基輸入。XTAL2:系統(tǒng)時鐘的反向放大器輸出端,一般在設(shè)計(jì)上只要在 XTAL1 和 XTAL2 上接上一只石英振蕩晶體系統(tǒng)就可以動作了,此外可以在兩個引腳與地之間加入一個 20PF 的小電容,可以使系統(tǒng)更穩(wěn)定, 避免噪聲干擾而死機(jī)。而P1口用于輸出控制信號.而通過74LS04反向器實(shí)現(xiàn)控制各個燈的情況.它采用5V的直流電來驅(qū)動二極管。因此,單片機(jī)的學(xué)習(xí)、開發(fā)與應(yīng)用將造就一批計(jì)算機(jī)應(yīng)用與智能化控制的科學(xué)家、工程師?,F(xiàn)在,這種單片機(jī)的使用領(lǐng)域已十分廣泛,如智能儀表、實(shí)時工控、通訊設(shè)備、導(dǎo)航系統(tǒng)、家用電器等??梢哉f,二十世紀(jì)跨越了三個“電”的時代,即電氣時代、電子時代和現(xiàn)已進(jìn)入的電腦時代。2首先將許多邏輯關(guān)系簡化到極點(diǎn),而后將其一起集成用較少的芯片去完成所需功能。而紅綠燈的顯示也是一樣,由狀態(tài)分析可以得出紅綠燈的變化表如:表2狀態(tài)主干道燈顯示次干道燈顯示00紅燈綠燈01紅燈左轉(zhuǎn)綠燈10綠燈紅燈11左轉(zhuǎn)綠燈紅燈表2 紅綠燈變化表通過這張表就可以用組合電路實(shí)現(xiàn)該功能了,可以用數(shù)據(jù)選擇器的思想,在本系統(tǒng)中,直接通過門電路的譯碼,接下來就是計(jì)數(shù)模塊了,其主要的功能細(xì)分為,要從預(yù)置數(shù)開始遞減計(jì)數(shù),一個狀態(tài)結(jié)束,通過判斷,通知主控制模塊,使之進(jìn)入下一模塊。 5 2 交通管理方案論證 設(shè)計(jì)任務(wù)東西(A)、南北(B)兩干道交于一個十字路口,各干道有一組紅、左轉(zhuǎn)綠、綠三個指示燈,指揮車輛和行人安全通行。道路擁擠現(xiàn)象日趨嚴(yán)重,造成的經(jīng)濟(jì)損失越來越大,并一直保持大比例的增長。紅外光束能把信號燈的紅燈延長一段時間,推遲汽車放行,以免發(fā)生交通事故。它由紅綠兩塊以旋轉(zhuǎn)式方形玻璃提燈組成,紅色表示“停止”,綠色表示“注意”。單片機(jī)系統(tǒng)采用的直流供電。單片機(jī)作為計(jì)算機(jī)技術(shù)的一個分支,正在不斷的應(yīng)用到實(shí)際生活中,同時帶動傳統(tǒng)控制檢測的更新。那么靠什么來實(shí)現(xiàn)交通的井然秩序呢?靠的是交通信號燈的自動指揮系統(tǒng),來實(shí)現(xiàn)交通的井然有序。III 英文摘要In recent years, with the rapid development of science and technology, a micro electronic technology, puter technology and munication technology as the forerunner of the information revolution is booming. Computer technology, as one of the three, how to bine with practical application more effectively and play its role. Single chip microputer as a branch of puter technology is constantly applied to the real life, while driving the traditional control detection update. Single chip microputer as a branch of puter technology is constantly applied to the real life, while driving the traditional control detection update. In realtime detection and automatic control of the application system, the microcontroller is often used as a core ponent, according to the specific characteristics of the application object, with other devices to improve.Crossroads shuttle vehicles, pedestrians bustling, car lanes, walkways, everything in good order and well arranged. So what to achieve traffic in order? Rely on the automatic mand system of traffic signal lamp, traffic in order to achieve. Many traffic lights control. The system uses the United States ATMEL pany AT89S51 microcontroller, as well as other chips to design traffic light control. Achieved through the AT89S51 chip P1 port set red, green light function, through the AT89S51 chip RXD, TXD input, output display time. The light of the traffic light is realized by the light emitting diode, and the display of the time is realized by seven sections of digital tubes. DC power supply used in single chip microputer system. In order to ensure the stability and reliability of the system, the system integrates the watchdog chip, to avoid the system because of the crash and stop working. The system has strong practicability, simple operation and good expansibility.計(jì)算機(jī)科學(xué)與技術(shù)系畢業(yè)設(shè)計(jì)