跳至主要内容

【转】 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...

【转】tcphdr结构详解

位于:/usr/src/linux/include/linux/tcp.h struct tcphdr { __be16 source; __be16 dest; __be32 seq; __be32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) __u16   res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; #elif defined(__BIG_ENDIAN_BITFIELD) __u16   doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1; #else #error "Adjust your <asm/byteorder.h> defines"