跳至主要内容

【转】 LED 数码管驱动点滴

驱动LED的时候,应该分二种情况比如用共阳接法和共阴接法,共阳的时候LED正端接正电源,负端通过一个限流电阻接P口,这时不用接上拉电阻,只要这个限流电阻取合适就可以了发光管亮的时候电流就是从电源正――LED――限流电阻――P口,P口为低电位发光管灭的时候没有电流流过,P口为高电位或高阻状态共阴接法,LED负端接地,正端直接P口,这时候要接上拉电阻,这个上拉电阻是提供LED发光用的,发光管亮的时候电流是从电源正――上拉电阻――LED ――地。这时上拉电阻也是限流用的。P口为高电位或高阻状态发光管暗的时候电流是从电源正――上拉电阻――P口,这时LED无电流流过,P口为低电位,限流电阻上流过电流全部从P口流入。
        要从单片机的输出驱动能力开始讲起。单片机输出驱动分为高电平驱动和低电平驱动两种方式,所谓高电平驱动,就是端口输出高电平时的驱动能力,所谓低电平驱动,就是端口输出低电平时的驱动能力,当单片机输出高电平时,其驱动能力实际上是靠端口的上拉电阻来驱动的,实际测试表明,51单片机的上拉电阻的阻值在 330K左右,也就是说如果靠高电平驱动,本质上就是靠330K的上拉电阻来提供电流的,当然该电流是非常小的,小的甚至连发光二极管也难以点亮,如果要保证LED正常发光,必须要外接一个1K左右的上拉电阻,如果是一个led还好,要是10个、20个led的话,就要接10个、20个1K的上拉电阻,接电阻的本身是可以的,问题是接了上拉电阻以后,每当端口变为低电平0的时候,那么就有10个、20个上拉电阻被无用的导通,假设每个电阻的电流为5mA计算,20个电阻就是100mA,这将造成电源效率的严重下降,导致发热,纹波增大,以至于造成单片机工作不稳,因此很少有采用高电平直接驱动led的,高电平驱动led 实际上就是共阴。低电平驱动就不同了,端口为低电平0时,端口内部的开关管导通,可以驱动高达30多毫安的驱动电流,可以直接驱动led等负载,当端口为低电平0时,尽管内部的上拉电阻也是消耗电流的,但是由于内部的上拉电阻很大,有330K,因此消耗电流极小,基本上不会影响电源效率,不会造成无用功的大量消耗,因此51单片机是不能用高电平直接驱动led的,只能用地电平直接驱动led,即只能用共阳数码管,而不能直接用共阴数码管。

评论

此博客中的热门博文

【转】smb协议栈使用示例

/*  * * uncdownload.c  * *  * * Utility for downloading files from SMB shares using libsmbclient  * *  * * Copyright(C) 2006 Sophos Plc, Oxford, England.  * *  * * This program is free software; you can redistribute it and/or modify it under the terms of the  * * GNU General Public License Version 2 as published by the Free Software Foundation.  * *  * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  * * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  * * See the GNU General Public License for more details.  * *  * * You should have received a copy of the GNU General Public License along with this program; if not,  * * write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  * *  * */ # include < sys / types . h > # include < sys / time . h > # include ...

【转】Ether Types

Ether Types (last updated 2008-09-09) NOTE: Please see [RFC5342] for current information and registration procedures. This registry will be revised soon and will be replaced with up-to-date information. Many of the networks of all classes are Ethernets (10Mb) or Experimental Ethernets (3Mb). These systems use a message "type" field in much the same way the ARPANET uses the "link" field. If you need an Ether Type, contact: IEEE Registration Authority IEEE Standards Department 445 Hoes Lane Piscataway, NJ 08854 Phone +1 732 562 3813 Fax: +1 732 562 1571 Email: <ieee-registration-authority& ieee.org > http://standards.ieee.org/regauth/index.html The following list of EtherTypes is contributed unverified information from various sources. Another list of EtherTypes is maintained by Michael A. Patton and is accessible at: <URL: http://www.cavebear.com/CaveBear/Ethernet/ > <URL: ftp://ftp.cavebear.com/pub/Ethernet-codes > Assign...

【转帖】berkeleyDB安装

我们以redhat9为例开始介绍其安装过程: 从其sleepycat公司官网的下载页 http://dev.sleepycat.com/downloads/releasehistorybdb.html 获得其安装包,现在已经更新到4.4.20.   #tar zxfv db-4.x.tgz   #cd db-4.x/build_unix   1. 如果以gcc编译的话,进行以下操作:   #vi /dist/configure 在最前面添加:CC gcc   #../dist/configure   #make   #make install   默认状态,berkeleyDB的lib和include将被安装到/usr/local/BerkeleyDB/下,需要更改这个路径的话,可以将 #../dist/configure一步加上选项--prefix,例如:#../dist/configure --prefix=/opt/BerkeleyDB.   #vi /etc/ld.so.conf 并将berkeleyDB的lib路径加到该文件的最后一行,这样才能找到并加载它的库文件.ld.so.conf是什么东西?它就是系统动态链接库的配置文件。此文件内,存放着可被LINUX共享的动态链接库所在目录的名字(系统目录/lib,/usr/lib除外),各个目录名间以空白字符(空格,换行等)或冒号或逗号分隔。   #ldconfig   2. 如果以armgcc编译的话,进行以下操作:   先安装armgcc,对我说就是在/mnt/setup/program/FFT/FFT-2410光盘-V3.0/linux开发/linux交叉编译器/tool或者在gmail中附件里armgcc目录下(除了cross-armv4l-qtE-custom-1.5-3mz.i386.rpm,其他都装)   #cp /mnt/setup/program/FFT/FFT-2410光盘-V3.0/linux开发/linux交叉编译器/tool /usr/tmp/   #cd /usr/tmp/tool   #rpm -ivh *   #ldc...