ST7920 LCD controller/driver IC can display alphabets, numbers, Chinese fonts and self-defined characters. It supports 3 kinds of bus interface, namely 8-bit, 4-bit and serial.
I recently ordered a 128 x 64 Graphic LCD display. The LCD is based on the ST7920 driver, and I am having issue finding information on interfacing this LCD with the Raspberry PI. The data sheet is here: I was wondering if someone could explain to me how to interface with it using 4 bit GPIO and code in python for it. For now, all I'm wanting to do is use the display to display information such as IP, Date, and Time. UPDATE: Nvm guys, I got this to work (kinda).
It works, but it takes a bit of tinkering to get it to work. If anyone needs help, post a reply and i'll tell you how I got mine working as a character display (I cannot help with graphics, only code to display characters. First off, my display is the QC12864B using the ST7920 driver. Thankfully, this driver works pretty well when using the hd44780 lcd library, so for the most part, any code running the hd44780 will work on this also. The large thing that is different, however, is the beginning address for each line when using it as a character display. The ram address's are NOT THE SAME! To utilize the display correctly, you need to change each of the lines ram address starting point in the code to reflect the following: Line 1= 0x80 Line 2= 0x90 Line 3= 0x88 Line 4= 0x98 These will make the display output your text to the correct section on the display.
Now for the wiring. Treat this like a 16 pin display, and don't connect pin 15-18. Connect the rest as if you were using 4 bit parallel.
Following are the websites i used to configure it: add this to the end of the adafruit code replacing this. Code: for char in text: if char ' 2': self.write4bits(0x90) # 2nd line elif char ' n': self.write4bits(0x88) # 3rd line elif char ' 4': self.write4bits(0x98) # 4th line else: self.write4bits(ord(char),True) this will fix the lines and make the display correctly show the text on the correct line (notice the n on the third line.
This is because using 3 caused my display to put a wierd character on the display at the end of said line, so i used n) The only thing not working so far is the screen refresh takes too long, but i personally have yet to understand how to fix it. This does not, however, affect the performance of the lcd in any large way. ST7920 have a serial mode. I have an LCM12864R with ST7920 controller.
I built an interface board that converts it into a SPI device. Pinout:. GND.
VDD. V0, go to contrast adjusting pot (my module have built-in contrast adjusting circuitry so this pin goes not connected). RS, this pin is chip select, inverted from nCS line of the SPI bus. R/W, this pin is serial data, connected to MOSI of the SPI bus. Strobe, this pin is serial clock, connected to SCK of the SPI bus. DB0-DB7, unused and not connected.
PSB, this pin selects function mode, tied to ground to force serial mode. NC. RST, reset pin, not connected as my board have onboard power on reset circuitry.
VEE, not connected. A, connected to 3.3V power rail. K, grounded. Then the driver is written using wiringPi to manage SPI bus and write(2) system call to manipulate the data, as it is yet another SPI device here. This quick & dirty setup will not allow bidirectional data flow, but if you want you can use a simple microcontroller (or some 74HCxx sequential logic and one 74HC4066) to make it a full SPI-compatible bidirectional device. Also, after found the best contrast of your LCD, you can fix it down by using something that can produce a stable voltage at V0 pin, I biased my HD44780-driven 16x2 screen with two 1N4148 diodes and a 5.1k resistor which keeps the V0 pin at its sweet spot, 1.22V.
Dear All, Can anyone please provide links for: 1. Complete sketch (from start to end) using ST7920 Controller for this Parallel/serial selectable GLCD (128x64) according to this GLCD's specific pinouts (see below) and 2. The full Pinout for the Mega2560 Board connecting this GLCD; There are numerous sketches and very different 128x64 GCLD's Controllers out there BUT none seem to be for the above combination. Or the information that is available is only discernable by one who is fully conversant with the programming languages. I have located the Datasheet, (DS) for the ST7920 controller - and readers looking for this information need to be aware there are various publication dates for this specific DS ranging from Oct 2002 to Aug 2008 and possibly later as well, and they can be substantially different or don't include the same pin assignments - which adds to both the difficulty in trying to nut this out yourself and creates even more confusion since almost all these 'other' GLCD's use two pins, CS1 & CS2 instead of a single pin, E?
The correct pinout for my 128x64 GLCD which carries the only identifying feature of J12864 followed by two chinese characters is: Pin 1 - GND; Pin 2 - Vcc; Pin 3 - Vo; Pin 4 - RS; Pin 5 - R/W; Pin 6 - E; Pin 7 to Pin 14 - DB0 to DB7; Pin 15 - PSB (Parallel-H/serial-L select); Pin 16 - NC; Pin - 17 RST; Pin 18 - Vout; (from internal voltage doubler); BLA (Backlight annode); Pin 20 - BLK (Cathode). I hope someone can please put me out of my misery and point me in the right direction. I have, I believe thoroughly chceked(??) both the Arduino and Adafruit sites but to no avail??? Hi Oliver, Thank you again for your quick reply. I am however a tad confused with some of what you have said, eg,; '.
Connect E, RW, RS and RST with some GPIO ports of your board.' I understand the GPIO Serial?? ports on the Mega2560 to be TX/RX pairs - pins 14 to 19? Are you suggesting that 'E' should connect to (say) TX3 (Pin 14); 'RW' connects to RX3 (Pin 15); 'RS' to TX2 (Pin 16); 'RST' to RX2 (Pin 17) I also presume that pins DB0 - DB7 on the GLCD will be connected to Mega2560 digital pins (say) 21 - 27???
I have looked at the U8glib and have located the appropriate line to 'uncomment' but need the above to be clarified first. There is also much confusion with a great many of the available sketches (not necessarily the ST7920 controller) on whether a resistor should also be put in series with BLA (220 ohm is suggested when using +5V) in addition to including the variable pot (10K??) to control contrast on Vo? Appreciate your clarification please. Also is there a completed sketch available for both the serial and parallel operation of the same GLCD - if so this would go a long way to seeing what the actual code differences are for both serial and parallel code - and therfore this too would help eliminate confusion arrising from the different codes (serial/parallel) for these different modes of driving the same GLCD? Regards, Ian.
Hi GPIO = means 'General Purpose Input/Output'. You can use any four pins of your board. It does not matter which you use. The good thing about serial mode is, that you do not need to connect DB0 to DB7. See my picture. I have only connected four lines (white wire) with my Arduino board.
Uncommenting a line in u8glib might not need to be enough.You might need to modify the arguments (=pin numbers) of the constructor call. BLA and BLK usually is the power supply for the BackLight LED. It will require an additional (fixed) resistor. 10K should be fine for the variable pot. Without the datasheet of your display it is difficult to say something reliable, but in general the wiper should be connected to v0. One end to GND and the other end to some negative voltage.
Thanks once again Oliver, Re GPIO's - do you mean you can use 4 x digital or 4 x analog pins for these connections or any combination of either, and not the use the TX/RX pins at all? Re Uncommenting the U8glib line might not be enough - I was wondering about this as I could not see anywhere in U8glib code where 'E, RW, RS and RST' were being defined with respect to which pin numbers were connected to Mega2560 pins??? Do you have an example code line for this specific process of 'telling the code which Mega2560 pins are being used'?
I could not see any other similar example in any of the various U8glib code statements that I could see here, either? By the way, I uncommented the code which still only showed the parameters 'E, RW, RS and RST' as these alpha characters but had not substituted any Mega2560 pin numbers and then compiled the code - which compiled OK showing no errors! Not yet sure what will happen once I substitute the pin numbers, though? I have attached the Controller (ST7920 DS) which I believe is in my GLCD but I have not yet located a GLCD DS - I have been chasing the seller of the GLCD to provide both - and we all should hound any seller who doesn't provide this basic info for our purchases, or go to another seller that does provide all the required data although these can be few and far between - and he has just sent me an hour ago the ST7920 DS - BUT WAIT - IT IS ALL IN CHINESE, OF COURSE - and therefore NBG, which I have just let them know!!! So I am still only guessing that my GLCD has the ST7920 in it and as yet have no idea whether or not a BL resistor or its size, is required? Thanks once again Oliver - and this time SUCCESS using your U8glib code! I have attached 3 pictures showing the GLCD working, the Arduino Uno wiring and have included the description of what I did to achieve this for anyone who might be interested in using the 128x64 GLCD!
This monochrome display is an excellent GLCD and shows very crisp alpha-numeric characters. The graphics capability is also quite good. It was very cheap at Aus. The Code: I used U8GLIBST7920128X641X u8g(E, RW, RS, RST); and using the Arduino Uno pins as shown here; U8GLIBST7920128X641X u8g(13, 11, 10); RST GLCD pin 17 was not used as the GLCD worked whether or not RST was connected. I am not sure whether not connecting the RST has any adverse consequences. The one adverse observation noted with this particular code is that it takes a very long time for this code to compile and to upload! Could not connecting the RST be causing this slowness?
Uno Wiring: Parallel/serial select PSB GLCD pin 15 was connected to GND bus, which sets the display in serial mode. Arduino Uno +5V connected to breadboard bus; GND connected to breadboard -ve bus. In my case I used a single 220 ohm resistor connected from +5 bus through the resistor to GLCD pin 19, BLA just to be safe and protect the GLCD backlights, and -ve bus to BLK. I also used a 10K pot as follows; one leg of the pot connected to +5V and the other to GND while the wiper was connected to GLCD Vo pin 3 - the GLCD contrast control. (See below for additional comments on display contrast control).
GLCD GND pin 1 was connected to -ve (GND) bus and GLCD Vcc pin 2 was connected to +5V. And that's it!!! Back of the GLCD: The third picture shows the components on the rear of the display.
Of special interest is VR1; a 7.2K variable pot shown as the 'screw' beneath the R1-R5 header. I believe this pot is a built in display contrast control but as stated in my previous post I have not been able to obtain the Datasheet for this GLCD and have only thus far obtained the ST7920 Controller DS. Below VR1 is jumper pad JP3 which itself is not bridged across this jumper pad. Jumper pad 3 connects with VR1 and is, I believe, the means of switching VR1 into or out of the circuit. Since I have not obtained the GLCD datasheet I am not sure whether VR1 is presently activated so if anyone knows how VR1 (and I am not game enough to just try it without knowing what it does) and JP3 are operated I would be very grateful to know this.
I would be equally interested to learn what R1-R7, R10 and JP1, JP2 and JP4 are controlling? I hope the above description helps anyone who is struggling to get their head around this GLCD!