| Next revision | Previous revision |
| arduino:spilcd_driver_library [2018/12/17 04:42] – created tony | arduino:spilcd_driver_library [2023/03/12 08:58] (current) – tony |
|---|
| \\ | \\ |
| |
| I have a couple of display panels, one from a Brother Fax, the other from a Panasonic phone, that I wish to use in Arduino projects. These are 1 line by 16 character LCD status displays, controlled by a Hitachi HD44780 compatible LCD controller/driver chip that uses an SPI serial interface. | I have a couple of display panels, one from a [[:electronic:lcd:b53K4631|Brother Fax-645]], the other from a [[:electronic:lcd:c7g045|Panasonic KX-T7730]] Phone, that I wish to use in Arduino projects. These are 1 line by 16 character LCD status displays, controlled by a Hitachi HD44780 compatible LCD controller/driver chip that uses an SPI serial interface. |
| <HTML> | <HTML> |
| <div class="shadows" style="text-align:center"> | <div class="shadows" style="text-align:center"> |
| <a href="/dokuwiki/_detail/electronic/lcd/pa101815a.jpg" class="media"><img width="45%" src="/dokuwiki/_media/electronic/lcd/pa101815a.jpg" class="media" title="SPI LCD" alt="SPI LCD" /></a> <a href="/dokuwiki/_detail/electronic/lcd/pa.jpg" class="media"><img width="45%" src="/dokuwiki/_media/electronic/lcd/pa.jpg" class="media" title=SPI LCD" alt="SPI LCD" /></a> | <a href="/dokuwiki/_detail//electronic/lcd/p8250907a.jpg" class="media"><img width="45%" src="/dokuwiki/_media//electronic/lcd/p8250907a.jpg" class="media" title="Panasonic KX-T7730" alt="Panasonic KX-T7730" /></a> <a href="/dokuwiki/_detail/arduino/spilcd/pc143172a.jpg" class="media"><img width="33%" src="/dokuwiki/_media/arduino/spilcd/pc143172a.jpg" class="media" title="Brother Fax-645" alt="Brother Fax-645" /></a> |
| <div class="container"> | <div class="container"> |
| <a href="/dokuwiki/electronic/lcd/dzyc0543">SPI LCD panels that use a Hitachi HD44780 compatible controller</a> | <a href="/dokuwiki/electronic/lcd/c7g045">SPI LCD panels that use a Hitachi HD44780 compatible controller</a><br> |
| | <a href="/dokuwiki/electronic/lcd/b53K4631">SPI LCD panels that use a Hitachi HD44780 compatible controller</a> |
| </div> | </div> |
| </div> | </div> |
| I looked for an Arduino library that would talk to this chip-set, but failed to find one. | I looked for an Arduino library that would talk to this chip-set, but failed to find one. |
| |
| I based my library module for this on a standard Arduino library for the Hitachi HD44780 chip, LiquidCrystal.cpp. The programs included here are LCD_test.ino, LiquidCrystal_SPI.cpp and LiquidCrystal_SPI.h. | I based my library module for this on a standard Arduino library for the Hitachi HD44780 chip, LiquidCrystal.cpp. The programs included here are HelloWorld_SPI.ino, LiquidCrystal_SPI.cpp and LiquidCrystal_SPI.h. |
| |
| The command set is compatible with the Hitachi HD44780, but I don't know the model of the chip, or even the manufacturer. | The command set is compatible with the Hitachi HD44780, but I don't know the model of the chip, or even the manufacturer. |
| |
| ===== Hardware description ===== | ===== Hardware description ===== |
| |
| The controller is mounted directly on the LCD glass, and the LCD module has a 6 pin, 1mm pitch, pcb flex cable. The displays are a single line of sixteen, 5 by 8 pixel, characters. | The controller is mounted directly on the LCD glass, and the LCD module has a 6 pin, 1mm pitch, PCB flex cable. The displays are a single line of sixteen, 5 by 8 pixel, characters. |
| |
| {{:electronic:lcd:pa.jpg?50 |SPI LCD pixel layout}}The two modules have different character sets, but the characters in common tend to have exactly the same font design, so they may have the same manufacturer. I experimented a little, but could not get either board to display an 5 by 11 character mode. | {{:arduino:spilcd:pc173298a.jpg?50 |SPI LCD pixel layout}}The two modules have different character sets, but the characters in common tend to have exactly the same font design, so they may have the same manufacturer. I experimented a little, but could not get either module to display an 5 by 11 character mode. |
| | \\ |
| | \\ |
| \\ | \\ |
| \\ | \\ |
| The great advantage of these serial SPI LCD modules is the simplicity of the Arduino interface. There are three signal lines MISO (data), SCLK (clock), and SS (select). Plus power (+5V) and ground. | The great advantage of these serial SPI LCD modules is the simplicity of the Arduino interface. There are three signal lines MISO (data), SCLK (clock), and SS (select). Plus power (+5V) and ground. |
| |
| The data clock is also the chip's clock that is used to produce the LCD scanning. The datasheet says 500kHz down to 125kHz, typically 250kHz. My board seemed to be quite happy to operate at 1MHz and was still working down to 50kHz, albeit with a lot of flicker. Data is clocked on the rising edge of the clock signal, starts with three low start bits, two register select bits (instruction, data, and two LED control registers), an 8 bit command or data, and at least one high stop bit. The register select and command/data words are sent least significant bit first. | Eight bit commands/data are clocked in, least significant bit (LSB) first, on the rising edge of SCLK. There is no register select so command or data is determined by context : the first thing sent to the LCD after SS is asserted is a command. If you want to just send data to the display, then prefix it with a cursor-positioning or display-on command, then send a stream of data bytes terminated by releasing SS. |
| |
| A suitable clock signal can be generated from the Arduino using one of the timers (I have used Timer1), but the main difficulty is synchronising the data out from the Arduino to this clock. I could perhaps use timer interrupts to drive an output routine that puts out one bit at each clock pulse, but to do this in C in less than 8µS (125kHz clock) seemed difficult. For testing purposes I did something a bit simpler: In the data output routine, I simply turned off the timer clock and 'manually' generated clock and data pulses, then turned on the timer clock when finished. Although the resultant clock during data transmission is something like 73kHz, it seems to work fine. But I see when analysing the clock output that there are occasionally nasty short clock cycles when switching from timer clock to data clock and back. These have no effect upon the communication as they occur when the data pin is high and so don't generate spurious start bits etc, but probably aren't good for the driver chip or LCD. | I used a 56uS clock cycle for SCLK and 800uS between sending bytes. I have no idea of what the controller chip is exactly, therefore no idea of its actual requirements. Those figures are just from analysing the fax data stream. |
| |
| There is no "busy" pin, so delays between commands are necessary, 80µS normally and 1640µS for display clear when using a 250kHz clock. | There is no "busy" pin, so delays between commands are necessary to give sufficient time for internal processing. |
| |
| There was no contrast adjustment on this board. | There was no contrast adjustment on these modules (maybe a command programmable feature). |
| |
| The data pin could be most any Arduino pin, but the clock pin has to be one that can generate PWM outputs, and pin 9 was the appropriate pin when using Timer1 for this purpose. | The data pins can be any available Arduino pins. |
| |
| ===== T6A34 Library ===== | ===== SPI LCD library ===== |
| |
| As mentioned earlier the library is based on a standard Arduino HD44780 LCD library. Most T6A34 hardware commands, including programmable characters, seem to be compatible with the HD44780, but there are some minor variations when comparing datasheets. | As mentioned earlier the library is based on a standard Arduino HD44780 LCD library. Most hardware commands, including programmable characters, seem to be compatible with the HD44780, but I would need to do a lot of experimentation to find any extended commands. |
| |
| The functions implemented are: | The functions implemented are: |
| * display(); | * display(); |
| * noDisplay(); | * noDisplay(); |
| | * Turns the display on or off. |
| * blink(); | * blink(); |
| * noBlink(); | * noBlink(); |
| | * Turns the blinking cursor on or off. |
| * setCursor(col, row) | * setCursor(col, row) |
| * Set location for next character to be displayed. | * Set location for next character to be displayed. |
| * Turns off autoscroll. | * Turns off autoscroll. |
| * createChar() | * createChar() |
| | * Programs one of the 4 user defined, 5x8 pixel characters. |
| | |
| The functions appear to be the same as for the HD44780 but have not been extensively tested for compatibility. | The functions appear to be the same as for the HD44780 but have not been extensively tested for compatibility. |
| | There didn't seem to be any need for 4/8 bit interface selection. It is conceivable that the display controller chip might support 4/8 bit modes, but no account of this possibility is included in this driver. So initialisation is simplified. |
| | |
| | When writing data to be displayed on the LCD screen it would be more efficient to assert SS, send a positioning command and then a stream of bytes, and de-assert SS when complete. But this driver has a, print.h library compatible, single-character output routine, 'write', which is used to output one character at a time, each preceded by a display-on command. |
| | |
| | The original firmware sent an extra code, 0xf8, during startup. On an HD44780 chip this would just be a cursor positioning command (to set data cursor to location 0x78), but this would not be a displayable location, and no data is sent to be displayed. It appears that this may be a reset or other initialisation command. |
| | |
| | I finally realised why I sometimes had trouble setting the programmable characters (only 4 available on these chips) - after setting a programmable character future writes also go to the programmable character CGRAM (corrupting it) until you deliberately switch back to the display ram. This is a problem from the original LiquidCrystal.h library - the solution here is that I just reset the cursor to the home location after programming characters. |
| \\ | \\ |
| \\ | \\ |
| <HTML> | <HTML> |
| <div class="shadows" style="text-align:center"> | <div class="shadows" style="text-align:center"> |
| <a href="/dokuwiki/_detail/arduino/t6a34/pb192735b.jpg" class="media"><img width="80%" src="/dokuwiki/_media/arduino/t6a34/pb192735b.jpg" class="media" title="UF-V40 LCD panel LCD test" alt="UF-V40 LCD panel LCD test" /></a> | <a href="/dokuwiki/_detail/arduino/spilcd/pc173301a.jpg" class="media"><img width="80%" src="/dokuwiki/_media/arduino/spilcd/pc173301a.jpg" class="media" title="SPI LCD panel test" alt="SPI LCD panel test" /></a> |
| <div class="container"> | <div class="container"> |
| LCD module displaying text output of LCD_test_T6A34.ino program | LCD module displaying text output of helloWorld_SPI.ino program |
| </div> | </div> |
| </div> | </div> |
| \\ | \\ |
| The programs (v1.00):\\ | The programs (v1.00):\\ |
| * {{:arduino:t6a34:v1.00:lcd_test_t6a34.ino}}, sketch to test the LCD library | * {{:arduino:spilcd:v1.00:helloworld_spi.ino}}, sketch to test the LCD library |
| * {{:arduino:t6a34:v1.00:liquidcrystal_t6a34.h}}, Toshiba T6A34 library | * {{:arduino:spilcd:v1.00:liquidcrystal_spi.h}}, SPI LCD library |
| * {{:arduino:t6a34:v1.00:liquidcrystal_t6a34.cpp}}, Toshiba T6A34 library | * {{:arduino:spilcd:v1.00:liquidcrystal_spi.cpp}}, SPI LCD library |
| |
| ====== References and Additional Resources ====== | ====== References and Additional Resources ====== |
| |
| * Datasheet for T6A34 {{:electronic:datasheet:toshiba:t6a34.pdf}} | |
| |
| * Information about using Arduino PWM outputs is provided by arduino.cc at [[https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM|Arduino PWM]]. | |
| |
| ===== Other Arduino LCD drivers ===== | ===== Other Arduino LCD drivers ===== |
| | |
| * [[https://playground.arduino.cc/Code/LCD|Arduino LCD display drivers]] | * [[https://playground.arduino.cc/Code/LCD|Arduino LCD display drivers]] |
| |
| * [[https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home|New LiquidCrystal]] | * [[https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home|New LiquidCrystal]] |
| |
| * [[https://github.com/adafruit/Adafruit-RGB-LCD-Shield-Library/blob/master/Adafruit_RGBLCDShield.cpp|Adafruit RGB LCD Shield-Library | * [[https://github.com/adafruit/Adafruit-RGB-LCD-Shield-Library/blob/master/Adafruit_RGBLCDShield.cpp|Adafruit RGB LCD Shield-Library |
| ]]. | ]]. |
| |
| | * [[:arduino:ks0073 driver library|KS0073 SPI LCD]], LCD display panel Arduino driver |
| * [[:arduino:metp0000 driver library|METP0000]], NEC µPD7225 based LCD display panel Arduino driver | * [[:arduino:metp0000 driver library|METP0000]], NEC µPD7225 based LCD display panel Arduino driver |
| | * [[:arduino:mx300 driver library|Canon MX300]], Canon MX300/310 printer LCD display panel Arduino driver. |
| * [[:arduino:uPD7228 driver library|NEC µPD7228]] and μPD16434 LCD display panels Arduino driver | * [[:arduino:uPD7228 driver library|NEC µPD7228]] and μPD16434 LCD display panels Arduino driver |
| | * [[:arduino:t6a34 driver library|Toshiba T6A34]] SPI, HD44780 compatible, LCD display panel Arduino driver |
| |
| <html><small>If any referenced page no longer exists, try looking for its URL on <a href="http://archive.org">http://archive.org</a>.</small></html> | <html><small>If any referenced page no longer exists, try looking for its URL on <a href="http://archive.org">http://archive.org</a>.</small></html> |