【正文】
本文力圖從這兩方面作些探索,希望這些粗淺見解能夠起些拋磚引玉的作用,對大家有所幫助;也希望各位同仁一起探索,共同提高我們的設計水平。 圖 5 變壓器保護器部分程序流程 結(jié) 語 跑飛的特殊性,它受到干擾 的后果可能是死機,也可能在死機前發(fā)出各種錯誤或非法動作,使整個系統(tǒng)產(chǎn)生致命性錯誤。當程序再次由復位開始時,檢測到 Ts=0 但是 Td≠0,表明已經(jīng)越過了試送電,現(xiàn)在正處于停電等待 30s 的過程中。當 Ts1=0 時,應該進入停電等待 30s 的過程了。下一次被復位后,再檢測上電引腳已不是初上電,于是進 行到試送電計時 Ts 的檢測。試送電的 延時是對復位進行 25 次計數(shù)實現(xiàn)的,因為每次復位時間是 20ms。送電后的 1s 內(nèi)為啟動時間,不進行過電流檢測。它 在上電后,經(jīng)過一定的動作順序達到正常工作狀態(tài),如圖 4;根據(jù)這個動作編寫軟件流程的一部分,如圖 5。也就是說,凡是跨過復位周期的操作,都是靠標志傳遞的,這些標志存放在內(nèi)部 RAM 中,只有初上電時才清零。要注意的是,測量、送顯示用的總時間要小于復位低電平時間,否則會出現(xiàn)永遠不能完整執(zhí)行程序的錯誤。 實現(xiàn)跨越定時復位間隔的時序控制 用復位方式工作,每次從頭開始反復執(zhí)行同一程序。如果計算時間允許,盡量采取方法 1。 3 軟件實現(xiàn)要點 輸出恢復與不清零 RAM 此,復位后要立即恢復所有引腳的狀態(tài)。在某引腳對地接一個 1μF的電容,復位后檢測該引腳,如果是低電平就是初上電。當然,這種方法會使正常的輸出變化滯后一個周期,才真正反映到輸出端子。由于電容的保持作用,在本周期內(nèi)尚不能使輸出變化到有效的電平;在下個周期,錯誤被 糾正。 ② 把外圍電路設計成高電平無效。這個正脈沖會影響正常的輸出,有 2 個辦法處理: ① 在端子上并聯(lián)電容加以抑制,容量根據(jù)復位的 Tr 時間確定。 輸出端子的處理 (1)復位期間的正脈沖 I/O 口變成高電平。單片機在 Ts 和 Tr 期間都能有效地抗干擾,但是最好還是把多余時間安排在 Tr 內(nèi)。合理選擇復位周期和復位信號的高電平占空比非常重要。 復位周期與復位高電平時間 3 中,復位信號在高電平 Tr 期間,單片機處在復位狀態(tài), 程序不運行,抗干擾能力最強;高電平過后,單片機開始執(zhí)行程序。 外部條件復位 以使用施密特觸發(fā)器整形;對于記錄最大或最小值的儀器,可使用窗口比較器。 ② 使用系統(tǒng)固有的信號作為定時復位脈沖。圖 1 為使用 555 電路組成的定時電路;也可以使用 X1126 之類的時鐘芯片,設置報警時間后用報警信號喚醒CPU。 2 硬件實現(xiàn)要點 無條件定時復位 一般有 2 種方法。這種方法的復位間隔不是固定的,而是根據(jù)外部條件確定的。因此,只要把水輪脈沖與 CPU的復位聯(lián)系起來,水輪每旋轉(zhuǎn) 1 周, CPU復位 1 次,熱表就可以正常工作了,這就是外部條件復位法。 外部條件復位法 沖計算熱量,沒有熱水流動,就沒有熱量輸出, CPU只要保持原來數(shù)值即可,不需要計數(shù)。對于只是顯示的儀表,某 1s 偶然出現(xiàn)的讀數(shù)錯誤對下一次測量并沒有記憶,是可以承受的,屬 “一過性 ”錯誤。如果工作與休眠的時間比例為 1:9,也就是說, 1s 內(nèi)有 的時間用來檢測、送顯示,有 的時間休眠,程序受干擾的概率是全速運行時的 1/10,整體抗干擾能力提高了 10倍。如果讓 CPU 執(zhí)行完任務后直接進入休眠,然后由外界復位喚醒它去執(zhí)行下 一次操作,這就是定時復位法。在實際運行中,往往是用 A/D 轉(zhuǎn)換器采樣輸入的模擬量,然后進行存儲顯示。下面以 51 系列單片機為例探討具體原理與實現(xiàn)方法,復位信號為高電平。每次復位后,單片機執(zhí)行相應的程序,執(zhí)行完任務后及時進入休眠,等待下次復位。在抗干擾方面的許多技術,比如設軟件陷阱 、加硬件看門狗電路等,可使這一問題有較好的解決,但仍然存在問題:① 看門狗動作時,意味著已經(jīng)出現(xiàn)了錯誤,且運行了一段時間,這在有些場合是不允許的;② 有時程序出現(xiàn)死循環(huán)錯誤,但是剛好把看門狗控制環(huán)節(jié)包含進去,對于這樣的錯誤采用看門狗無法識別;③ 在檢測控制周期比較長的系統(tǒng)中,單片機花大量時間等待外設,執(zhí)行等待命令時同樣會受到干擾。 關鍵詞:單片機 復位 /休眠 抗干擾 引 言 化方面顯示出非凡的優(yōu)勢,在很大程度上取代了原來由數(shù)字邏輯電路、運算放大電路組成的檢測、控制電路,應用非常廣泛。 Transmit power formally after waiting for 30s. It is startup time in 1s after transmitting power, does not measure the electric current. Start after finishing, if all going well, the location is put normal sign , person who protect restore to the throne cycle enter normal running in the next one. Try 0 that transmits power. 5s is it is it realize to count once restoring to the throne to delay time, restore to the throne time 20ms each time. At having electricity for the first time, make all zero clearing to inside RAM, make it is it time Ts to transmit power not to try =Dormancy after 25. After restoring to the throne, is it have electric pin to have electricity for the first time already, is it is it is it is it time the measuring of Ts to transmit power to try to get to go on to measure next time. If Ts * 0, is it in is it prolong period to transmit power, is it enter dormancy after the 1 to reduce Ts to prove. Act as Ts1 = 0, the course which waited for 30s that should enter and lose electrical power. Just when Ts decreases progressively to 0, make it is it indicate to wait for not to lose electrical power Td =1500. When the procedure is restored to the throne beginning again, measure to Ts =0 but Td * 0, is it is it is it transmit power to try to cross already to indicate, at is it wait for the course of 30s to lose electrical power now. In this way, the whole process is transmitted each other by such these parameters as Tr, Td , Ts etc, go on step by step. Result: Conclusion Antiinterference is an important problem in an electronic design, especially Important in the onechip puter. This is because the onechip puter has procedures to run particularity that flies, the consequence that it is interfered may be the system halted, may send out various kinds of mistakes or illegal movements before the system halted too, make the whole system produce the mortality mistake. So, only guarantee it is not enough yet for onechip