Help: NHD-0216S3Z-FL-GBW-V3 python modules for use over i2c
I'd like to use my new 16x2 LCD display over i2c on Raspberry Pi (actually a Rock64 running Armbian, but same diff).
My display is the NHD-0216S3Z-FL-GBW-V3.
I've been reading up on the RPLCD library (https://github.com/dbrgn/RPLCD), which looks like a nice modular library to use.
The docs are over here: https://rplcd.readthedocs.io/en/latest/index.html
They support the PCF8574, MCP23008 and MCP23017 I2C port expanders.
The supported character map A00 is exactly the same as the 0A (english+japanese) character mapping from the ST7066, which seems to be an advantageous feature of RPLCD.
So I installed it on my Rock64, changed the i2c address to the appropriate one (0x28, port0 in my case), and attempted to run this simple program:
from RPLCD.i2c import CharLCD
import time
lcd = CharLCD(i2c_expander='PCF8574', address=0x28, port=0, cols=16, rows=2, dotsize=8, charmap=A00)
lcd.write_string('Hello World')
time.sleep(1)
lcd.clear
and the display reads:
ǁǁ$ a`aaǁ
or something like that.
You'll notice that I specified (naively) the PCF8574 i2c expander, since specifying an expander is necessary. I have tried the other combinations of port expanders (MCP23008 and MCP23017) with different but no intelligible results.
So my question is, how shall I modify the RPLCD library code to make it work with the NHD-0216S3Z?
I think I would need to add a "port expander" config, let's call it 'PIC16F690', since that's the name of the controller for this display. It would use the same codec as 'A00'.
From page 7 of the spec (https://www.newhavendisplay.com/specs/NHD-0216S3Z-FL-GBW-V3.pdf) it also seems to require some additional syntax for control commands, such as the command prefix 0xFE.
Can anyone please have a look at https://github.com/dbrgn/RPLCD/blob/master/RPLCD/i2c.py and https://github.com/dbrgn/RPLCD/blob/master/RPLCD/lcd.py and suggest some things I might need to change to get it working?
Also, I have no idea about the relevance of the port expander pin mappings (for example: https://github.com/dbrgn/RPLCD/blob/master/RPLCD/i2c.py#L75) and how they might relate to the PIC16F690 we are using.
Many thanks!
-
I've just been using SMBus to send commands directly to i2c, along the lines of what has been attempted here: http://nhdforum.newhavendisplay.com/index.php/topic,2024.0.html
I can display individual characters occasionally, sometimes these are not the ones requested. I can request to check the baud rate which appears about 5% of the time, and clear the screen, which happens rarely.
I think I know the answer. The i2c on a lot of these devices, including RPi, Rock64, even Arduino, clocks at around 100 kHz. However the NHD-0216S3Z-FL-GBW-V3 datasheet mentions the maximum clock frequency of 50 kHz! So that explains why the display shows the right characters only occasionally.
Newhaven dudes, I suspect you might need to increase your i2c clock frequency on this particular LED display module to make it compatible with a wider range of devices.
One way to test this could be to rebuild an Armbian distribution (or such like) with default i2c clock frequency of 40-50 kHz. Or this might be configurable on the latest Raspberry Pi, by editing the /boot/config.txt file and adding:dtparam=i2c_arm=on,i2c_arm_baudrate=50000
0 -
Hi Falcon,
Thanks for your update on this as it sounds like you now have it working with a clock rate of 50 khz.
The RPLCD Python library looks like a good option to consider using when programming for this character display.
Best Regards,0
Please sign in to leave a comment.
Comments
2 comments