English 中文(简体)
Interrupt driven HD44780 library for an Arduino
原标题:

I have an HD44780 LCD screen, and I ve been using the LiquidCrystal Library provided with the Arduino development package. However, it s not reliable. I noticed some problems with it, and instead of being interrupt driven, it just sleeps as long as the developer thinks the chip should take to execute the operation.

From the spec sheets, the BUSY flag will be set while it is executing, meaning it is possible to be interrupt driven.

Does anyone know of a library that actually does this, and does it require all 8 bits to be connected or can I keep it at 4 pins?

最佳回答

I don t think you need an interrupt for this. Looking at LiquidCrystal.cpp in the Arduino distribution, you just need to change the LiquidCrystal::write4bits, LiquidCrystal::write8bits, and LiquidCrystal::pulseEnable code. The first two methods should start by monitoring the busy line (BD7) before writing data, and the last one would be modified to remove the 100us pause.

I think the reason this wasn t done in the default code is that many users of these LCDs just tie R/W to ground so the display is always in write mode, making it impossible to read the BUSY signal. However, this is passed into the library by setting _rw_pin to -1, so the pulse and write code can conditionally use the r/w pin as a way of detecting busy as a speed optimization.

问题回答

It is possible to use 8 bit on three pins; you just need a shift register. I m using a HEF4094BP from mouser.com (shipping is going to cost more than the actual chip)

the wiring diagram and code modifications for the shift register are here: http://www.arduino.cc/playground/Code/LCD3wires

Some time ago I modified the LiquidCrystal lib to support the busy flag. Please note that real interrupt driven operation is not possible - for each read you need to toggle the Enable line twice. Therefore you will need to poll the busy flag.

Then I did some benchmarks an found, that polling the busy flag is slower than just waiting for most commands. (The exception are the clear and home commands). The reason was, that switching between read mode and write mode requires aditional steps like 8 additional calls to digitaWrite and 8 additional calls to pinMode. Even with 16MHz Arduinos this slower than just waiting 100µs.

After that I wrote a library that manipulates the pin registers directly and in bulk mode - all 8 pins with one register access. After that I was in the ballpark to get some benefit by polling.





相关问题
Interrupt driven HD44780 library for an Arduino

I have an HD44780 LCD screen, and I ve been using the LiquidCrystal Library provided with the Arduino development package. However, it s not reliable. I noticed some problems with it, and instead of ...

Appending lists from files to a single list in Python

I m trying to write a function that reads files from a "deferred" directory which contains files that contain lists. Here s what the files in the deferred folder contain: 173378981 , 45000 , ...

C# TCP/IP Client having an IO Exception

The IO Exception: "Unable to read data from the transport connection: An established connection was aborted by the software in your host machine." The code has been copied from a tutorial and I m ...

Java: Why isn t my file writing working?

I m trying to write a file from my Java program, but nothing happens. I m not getting any exceptions or errors, it s just silently failing. try { File outputFile = new File(args[...

Multithreading on a file open copy and write

I am new at threads here is the question, I have 3 threads one of them calls a method that writes into a file via File.AppendAllText method, other thread duplicates the text in the same file, and the ...

Is File.Exists an expensive operation?

Re: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx Does anyone know if this is a particularly slow or locking operation which could impact server performance in a large ...

Removing pause after reading using readLine in java

I am reading several lines from the console in a java program using the readLine command from the BufferedReader class. However, the program pauses at the end of the last line and does not proceed ...

热门标签