應(yīng)用RC低通濾波器擴(kuò)展微處理器輸出端口
摩爾定律形成一個(gè)幾乎必然的推論——下一年,微處理器將會(huì)擁有更多的功能,而軟件團(tuán)隊(duì)則會(huì)提出更多創(chuàng)意。然而不幸的是,微處理器輸出端口仍保持原樣。找到一個(gè)用作測(cè)試、調(diào)試或是標(biāo)準(zhǔn)I/O口的空閑輸出端是件相當(dāng)困難的事。外加簡(jiǎn)單硬件,如圖1所示電路實(shí)現(xiàn)單端口“總線”,提供無限量的并行輸出端。
圖1 HC164外圍電路圖
帶RC低通濾波器的微處理器輸出端控制串并轉(zhuǎn)換器HC164。為了數(shù)據(jù)輸入到串并轉(zhuǎn)換器,每位都要由1-0-1的轉(zhuǎn)換組成,這種轉(zhuǎn)換數(shù)據(jù)低電平狀態(tài)長(zhǎng)度是變化的。如果低電平狀態(tài)超出了低通濾波器的時(shí)間常數(shù),一個(gè)零移進(jìn)寄存器;如果低電平狀態(tài)短,一個(gè)1就移進(jìn)寄存器。這樣,時(shí)鐘信號(hào)和數(shù)據(jù)信號(hào)就合并成為一個(gè)信號(hào)。低通濾波器可以分離時(shí)鐘信號(hào)和數(shù)據(jù)信號(hào)(如圖2)。
圖2 時(shí)鐘信號(hào)與數(shù)據(jù)信號(hào)合并成一個(gè)信號(hào)
表1 whip程序輸出功能
如表1所示,一個(gè)簡(jiǎn)單的“whip”程序?qū)崿F(xiàn)8位輸出功能。假定低通濾波器時(shí)間常數(shù)為3μs,使用4MHz或更高頻率晶振時(shí),指令時(shí)間應(yīng)該為1μs或更短。程序使用My_Port端口的My_ Bit輸出的位操作。
如圖1中電路可以控制一些低速設(shè)備,例如繼電器或LCD,但是電路用于發(fā)光二極管時(shí),HC164進(jìn)行寫操作會(huì)產(chǎn)生令人討厭的閃爍。為解決這個(gè)問題,圖3電路使用另一款串入并出寄存器4096,這種芯片有濾波輸入功能,允許全部沒有達(dá)到臨時(shí)水準(zhǔn)的輸出同時(shí)更新。兩個(gè)單穩(wěn)態(tài)電路提供數(shù)據(jù)和濾波信號(hào)。這個(gè)電路可以用來控制并行設(shè)備,例如基于HD44780的顯示模塊。
圖3 串行輸入/并行輸出芯片4096外圍電路圖
附英文原文:
RC lowpass filter expands microcomputer’s output port
A simple lowpass RC filter allows a single output pin of a microcontroller to expand the number of output bits.
Rex Niven, Forty Trout Electronics, Eltham, Victoria, Australia; Edited by Charles H Small and Fran Granville -- EDN, 6/21/2007
It’s almost a corollary to Moore’s Law: Next year, microcomputers will have more features, and the software team will have bigger ideas. Unfortunately, though, the number of output pins will stay the same. Finding even one spare output for diagnostics, test, or even standard I/O can be a tussle. The single-pin “bus” in Figure 1 can provide an unlimited number of parallel outputs with simple additional hardware. A microcomputer output with an RC lowpass filter controls serial-to-parallel converter HC164. To enter data into the serial-to-parallel converter, each bit consists of a one-to-zero-to-one transition, which alters the length of the low state. If the low state is longer than the lowpass filter’s time constant, a zero shifts into the register. If the low state is short, then a one shifts into the register. The clock and data signals thus combine into one signal. A lowpass filter separates the clock and data signals (Figure 2).
Listing 1, a simple “Whip” routine, performs the output function for eight bits. Assume that the RC time constant is 3 µsec, and the instruction time should be 1 µsec or less at a crystal frequency of 4 MHz or greater. The routine uses bitwise manipulation of output My_Bit of port My_Port.
Although the circuit in Figure 1 can control slow-reacting devices, such as relays or LCDs, using it with LEDs can give an annoying flicker when the HC164 is writing. To address tha t problem, the circuit in Figure 3 uses another serial-in/parallel-out register, the 4094, which has a strobe input to allow simultaneous updates of all outputs without temporary levels. A twin monostable circuit supplies the data and strobe signals. This circuit should be able to control parallel devices, such as display modules based on HD44780 devices.
評(píng)論