使用数字发现模拟HD44780显示器

HD44780 compatible displays are used in a wide range of devices. They can be connected to a system using as little as 6 pins and display up to 80 alphanumerical character. The most common version uses a 2×16 character array. Display operation may be debugged using logic analyzers such as the Digital Discovery. This demo simulates the real-time operation of a display using the Digital Discovery and a computer while running a Python script.


存货

  • 带有USB端口的计算机运行软件
  • Python 2.7软件使用Python 2.7解释器和TKINTER及其依赖关系
    • 2×6 MTE电缆可用于硬件连接
  • Arduino™
    • In the example, an Arduino™ Uno™ compatible device will be used, but any other Arduino™ board capable of driving HD44780-compatible display will be suitable
  • HD44780- 兼容2×16显示器
    • 在演示中LCD将使用Arduino的键盘盾牌
  • Python源代码下载到电脑
  • Arduino草图代码下载到电脑

步骤1:硬件设置

1.确保下载链接的Arduino草图存货本指南的部分。

2.打开Arduino UNO素描和上传。这sketch will display some short content received over the serial port on theLCD。然后LCD应连接到Arduino模块。所有连接都是4位操作的标准配置,而无需阅读繁忙的标志,并在示例Arduino草图中进行了描述。电路如下:

LCDRS pin to digital pin 8 LCD Enable pin to digital pin 9 LCD D4 pin to digital pin 4 LCD D5 pin to digital pin 5 LCD D6 pin to digital pin 6 LCD D7 pin to digital pin 7 Backlight control to digital pin 10 LCD R/W pin to ground 10K resistor to +5V and ground Wiper to LCD VO pin (LCD pin 3)

3.如果使用不同的LCDmodule then the Arduino code should be adjusted as required before uploading and connecting. Initialize the library by associating any neededLCD与Arduino引脚编号连接到的接口引脚。

const int rs = 8,en = 9,d4 = 4,d5 = 5,d6 = 6,d7 = 7,bl = 10;LiquidCrystal LCD(RS,EN,D4,D5,D6,D7);

4. After resetting the device an “LCD TEST” message should appear on the display. If needed, a contrast should be adjusted. The following is how to connect the Digital Discovery to the HD44780LCD

笔记:Ground should be connected before any other connections are made.

数字发现GND to the LCD GND Digital Discovery DIN0 to the LCD EN Digital Discovery DIN1 to the LCD RS Digital Discovery DIN2 to the LCD D4 Digital Discovery DIN3 to the LCD D5 Digital Discovery DIN4 to the LCD D6 Digital Discovery DIN5 to the LCD D7


步骤2:通信

Data sent to the HD44780-compatible display can be seen using WaveForms software and the Logic Analyzer instrument. In the Logic Analyzer, add a bus with clock on rising edge of the EN signal. Next, add the RS signal as a separate signal and set trigger mode to normal with triggering on a rising edge of the EN signal. After this is set up, run the Logic Analyzer and send one letter through the serial port. The letter will appear on theLCD并在逻辑分析仪中。在这一点上,您将能够看到传输的四个4位nibbles,每个小点数在EN线的上升边缘上。小吃是“分组”以形成8位数字。RS线的状态确定该8位号码是命令RS低还是数据rs高。命令0x01(“清除显示”)随后是数据0x50,是编码的字母“ p”ASCII


Step 3: Python-based HD44780 Emulation

确保下载链接的Python源文件存货本指南的部分。

实时数据采集和分析可以分为步骤。多线程解决方案是一个不错的选择。演示有四个线程:

  1. GUIthread or main thread initializes equipment and is responsible for theGUI手术。
  2. 这acquisition thread collects real-time data form Digital Discovery and puts data into a queue.
  3. 原始数据处理线程从队列中读取数据。仅在EN的上升边缘锁定并将数据放入另一个队列中。
  4. 数据处理线程从第二个队列中读取锁存的数据,并模拟HD44780显示屏的行为。

数据处理算法有一些局限性:

  • 这full finished state machine used by the original controller is not implemented. A simplified initialization procedure is used. The command mode to data mode transition, which is a rising edge on the RS line is used to determine when theLCD被初始化。这用于设置4位模式以及其他参数的设置。
  • Some commands are implemented such as Clear Screen and Set DDRAM address which sets the cursor location.
  • 这script is not optimized for performance.

有关仿真功能的所有详细信息均以脚本注释的形式呈现。


步骤4:运行示例

要测试示例,请运行Python脚本。如果原始的缓冲区或数据缓冲区非常快速填充,则应降低采样率。请注意,过于低的样品速率可能不会“捕获”所有EN脉冲,根据规范的规格可能会短达450 ns。

#示例率=系统频率 /分隔器,100 MHz / 400 = 0.25 MHz DWF.FDWFDIGITALIDIVIDERDERDERDERDERDERDERDERSET(HDWF,C_INT(400))

与Arduino建立串行联系。如果已经建立了连接,则可能需要重置Arduino。

“ int”指示器表示脚本是否检测到初始化。“ 2”值表示成功完成初始化,而“ 0”或“ 1”的值表示不完整的过程。如果显示器在启动时已经初始化,则脚本用户可以设置SI或重置CI初始化标志。“ NIB”指示器表示是否已收到偶数的小点心。甚至用“ 0”表示“ 1”。如果生成错误,则用户还可以使用CN和SN按钮手动调整该标志。通过串行端口向Arduino发送了一些数据后,数据显示在LCD以及在Python脚本创建的用户界面中。


下一步

该示例说明了与HD44780兼容的16×2显示器的简单模拟器。可以进一步开发软件。例如,实现初始化过程的完整兼容性,检测显示功率循环和自动分析。数字发现能够将数字数据馈送到计算机,在该计算机可以使用自定义软件进行非标准分析和调试。

有关如何使用数字发现的更多指南,请返回设备的Resource Center

有关波形的更多信息,请访问波形参考手册

For technical support, please visit the测试和测量section of the Digilent Forums.


,,,,,,,,,,,,