电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>电子资料>带CMOS4511IC的RPi 7段显示器

带CMOS4511IC的RPi 7段显示器

2023-07-10 | zip | 0.04 MB | 次下载 | 免费

资料介绍

描述

背景

本系列的第一篇文章中,我讨论了一种直接通过 Raspberry Pi 2 驱动 7 段显示器的非常简单的方法。虽然这确实有效,但在实践中它有许多注意事项和限制。首先,通过每个 LED电流受限于 Raspberry Pi 上每个 GPIO 引脚可以提供的电流。其次,如果所有段都点亮,则进入 GPIO 输入引脚的累积电流超过了建议的输入电流。虽然我毫不怀疑 Raspberry Pi 可以处理它,但我不建议长期使用它。

介绍

为了改进上一篇文章并以更有效的方式驱动七段显示器,我将进行两项重大更改。首先,我将使用 CMOS4511 集成电路芯片从二进制输入驱动 7 段显示器。其次,为了保护 GPIO 输入晶体管将用于打开和关闭显示器,电路将接地而不是 GPIO 引脚。

先决条件

1 个树莓派 2

1 个 Cmos 4511 集成电路

4 x NPN 晶体管(或多或少取决于显示的位数)

1 x 5641AS 7 段显示器(或类似的 7 段显示器)

7 x 220 欧姆电阻

4 x 1 kOhm 电阻器(与晶体管数量相同)

弗里茨

 
poYBAGOjs66AfWD9AAB9hwDIiAg122.jpg
 

电路

上面的 fritzing 图显示了演示中使用的完整电路。如果需要输出到 4511 和 GPIO,可以使用不同的 GPIO 引脚。

CMOS4511 IC 用于将二进制输入转换为 7 段显示输出。可以在数据表中找到 4511 的引脚分配4个输入D0-D3接到树莓派上,7个输出a到g通过220欧姆电阻接显示器上相应的段。Vcc、BL、LT都要接电源[推荐3.3 v]和地应接地。LE 可以悬空。

 

从显示器上看,每个数字显示引脚都应连接到一个NPN晶体管的集电极,每个晶体管的发射极都可以接地。每个晶体管基极都可以通过一个 1 kOhm 电阻器连接到一个 GPIO 引脚。

代码

由于核心代码与以前的驱动程序相同,因此从以前的代码中抽象出我们的新驱动程序是有意义的。为此,我们需要做一些小改动。

首先,因为我们要使用 4 个引脚而不是 7 个引脚来驱动我们的显示器,我们需要覆盖现有类中的 SetDisplay 方法,因此现在应该将其设置为虚拟以允许我们执行此操作。我们还需要覆盖 ClearDisplay() 方法,因此它也被设置为虚拟的。

最重要的是,由于我们使用了一组不同的 GPIO 引脚,我们需要能够提供不同的构造函数,但由于我们不想使用原始的基本构造函数,因此我们必须提供另一个,在这种情况下无参数构造函数。因为我们只希望派生类能够使用它,所以我们可以将构造函数设置为受保护的。我们还可以利用此构造函数来设置先前在主构造函数中设置的取消标记,从而无需为这些字段提供受保护的访问器。

 protected Display()
{
this.cts = new CancellationTokenSource();
this.token = new CancellationToken();
} 

我们需要对原始类做的最后一件事是使派生类可以访问显示数组


protected GpioPin[] Displays
        {
            get
            {
                return this.displays;
            }

            set
            {
                this.displays = value;
            }
        } 

现在我们已准备好创建新的派生类。应该创建一个类似于我们原始基类的新构造函数,但我们只需要提供 4 个输出引脚 [for the 4511 D0-D3],然后是我们的显示引脚。然后根据基类执行引脚的初始化。

接下来我们可以提供重写的 SetDisplay 方法。此版本不是将提供的 int 转换为其 7 段表示形式,而是将提供的 in 转换为其二进制表示形式。


protected override void SetDisplay(GpioPin displayPin, int value)
        {
            this.ClearDisplay();

            switch (value)
            {
                case 0:
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
                case 1:
                    this.SetHigh(new GpioPin[] { this.pinBcd0 });
                    this.SetLow(new GpioPin[] { this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
                case 2:
                    this.SetHigh(new GpioPin[] { this.pinBcd1 });
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd2, this.pinBcd3 });
                    break;
                case 3:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1 });
                    this.SetLow(new GpioPin[] { this.pinBcd2, this.pinBcd3 });
                    break;
                case 4:
                    this.SetHigh(new GpioPin[] { this.pinBcd2 });
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd3 });
                    break;
                case 5:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd2 });
                    this.SetLow(new GpioPin[] { this.pinBcd1,this.pinBcd3 });
                    break;
                case 6:
                    this.SetHigh(new GpioPin[] { this.pinBcd1, this.pinBcd2});
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd3 });
                    break;
                case 7:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2 });
                    this.SetLow(new GpioPin[] { this.pinBcd3 });
                    break;
                case 8:
                    this.SetHigh(new GpioPin[] { this.pinBcd3 });
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2 });
                    break;
                case 9:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd3 });
                    this.SetLow(new GpioPin[] { this.pinBcd1, this.pinBcd2 });
                    break;
                case 10:  // Clear Display
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
                default:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
            }

            this.SetHigh(new GpioPin[] { displayPin });
        }

此方法还有一个变化。也就是说,这次我们将 GPIO 设置为高电平,而不是将 GPIO 引脚设置为低电平来打开显示数字。这是因为我们现在不是将引脚设置为低电平以允许电流流入 GPIO 引脚,而是将引脚​​设置为高电平,然后“切换”允许电流流动并下沉至接地轨的晶体管。正是出于这个原因,我们还覆盖了 ClearDisplays 方法以将所有 GPIO 引脚设置为低 [而不是高]。

 protected override void ClearDisplay()
{
this.SetLow(this.Displays);
} 

下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1山景DSP芯片AP8248A2数据手册
  2. 1.06 MB  |  532次下载  |  免费
  3. 2RK3399完整板原理图(支持平板,盒子VR)
  4. 3.28 MB  |  339次下载  |  免费
  5. 3TC358743XBG评估板参考手册
  6. 1.36 MB  |  330次下载  |  免费
  7. 4DFM软件使用教程
  8. 0.84 MB  |  295次下载  |  免费
  9. 5元宇宙深度解析—未来的未来-风口还是泡沫
  10. 6.40 MB  |  227次下载  |  免费
  11. 6迪文DGUS开发指南
  12. 31.67 MB  |  194次下载  |  免费
  13. 7元宇宙底层硬件系列报告
  14. 13.42 MB  |  182次下载  |  免费
  15. 8FP5207XR-G1中文应用手册
  16. 1.09 MB  |  178次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234315次下载  |  免费
  3. 2555集成电路应用800例(新编版)
  4. 0.00 MB  |  33566次下载  |  免费
  5. 3接口电路图大全
  6. 未知  |  30323次下载  |  免费
  7. 4开关电源设计实例指南
  8. 未知  |  21549次下载  |  免费
  9. 5电气工程师手册免费下载(新编第二版pdf电子书)
  10. 0.00 MB  |  15349次下载  |  免费
  11. 6数字电路基础pdf(下载)
  12. 未知  |  13750次下载  |  免费
  13. 7电子制作实例集锦 下载
  14. 未知  |  8113次下载  |  免费
  15. 8《LED驱动电路设计》 温德尔著
  16. 0.00 MB  |  6656次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935054次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537798次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420027次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234315次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233046次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191187次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183279次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138040次下载  |  免费