| Next revision | Previous revision |
| arduino:ks0073_driver_library [2022/08/18 02:36] – created tony | arduino:ks0073_driver_library [2022/08/22 23:31] (current) – [KS0073 LCD Library] tony |
|---|
| \\ | \\ |
| |
| I have a pile of display panels from Siemens optiPoint 500 series phones, that I wish to use in Arduino projects. These are 2 line by 24 character LCD status displays, controlled by Samsung KS0073 - a Hitachi HD44780 compatible LCD controller/driver chip that includes an SPI style serial interface. | I have a [[:electronic:lcd:vlgem1021|pile of display panels]] from Siemens optiPoint 500 series phones, that I wish to use in Arduino projects. These are 2 line by 24 character LCD status displays, controlled by Samsung KS0073 - a Hitachi HD44780 compatible LCD controller/driver chip that includes an SPI style serial interface. |
| <HTML> | <HTML> |
| <div class="shadows" style="text-align:center"> | <div class="shadows" style="text-align:center"> |
| <a href="/dokuwiki/_detail//electronic/lcd/p8123449a.jpg" class="media"><img width="90%" src="/dokuwiki/_media//electronic/lcd/p8123449a.jpg" class="media" title="Varitronix VLG1021" alt="Varitronix VLG1021" /></a> | <a href="/dokuwiki/_detail//electronic/lcd/p8123449a.jpg" class="media"><img width="90%" src="/dokuwiki/_media//electronic/lcd/p8123449a.jpg" class="media" title="Varitronix VLG1021" alt="Varitronix VLG1021" /></a> |
| <div class="container"> | <div class="container"> |
| <a href="/dokuwiki/electronic/lcd/dzyc0543">SPI LCD panel that use a Samsung KS0073 (a Hitachi HD44780 compatible controller with serial interface)</a> | <a href="/dokuwiki/electronic/lcd/vlgem1021">VLG1021 LCD panel that use a Samsung KS0073 (a Hitachi HD44780 compatible controller with serial interface)</a> |
| </div> | </div> |
| </div> | </div> |
| ===== Hardware description ===== | ===== Hardware description ===== |
| |
| The controller is mounted on a PCB joined to the LCD glass via a PCB flex cable, and the LCD module has a 10 pin, 1mm pitch, PCB flex cable to connect to a suitable socket. The displays are a two lines of twentyfour, 5 by 8 pixel, characters. | {{ :electronic:lcd:p8183558a.jpg?300|A VLG1021 LCD module with a faulty flex cable}} |
| | The KS0073 controller chip is capable of 4 or 8 bit parallel and SPI style serial interfacing, but in these modules it is hardwired for serial only. The controller is mounted on a PCB and joined to the LCD glass via a PCB flex cable. I think the flex cable is a weak point in the design as some modules display missing columns of pixels (best observed when the contrast is turned right up where upon some characters only show as narrow strips rather than solid blocks - pressure on the cable changes which columns of pixels are displayed). |
| |
| {{:electronic:lcd:p8153507a.jpg?50 |SPI LCD pixel layout}}. | The LCD module has a 10 pin, 1mm pitch, PCB flex cable to connect to a suitable socket. |
| | |
| | The displays are a two lines of twentyfour, 5 by 8 pixel, characters. |
| | {{:electronic:lcd:p8153507a.jpg?50 |VLG1021 LCD pixel layout}}. |
| \\ | \\ |
| \\ | \\ |
| \\ | \\ |
| \\ | \\ |
| ===== Arduino to SPI LCD wiring ===== | |
| |
| 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 ks0073 controller chip has two sets of, very similar, instructions available. They are selectable via the Extended Instruction control pin (IE). In the VLGEM1021 modules this appears to be tied "low". I assume that this pin is to allow the chip to emulate either of two previous LCD control chip implementations. |
| |
| 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. | ===== Arduino to VLG1021 LCD wiring ===== |
| |
| 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. | The great advantage of these serial SPI LCD modules is the simplicity of the Arduino interface. There are four signal lines SID (data to the display), SOD (responses from the display), SCLK (clock), and CS (select). Plus power (+5V) and ground (the module should also work from a 3.3V supply). CS is really only needed if there is more than one display connected to SCLK, SID and SOD, so it could be tied to ground to permanently enable the interface. SOD is mainly used for checking the ready state of the LCD module after each command, if speed isn't crucial then just implementing a wait after each command (about 40uS usually), means you can get away with just using SCLK and SID - so requiring only two Arduino pins for full control of the device. |
| |
| There is no "busy" pin, so delays between commands are necessary to give sufficient time for internal processing. | There is a separate power line, VCI, to supply the voltage converter that sets the LCD contrast voltage, around 1.3V was typical. |
| |
| There was no contrast adjustment on these modules (maybe a command programmable feature). | The interface pins can be any available Arduino pins. |
| |
| The data pins can be any available Arduino pins. | ===== KS0073 LCD Library ===== |
| |
| ===== SPI LCD Library ===== | The KS0073 uses its own variation of a SPI protocol where data and commands are prefixed by a control byte that specifies what the following bytes are going to be - ie read/write data, or a command. |
| |
| 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. | All bytes are sent least significant bit (LSB) first, on the rising edge of SCLK. The control byte consists of 5 successive "1"s followed by read/write (R/W) and command/data register select (RS) bits. The final bit of the control byte is a "0", making a total start sequence of 8 bits. So typically you assert CS and send a control byte indicating a command follows, then the command. If there is data to be sent, send a control byte followed by a stream of data bytes terminated by releasing SS. Both commands and data are split into two nibbles and a prefix of four "0"s is added to each - so there will never be a stream of commands or data containing five successive "1"s. ie to send 00011111, you send 0000 0001 0000 1111. So the KS0073 can always unambiguously re-synchronise to the command stream. |
| | |
| | {{:arduino:ks0073:fig19.png?600|KS0073 data format}} {{:arduino:ks0073:fig20.png?600|KS0073 data stream format}} |
| | |
| | I used a minimum of 2uS for the clock cycle for SCLK and, as I was not checking the ready status of the chip, a delay of about 40uS between sending bytes to give sufficient time for the chip's internal processing. |
| | |
| | |
| | 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. There are a number of chip features that are not supported by this driver, such as "Low power mode", "Dot scrolling" (shifting the display window by 1 dot increments), "Bidirectional segment addressing" (horizontal mirroring of display), "4-line mode" (for 4 line displays), "Inverting cursor" and "6-dot font width". This is mainly because I couldn't test them with the VLGEM1021 LCM. |
| |
| The functions implemented are: | The functions implemented are: |
| * noBlink(); | * noBlink(); |
| * Turns the blinking cursor on or off. | * Turns the blinking cursor on or off. |
| | * reverse() |
| | * noReverse() |
| | * Turns on or off reverse video mode (white on black, rather than black on white characters) |
| | * (only works when the ks0073 chip has Extended Instruction (IE) pin tied "high") |
| * 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. | * Programs one of the 8 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. | 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. |
| | |
| 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/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> | <a href="/dokuwiki/_detail/electronic/lcd/p8183557a.jpg" class="media"><img width="80%" src="/dokuwiki/_media/electronic/lcd/p8183557a.jpg" class="media" title="KS0073 SPI LCD panel test" alt="KS0073 SPI LCD panel test" /></a> |
| <div class="container"> | <div class="container"> |
| LCD module displaying text output of helloWorld_SPI.ino program | VLGEM1021-09 LCD module displaying text output of helloworld.ino program |
| </div> | </div> |
| </div> | </div> |
| |
| \\ | \\ |
| The programs (v1.00):\\ | The programs (v1.01):\\ |
| * {{:arduino:spilcd:v1.00:helloworld_spi.ino}}, sketch to test the LCD library | * {{:arduino:ks0073:v1.01:helloworld.ino}}, sketch to test the LCD library |
| * {{:arduino:spilcd:v1.00:liquidcrystal_spi.h}}, SPI LCD library | * {{:arduino:ks0073:v1.01:liquidcrystal_ks0073.h}}, KS0073 SPI LCD library |
| * {{:arduino:spilcd:v1.00:liquidcrystal_spi.cpp}}, SPI LCD library | * {{:arduino:ks0073:v1.01:liquidcrystal_ks0073.cpp}}, KS0073 SPI LCD library |
| |
| ====== References and Additional Resources ====== | ====== References and Additional Resources ====== |
| | * {{:electronic:datasheet:samsung:ks0073.pdf|KS0073}} dot matrix LCD driver & controller. |
| |
| ===== Other Arduino LCD drivers ===== | ===== Other Arduino LCD drivers ===== |
| * [[:arduino:mx300 driver library|Canon MX300]], Canon MX300/310 printer 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:spilcd driver library|SPI LCD]], LCD display panel Arduino driver |
| * [[:arduino:t6a34 driver library|Toshiba T6A34]] SPI, HD44780 compatible, LCD display panel Arduino driver | * [[:arduino:t6a34 driver library|Toshiba T6A34]] SPI, HD44780 compatible, LCD display panel Arduino driver |
| |