1. gzyueqian
      13352868059
      首頁 > 新聞中心 > > 正文

      使用一個微處理器管腳的三態開關接口

      更新時間: 2008-04-10 10:39:28來源: 粵嵌教育瀏覽量:870

      單個微處理器I/O引腳感知三位置開關的狀態。

        電子玩具的人機接口有時需要三態控制。一個單軸手柄可以定義向右運動、向左運動和不動的狀態。類似地,計數器有控制按鈕,允許計數器增加、減少和保持不變。工程師通常用兩個獨立的按鈕形成這些接口,需要兩個微處理器管腳。本設計方案提供了一個只使用Atmel公司的ATmega8微處理器的一個管腳,感知中間為關閉狀態的SPDT(單刀雙擲)開關三態的方法(參考文獻1和圖1)。表1為該電路的簡單程序(程序見英文源地址)。
                 






        微處理器的管腳狀態依靠DDR位的值、端口位和其外部連接。微處理器管腳用下拉電阻R1與地相連,阻抗典型為幾百千歐,在管腳上呈現出高阻狀態。設置DDR寄存器為0。當使用者鉗位開關到位置1時,管腳通過電阻R5連接到VDD,管腳位為1,不論端口位是什么值。當使用者鉗位開關到位置3時,管腳接地,管腳位為0,與端口位的值無關。在中心關閉狀態,管腳位服從端口位。表1總結了端口不同值和外部輸入的管腳狀態。

                        





        英文原文:



        Three-state switch interface uses one microcontrolle




      r pin



        A single microcontroller I/O pin senses the state of a three-position switch.



        Kartik Joshi, Netaji Subhas Institute of Technology, New Delhi, India; Edited by Charles H Small and Fran Granville -- EDN, 2/21/2008



        Human interfaces for electronic gadgets sometimes require three states for control. A single-axis joystick has states to define motions to the right, to the left, and with no motion. Similarly, a timer has control buttons that allow the timer to increment, decrement, and remain untouched. Engineers usually create these interfaces by using two independent pushbuttons, requiring two microcontroller pins. This Design Idea presents a way to sense three states of an SPDT (single-pole/double-throw) switch with a center-off state, using only a single pin of Atmel’s ATmega8 microcontroller (Reference 1 and Figure 1). Listing 1 is a simple program for the circuit.



        The status of the pin of the microcontroller depends upon values of the DDR bit, the port bit, and its external connection. The microcontroller’s pin connects to ground using pulldown resistor R1 with resistance, typically, of a few hundred kilohms to impress the high-impedance state on the pin. You set the DDR register to zero. When the user toggles the switch to Position 1, the pin connects to VDD through resistor R5, and the pin bit is one, regardless of the value of the port bit. When the user toggles the switch to Position 3, the pin is grounded, and the pin bit is zero, regardless of the value of the port bit. In the center-off state, the pin bit follows the port bit. Table 1 summarizes the states of the pin for different values of the port and the external input.






        Reference



        “ATmega8/ATmega8L 8-bit AVR with 8K Bytes In-System Programmable Flash,” Atmel Corp, 2007.

      免費預約試聽課

      亚洲另类欧美综合久久图片区_亚洲中文字幕日产无码2020_欧美日本一区二区三区桃色视频_亚洲AⅤ天堂一区二区三区

      
      

      1. 欧美日韩精品久久久久免费看 | 亚洲乱码精品不卡 | 在线看片免费人成影片 | 在线中文字幕有码中文 | 尤物在线精品国产 | 在线a亚洲老鸭窝天堂 |