使用一个微处理器管脚的三态开关接口

技术分类: 微处理器与DSP  | 2008-03-05
来源:EDN | 作者:Kartik Joshi, Netaji Subhas Institute of Technology, New Delhi, India

  单个微处理器I/O引脚感知三位置开关的状态。

  电子玩具的人机接口有时需要三态控制。一个单轴手柄可以定义向右运动、向左运动和不动的状态。类似地,计数器有控制按钮,允许计数器增加、减少和保持不变。工程师通常用两个独立的按钮形成这些接口,需要两个微处理器管脚。本设计方案提供了一个只使用Atmel公司的ATmega8微处理器的一个管脚,感知中间为关闭状态的SPDT(单刀双掷)开关三态的方法(参考文献1和图1)。表1为该电路的简单程序(程序见英文源地址)。

感知中间为关闭状态的SPDT

  微处理器的管脚状态依靠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.

0
0
(请您对文章做出评价)
1】【2
加载中

对文章的评论

更多评论

剩余字数:  

相关在线研讨会

我要参加

Microchip mTouch™ –灵活易用的电容式感应方案

时间:2008-11-27  10:00:00--12:00:00
简介:电容式感应以其增强的耐用性,较低的整体系统成本,时尚简约的外观等优点,迅速成为用户界面,面板显示等控制应用的解决方案之一。越来… 马上参会

浏览该文章的用户还看过...

  • 文 章

  • 论 坛

  • 博 客

  • 小 组

  • 博客推荐

  • 论坛推荐

  • 在线研讨会